logo       

cvs: pear /HTTP_Request Request.php: msg#00596

php.cvs.pear

Subject: cvs: pear /HTTP_Request Request.php

richard Thu Sep 26 08:18:28 2002 EDT

Modified files:
/pear/HTTP_Request Request.php
Log:
Added Gzip content encoding support
Fixed proxy auth

Patch from PHPSurf



Index: pear/HTTP_Request/Request.php
diff -u pear/HTTP_Request/Request.php:1.15 pear/HTTP_Request/Request.php:1.16
--- pear/HTTP_Request/Request.php:1.15 Mon Sep 16 14:00:40 2002
+++ pear/HTTP_Request/Request.php Thu Sep 26 08:18:27 2002
@@ -32,7 +32,7 @@
// | Author: Richard Heyes <richard@xxxxxxxxxxx> |
// +-----------------------------------------------------------------------+
//
-// $Id: Request.php,v 1.15 2002/09/16 18:00:40 richard Exp $
+// $Id: Request.php,v 1.16 2002/09/26 12:18:27 richard Exp $
//
// HTTP_Request Class
//
@@ -190,7 +190,11 @@
// Host header
if (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http) {
$this->addHeader('Host', $this->_url->host);
- }
+
+ if (extension_loaded('zlib')) {
+ $this->addHeader('Accept-Encoding', 'gzip');
+ }
+ }
}

/**
@@ -207,7 +211,7 @@
$this->_proxy_host = $host;
$this->_proxy_port = $port;
$this->_proxy_user = $user;
- $this->_proxy_port = $port;
+ $this->_proxy_pass = $pass;

if (!empty($user)) {
$this->addHeader('Proxy-Authorization', 'Basic ' .
base64_encode($user . ':' . $pass));
@@ -518,7 +522,7 @@
{
// Fetch all
$response = $sock->readAll();
-
+
if (PEAR::isError($response)) {
return $response;
}
@@ -530,11 +534,13 @@
list($this->_protocol, $this->_code) = sscanf($headers[0], '%s %s');
unset($headers[0]);
foreach ($headers as $value) {
- $headername = substr($value, 0, strpos($value, ':'));
- $headervalue = ltrim(substr($value, strpos($value, ':') + 1));
+ $headername = substr($value, 0, strpos($value, ':'));
+ $headername_i = strtolower($headername);
+ $headervalue = ltrim(substr($value, strpos($value, ':') + 1));

- if ('Set-Cookie' != $headername) {
+ if ('set-cookie' != $headername_i) {
$this->_headers[$headername] = $headervalue;
+ $this->_headers[$headername_i] = $headervalue;
} else {
// Parse a SetCookie header to fill _cookies array
$cookie = array(
@@ -579,7 +585,7 @@
$this->_body = substr($response, strpos($response, "\r\n\r\n") + 4);

// If response was chunked, parse it out
- if (@$this->_headers['Transfer-Encoding'] == 'chunked') {
+ if (@$this->_headers['transfer-encoding'] == 'chunked') {
$body = $this->_body;
$chunks = array();
while (true) {
@@ -603,7 +609,13 @@
// Save chunks to $this->_body
$this->_body = implode('', $chunks);
}
-
+
+ // If response was compressed using gzip, uncompress it
+ if (@$this->_headers['content-encoding'] == 'gzip') {
+ $body = substr($this->_body, 10);
+ $this->_body = gzinflate($body);
+ }
+
return true;
}
}



--
PEAR CVS Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise