Re: cvs: pear /HTTP_Request Request.php
| From: | Dave Mertens | Date: | Tue, 07 Oct 2003 19:39:25 +0000 |
| Subject: | Re: cvs: pear /HTTP_Request Request.php | ||
| References: | 1 2 | Groups: | php.pear.cvs |
| Request: | Send a blank email to pear-cvs+get-13467@lists.php.net to get a copy of this message | ||
>
> > - AND !empty($this->_response->_headers['Location'])) {
> > + AND !empty($this->_response->_headers['location'])) {
>
> ...
>
> > - $redirect = $this->_response->_headers['Location'];
> > + $redirect = $this->_response->_headers['location'];
>
> I can't remember the whole code, but shouldn't this be using the _header_i
> variable?
That was also my thought, but only the variable that contains the lowercase
headername (headername_i) as the suffix. The headername is just stored in
the associative array fully in lowercase and on original version.
A bit of the code: (Request.php, lines 729-737)
foreach ($headers as $value) {
$headername = substr($value, 0, strpos($value, ':'));
$headername_i = strtolower($headername);
$headervalue = ltrim(substr($value, strpos($value, ':') + 1));
if ('set-cookie' != $headername_i) {
$this->_headers[$headername] = $headervalue;
$this->_headers[$headername_i] = $headervalue;
} else {
...
}
As you've might noticed, the php website is now also redirects for
downloading php packages.
The url 'http://www.php.net/get/php-4.3.3.tar.bz2/from/a/mirror'
is working
perfectly with above code.
Althru i'm very sure that the webserver is sending the Location header,
using the lowercase form is working.
Above url is sending users to a overview page with mirros, so tests can be
done withour downloading php ;-)
Althru the bug was reported that 'location: xx' headers weren't supported,
I've couldn't find one sending this header.
Apache and IIS are both sending the Location. Also the AOLserver (I was
hoping that www.netscape.com was running on a Netscape enterprise server)
sends a perfect Location header.
BTW. I'm also finding a way to support the '100 continue' HTTP status. PHP
bug: 25486.
My best solution so far (didn't test it) is a regular expression based split
on the HTTP/1.1 headers.
To my opinion the last item in the returned array should assigned the
$response variable where now the socket is read.
resulting in something like: (near line 709)
$fullRespone = $sock->readAll();
$reponseParts = preg_split("^HTTP/1.[0|1"\ \d{3}\ .*\n$", $fullResponse, -1,
PREG_SPLIT_NO_EMPTY); //split on HTTP header
$response = array_pop($responseParts); //returning last element
The rest of the code shouldn't need any changes.
But like I said before, I didn't test my theory
With best regards,
Dave Mertens