summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-03-10 15:08:40 -0800
committerBrion Vibber <brion@pobox.com>2010-03-10 15:13:16 -0800
commit5cd020bf299619ca2844f4d14418891a59a0dd22 (patch)
treef3b04ed9020b12568234e1695cd41e4ccb1eaf41
parent294b290dd95a2e4a09026932a2b066ccee587681 (diff)
Workaround intermittent bugs with HEAD requests by disabling keepalive in HTTPClient.
I think this is a bug in Youtube's web server (sending chunked encoding of an empty body with a HEAD response, leaving the connection out of sync when it doesn't attempt to read a body) but the HTTP_Request2 library may need to be adjusted to watch out for that.
-rw-r--r--lib/httpclient.php10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/httpclient.php b/lib/httpclient.php
index 4c3af8d7d..64a51353c 100644
--- a/lib/httpclient.php
+++ b/lib/httpclient.php
@@ -120,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());
}