Throw DNS exception if HTTP response !== 200

This commit is contained in:
Daniil Gentili 2019-06-11 21:04:08 +02:00
parent c94adf5873
commit 1b9e2e6e8b

View File

@ -13,6 +13,7 @@ use LibDNS\Decoder\DecoderFactory;
use LibDNS\Encoder\EncoderFactory;
use LibDNS\Messages\Message;
use function Amp\call;
use Amp\Dns\DnsException;
/** @internal */
final class HttpsSocket extends Socket
@ -81,7 +82,12 @@ final class HttpsSocket extends Socket
}
$response = $this->httpClient->request($request);
return call(function () use ($response, $id) {
$response = yield (yield $response)->getBody();
$response = yield $response;
if ($response->getStatus() !== 200) {
throw new DnsException("HTTP result !== 200: ".$response->getReason());
}
$response = yield $response->getBody();
switch ($this->nameserver->getType()) {
case Nameserver::RFC8484_GET: