cvs: pear /HTTP_Request Request.php

From: Date: Thu, 05 Jun 2003 18:14:30 +0000
Subject: cvs: pear /HTTP_Request Request.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-10719@lists.php.net to get a copy of this message
chregu Thu Jun 5 14:14:30 2003 EDT Modified files: /pear/HTTP_Request Request.php Log: Handle badly formed headers "\n\n" from Netscape Enterprise Servers. (by Stephen J.L. Lim) Index: pear/HTTP_Request/Request.php diff -u pear/HTTP_Request/Request.php:1.23 pear/HTTP_Request/Request.php:1.24 --- pear/HTTP_Request/Request.php:1.23 Thu Jun 5 13:54:47 2003 +++ pear/HTTP_Request/Request.php Thu Jun 5 14:14:30 2003 @@ -32,7 +32,7 @@ // | Author: Richard Heyes <richard@phpguru.org> | // +-----------------------------------------------------------------------+ // -// $Id: Request.php,v 1.23 2003/06/05 17:54:47 chregu Exp $ +// $Id: Request.php,v 1.24 2003/06/05 18:14:30 chregu Exp $ // // HTTP_Request Class // @@ -710,9 +710,17 @@ return $response; } + // Handle badly formed headers "\n\n" from Netscape Enterprise Servers. + // Locate delimiter type by inspecting headers. + $delim = "\r\n"; + $crnlcrnl = strpos($response, "\r\n\r\n"); + $nlnl = strpos($response, "\n\n"); + if (($crnlcrnl === false) || ($nlnl !== false && $nlnl < $crnlcrnl)) + $delim = "\n"; + // Sort out headers - $headers = substr($response, 0, strpos($response, "\r\n\r\n")); - $headers = explode("\r\n", $headers); + $headers = substr($response, 0, strpos($response, "$delim$delim")); + $headers = explode($delim, $headers); list($this->_protocol, $this->_code) = sscanf($headers[0], '%s %s'); unset($headers[0]); @@ -765,7 +773,7 @@ } // Store body - $this->_body = substr($response, strpos($response, "\r\n\r\n") + 4); + $this->_body = substr($response, strpos($response, "$delim$delim") + 4); // If response was chunked, parse it out if (@$this->_headers['transfer-encoding'] == 'chunked') { @@ -773,7 +781,7 @@ $chunks = array(); while (true) { $chunksize = 0; - $line = substr($body, 0, $pos = strpos($body, "\r\n")); + $line = substr($body, 0, $pos = strpos($body, "$delim")); $body = substr($body, $pos + 2); if (preg_match('/^([0-9a-f]+)/i', $line, $matches)) {

« previous php.pear.cvs (#10719) next »