X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fhttpclient.php;h=64a51353c76e106cdfc10f79b90c6337a7b806b6;hb=1c40e7c139af98e4fe9c73093da4183ad8d9e234;hp=3f82620761c6eef8d953cc11fa9611addad5ba96;hpb=a2b830392597d88c435baf54ad0df4ecda02dc41;p=quix0rs-gnu-social.git diff --git a/lib/httpclient.php b/lib/httpclient.php index 3f82620761..64a51353c7 100644 --- a/lib/httpclient.php +++ b/lib/httpclient.php @@ -81,12 +81,13 @@ class HTTPResponse extends HTTP_Request2_Response } /** - * Check if the response is OK, generally a 200 status code. + * Check if the response is OK, generally a 200 or other 2xx status code. * @return bool */ function isOk() { - return ($this->getStatus() == 200); + $status = $this->getStatus(); + return ($status >= 200 && $status < 300); } } @@ -119,6 +120,16 @@ class HTTPClient extends HTTP_Request2 { $this->config['max_redirs'] = 10; $this->config['follow_redirects'] = true; + + // We've had some issues with keepalive breaking with + // HEAD requests, such as to youtube which seems to be + // emitting chunked encoding info for an empty body + // instead of not emitting anything. This may be a + // bug on YouTube's end, but the upstream libray + // ought to be investigated to see if we can handle + // it gracefully in that case as well. + $this->config['protocol_version'] = '1.0'; + parent::__construct($url, $method, $config); $this->setHeader('User-Agent', $this->userAgent()); }