| @@ 3187-3194 (lines=8) @@ | ||
| 3184 | while (!isset($lb)) { |
|
| 3185 | ||
| 3186 | // We might EOF during header read. |
|
| 3187 | if (feof($this->fp)) { |
|
| 3188 | $this->incoming_payload = $data; |
|
| 3189 | $this->debug('found no headers before EOF after length ' . strlen($data)); |
|
| 3190 | $this->debug("received before EOF:\n" . $data); |
|
| 3191 | $this->setError('server failed to send headers'); |
|
| 3192 | ||
| 3193 | return false; |
|
| 3194 | } |
|
| 3195 | ||
| 3196 | $tmp = fgets($this->fp, 256); |
|
| 3197 | $tmplen = strlen($tmp); |
|
| @@ 3200-3207 (lines=8) @@ | ||
| 3197 | $tmplen = strlen($tmp); |
|
| 3198 | $this->debug("read line of $tmplen bytes: " . trim($tmp)); |
|
| 3199 | ||
| 3200 | if ($tmplen == 0) { |
|
| 3201 | $this->incoming_payload = $data; |
|
| 3202 | $this->debug('socket read of headers timed out after length ' . strlen($data)); |
|
| 3203 | $this->debug('read before timeout: ' . $data); |
|
| 3204 | $this->setError('socket read of headers timed out'); |
|
| 3205 | ||
| 3206 | return false; |
|
| 3207 | } |
|
| 3208 | ||
| 3209 | $data .= $tmp; |
|
| 3210 | $pos = strpos($data, "\r\n\r\n"); |
|
| @@ 3276-3283 (lines=8) @@ | ||
| 3273 | $tmp = fgets($this->fp, 256); |
|
| 3274 | $tmplen = strlen($tmp); |
|
| 3275 | $this->debug("read chunk line of $tmplen bytes"); |
|
| 3276 | if ($tmplen == 0) { |
|
| 3277 | $this->incoming_payload = $data; |
|
| 3278 | $this->debug('socket read of chunk length timed out after length ' . strlen($data)); |
|
| 3279 | $this->debug("read before timeout:\n" . $data); |
|
| 3280 | $this->setError('socket read of chunk length timed out'); |
|
| 3281 | ||
| 3282 | return false; |
|
| 3283 | } |
|
| 3284 | $content_length = hexdec(trim($tmp)); |
|
| 3285 | $this->debug("chunk length $content_length"); |
|
| 3286 | } |
|
| @@ 3293-3300 (lines=8) @@ | ||
| 3290 | $tmp = fread($this->fp, $readlen); |
|
| 3291 | $tmplen = strlen($tmp); |
|
| 3292 | $this->debug("read buffer of $tmplen bytes"); |
|
| 3293 | if (($tmplen == 0) && (!feof($this->fp))) { |
|
| 3294 | $this->incoming_payload = $data; |
|
| 3295 | $this->debug('socket read of body timed out after length ' . strlen($data)); |
|
| 3296 | $this->debug("read before timeout:\n" . $data); |
|
| 3297 | $this->setError('socket read of body timed out'); |
|
| 3298 | ||
| 3299 | return false; |
|
| 3300 | } |
|
| 3301 | $strlen += $tmplen; |
|
| 3302 | $data .= $tmp; |
|
| 3303 | } |
|
| @@ 3308-3315 (lines=8) @@ | ||
| 3305 | $tmp = fgets($this->fp, 256); |
|
| 3306 | $tmplen = strlen($tmp); |
|
| 3307 | $this->debug("read chunk terminator of $tmplen bytes"); |
|
| 3308 | if ($tmplen == 0) { |
|
| 3309 | $this->incoming_payload = $data; |
|
| 3310 | $this->debug('socket read of chunk terminator timed out after length ' . strlen($data)); |
|
| 3311 | $this->debug("read before timeout:\n" . $data); |
|
| 3312 | $this->setError('socket read of chunk terminator timed out'); |
|
| 3313 | ||
| 3314 | return false; |
|
| 3315 | } |
|
| 3316 | } |
|
| 3317 | } while ($chunked && ($content_length > 0) && (!feof($this->fp))); |
|
| 3318 | if (feof($this->fp)) { |
|