Re: Re: cvs: pear /HTTP_Request Request.php
| From: | Alexey Borzov | Date: | Wed, 08 Oct 2003 08:35:17 +0000 |
| Subject: | Re: Re: cvs: pear /HTTP_Request Request.php | ||
| References: | 1 2 3 4 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-22464@lists.php.net to get a copy of this message | ||
Hi!
moshe doron wrote:
IMO both solutions smell of hack too much. :[ What really needs to be done to support 100 Continue and to f.e. give the ability to display progress bar when downloading a large file is refactoring HTTP_Response, *especially* getting rid of $socket->readAll() call. As the class is effectively private, I suspect it will not lead to any BC breaks. What I suggest: Removing response-processing logic from constructor (there can be errors and constructors cannot return these). Creating a readResponse() method with the following logic (pseudocode): do { readHeaders(); processHeaders(); notifyListeners(); if (100 == $code) {My best solution so far (didn't test it) is a regular expression basedspliton 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,here my implementation for the bad HTTP_Response code this code deal with: 1. 100 2. cookies wrong urlencode 3. improving the the flow structure by removing duplicate code into else\if. http://moshe.i-com-it.com/patchs/HTTP_Request.3.txt anyway your implementaion is bad coz we need the headers of the 100 chunk into the 200 (or whatever) one (e.g, times cookies are send on the 100 chunk).PREG_SPLIT_NO_EMPTY); //split on HTTP header $response = array_pop($responseParts); //returning last element
$headers = true;} else {
$headers = false;} } while ($headers); while ($data = readData()) { processData(); notifyListeners(); } I uploaded Stefan Walk's version of HTTP_Request I already talked about: http://oc.cs.msu.su/pear/Request.phps I do not agree with his implementation and the amount of changes he did, but this can serve as a starting point to extract a smaller and more manageable patch. Your opinions?