| @@ 3214-3221 (lines=8) @@ | ||
| 3211 | while (!isset($lb)) { |
|
| 3212 | ||
| 3213 | // We might EOF during header read. |
|
| 3214 | if (feof($this->fp)) { |
|
| 3215 | $this->incoming_payload = $data; |
|
| 3216 | $this->debug('found no headers before EOF after length ' . strlen($data)); |
|
| 3217 | $this->debug("received before EOF:\n" . $data); |
|
| 3218 | $this->setError('server failed to send headers'); |
|
| 3219 | ||
| 3220 | return false; |
|
| 3221 | } |
|
| 3222 | ||
| 3223 | $tmp = fgets($this->fp, 256); |
|
| 3224 | $tmplen = strlen($tmp); |
|
| @@ 3227-3234 (lines=8) @@ | ||
| 3224 | $tmplen = strlen($tmp); |
|
| 3225 | $this->debug("read line of $tmplen bytes: " . trim($tmp)); |
|
| 3226 | ||
| 3227 | if ($tmplen == 0) { |
|
| 3228 | $this->incoming_payload = $data; |
|
| 3229 | $this->debug('socket read of headers timed out after length ' . strlen($data)); |
|
| 3230 | $this->debug('read before timeout: ' . $data); |
|
| 3231 | $this->setError('socket read of headers timed out'); |
|
| 3232 | ||
| 3233 | return false; |
|
| 3234 | } |
|
| 3235 | ||
| 3236 | $data .= $tmp; |
|
| 3237 | $pos = strpos($data, "\r\n\r\n"); |
|
| @@ 3302-3309 (lines=8) @@ | ||
| 3299 | $tmp = fgets($this->fp, 256); |
|
| 3300 | $tmplen = strlen($tmp); |
|
| 3301 | $this->debug("read chunk line of $tmplen bytes"); |
|
| 3302 | if ($tmplen == 0) { |
|
| 3303 | $this->incoming_payload = $data; |
|
| 3304 | $this->debug('socket read of chunk length timed out after length ' . strlen($data)); |
|
| 3305 | $this->debug("read before timeout:\n" . $data); |
|
| 3306 | $this->setError('socket read of chunk length timed out'); |
|
| 3307 | ||
| 3308 | return false; |
|
| 3309 | } |
|
| 3310 | $content_length = hexdec(trim($tmp)); |
|
| 3311 | $this->debug("chunk length $content_length"); |
|
| 3312 | } |
|
| @@ 3319-3326 (lines=8) @@ | ||
| 3316 | $tmp = fread($this->fp, $readlen); |
|
| 3317 | $tmplen = strlen($tmp); |
|
| 3318 | $this->debug("read buffer of $tmplen bytes"); |
|
| 3319 | if (($tmplen == 0) && (!feof($this->fp))) { |
|
| 3320 | $this->incoming_payload = $data; |
|
| 3321 | $this->debug('socket read of body timed out after length ' . strlen($data)); |
|
| 3322 | $this->debug("read before timeout:\n" . $data); |
|
| 3323 | $this->setError('socket read of body timed out'); |
|
| 3324 | ||
| 3325 | return false; |
|
| 3326 | } |
|
| 3327 | $strlen += $tmplen; |
|
| 3328 | $data .= $tmp; |
|
| 3329 | } |
|
| @@ 3334-3341 (lines=8) @@ | ||
| 3331 | $tmp = fgets($this->fp, 256); |
|
| 3332 | $tmplen = strlen($tmp); |
|
| 3333 | $this->debug("read chunk terminator of $tmplen bytes"); |
|
| 3334 | if ($tmplen == 0) { |
|
| 3335 | $this->incoming_payload = $data; |
|
| 3336 | $this->debug('socket read of chunk terminator timed out after length ' . strlen($data)); |
|
| 3337 | $this->debug("read before timeout:\n" . $data); |
|
| 3338 | $this->setError('socket read of chunk terminator timed out'); |
|
| 3339 | ||
| 3340 | return false; |
|
| 3341 | } |
|
| 3342 | } |
|
| 3343 | } while ($chunked && ($content_length > 0) && (!feof($this->fp))); |
|
| 3344 | if (feof($this->fp)) { |
|