Skip to content
Snippets Groups Projects
Commit 1b5f82cb authored by Andreas Gohr's avatar Andreas Gohr
Browse files

Better write handling in HTTPClient

This patch takes care of a problem when sending large data to a remote server
through via HTTP. The write to a socket might not always send the whole chunk
in one piece. Now data is written in a loop until all bytes where sent to the
socket.

darcs-hash:20080708204703-7ad00-50809261df03c6c741393501d41d2beba128ac70.gz
parent 46e875ce
No related branches found
No related tags found
No related merge requests found
......@@ -231,7 +231,19 @@ class HTTPClient {
$this->_debug('request',$request);
// send request
fputs($socket, $request);
$towrite = strlen($request);
$written = 0;
while($written < $towrite){
$ret = fwrite($socket, substr($request,$written));
if($ret === false){
$this->status = -100;
$this->error = 'Failed writing to socket';
return false;
}
$written += $ret;
}
// read headers from socket
$r_headers = '';
do{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment