mirror of
https://github.com/danog/dns-over-https.git
synced 2024-11-26 20:04:47 +01:00
Delay throwing exception for 500ms when 405 is returned
This commit is contained in:
parent
fc4af5c29c
commit
adc1a53c43
@ -5,6 +5,7 @@ namespace Amp\DoH\Internal;
|
|||||||
use Amp;
|
use Amp;
|
||||||
use Amp\Artax\Client;
|
use Amp\Artax\Client;
|
||||||
use Amp\Artax\Request;
|
use Amp\Artax\Request;
|
||||||
|
use Amp\Delayed;
|
||||||
use Amp\Dns\DnsException;
|
use Amp\Dns\DnsException;
|
||||||
use Amp\DoH\JsonDecoderFactory;
|
use Amp\DoH\JsonDecoderFactory;
|
||||||
use Amp\DoH\Nameserver;
|
use Amp\DoH\Nameserver;
|
||||||
@ -84,6 +85,10 @@ final class HttpsSocket extends Socket
|
|||||||
return call(function () use ($response, $id) {
|
return call(function () use ($response, $id) {
|
||||||
$response = yield $response;
|
$response = yield $response;
|
||||||
if ($response->getStatus() !== 200) {
|
if ($response->getStatus() !== 200) {
|
||||||
|
if ($response->getStatus() !== 405) {
|
||||||
|
throw new DnsException("HTTP result !== 200: ".$response->getStatus()." ".$response->getReason());
|
||||||
|
}
|
||||||
|
yield new Delayed(500);
|
||||||
throw new DnsException("HTTP result !== 200: ".$response->getStatus()." ".$response->getReason());
|
throw new DnsException("HTTP result !== 200: ".$response->getStatus()." ".$response->getReason());
|
||||||
}
|
}
|
||||||
$response = yield $response->getBody();
|
$response = yield $response->getBody();
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Amp\DoH\Test;
|
namespace Amp\DoH\Test;
|
||||||
|
|
||||||
|
use Amp\Delayed;
|
||||||
use Amp\Dns;
|
use Amp\Dns;
|
||||||
use Amp\Dns\Record;
|
use Amp\Dns\Record;
|
||||||
use Amp\DoH;
|
use Amp\DoH;
|
||||||
@ -38,18 +39,19 @@ class IntegrationTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @group internet
|
* @group internet
|
||||||
* @dataProvider provideServersAndHostnames
|
* @dataProvider provideServers
|
||||||
*/
|
*/
|
||||||
public function testWorksAfterConfigReload($hostname, $nameserver)
|
public function testWorksAfterConfigReload($nameserver)
|
||||||
{
|
{
|
||||||
$nameserver = new Nameserver(...$nameserver);
|
$nameserver = new Nameserver(...$nameserver);
|
||||||
Loop::run(function () use ($hostname, $nameserver) {
|
Loop::run(function () use ($nameserver) {
|
||||||
$DohConfig = new DoH\DoHConfig([$nameserver]);
|
$DohConfig = new DoH\DoHConfig([$nameserver]);
|
||||||
Dns\resolver(new DoH\Rfc8484StubResolver($DohConfig));
|
Dns\resolver(new DoH\Rfc8484StubResolver($DohConfig));
|
||||||
|
|
||||||
yield Dns\resolve($hostname);
|
yield Dns\resolve('google.com');
|
||||||
$this->assertNull(yield Dns\resolver()->reloadConfig());
|
$this->assertNull(yield Dns\resolver()->reloadConfig());
|
||||||
$this->assertInternalType("array", yield Dns\resolve($hostname));
|
yield new Delayed(500);
|
||||||
|
$this->assertInternalType("array", yield Dns\resolve('google.com'));
|
||||||
});
|
});
|
||||||
\usleep(500*1000);
|
\usleep(500*1000);
|
||||||
}
|
}
|
||||||
@ -77,6 +79,7 @@ class IntegrationTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
\usleep(500*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,6 +105,7 @@ class IntegrationTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
\usleep(500*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -123,6 +127,7 @@ class IntegrationTest extends TestCase
|
|||||||
$this->assertNotNull($record->getTtl());
|
$this->assertNotNull($record->getTtl());
|
||||||
$this->assertSame(Record::PTR, $record->getType());
|
$this->assertSame(Record::PTR, $record->getType());
|
||||||
});
|
});
|
||||||
|
\usleep(500*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -141,6 +146,7 @@ class IntegrationTest extends TestCase
|
|||||||
$this->assertSame($promise1, $promise2);
|
$this->assertSame($promise1, $promise2);
|
||||||
$this->assertSame(yield $promise1, yield $promise2);
|
$this->assertSame(yield $promise1, yield $promise2);
|
||||||
});
|
});
|
||||||
|
\usleep(500*1000);
|
||||||
}
|
}
|
||||||
public function provideServersAndHostnames()
|
public function provideServersAndHostnames()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user