PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTTP » HTTP_Request » Bug #2792

Transfer-encoding chunked with empty body triggers an error

Details

Submitted2004-11-19 12:07 UTC
Fromafradejas at mediafusion dot es
Assignedavb
StatusClosed
PackageHTTP_Request
PHP Version4.3.9
OSLinux
Roadmaps(Not assigned)

Comments

[2004-11-19 12:07 UTC] afradejas at mediafusion dot es

Description:
------------
If the response for a request is chunked, and there's no body data (empty body, so no chunks at all), then there's an error as Socket->read() is called with 0 length.

WARNING [/usr/lib/php4/php/Net/Socket.php:262]
fread(): Length parameter must be greater than 0.

Here's a patch that fixes it.

--- Request.php Fri Nov 19 13:04:34 2004
+++ Request_patched.php Fri Nov 19 13:02:35 2004
@@ -1105,8 +1105,10 @@
}
}
}
- $data = $this->_sock->read($this->_chunkLength);
- $this->_chunkLength -= strlen($data);
+ if ($this->_chunkLength > 0) {
+ $data = $this->_sock->read($this->_chunkLength);
+ $this->_chunkLength -= strlen($data);
+ }
if (0 == $this->_chunkLength) {
$this->_sock->readLine(); // Trailing CRLF
}