diff options
author | Andreas Gohr <andi@splitbrain.org> | 2008-07-08 22:47:03 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2008-07-08 22:47:03 +0200 |
commit | 1b5f82cb521991619bd5ae26e07d8c6588e7bd18 (patch) | |
tree | 21a4a72b58eefecf2b449891e490672ce677c83c | |
parent | 46e875ce740bbc55abd094481b5bb12298985ef7 (diff) | |
download | rpg-1b5f82cb521991619bd5ae26e07d8c6588e7bd18.tar.gz rpg-1b5f82cb521991619bd5ae26e07d8c6588e7bd18.tar.bz2 |
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
-rw-r--r-- | inc/HTTPClient.php | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index 7474e1fd8..3d843c912 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -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{ |