Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.4.4

Bug #18107 Use of stream_get_contents() cause bad interpretation of chunked result
Submitted: 2010-12-08 20:56 UTC
From: purebill Assigned:
Status: Open Package: Testing_Selenium (version SVN)
PHP Version: 5.2.9 OS: MS Windows 7
Roadmaps: (Not assigned)    
Subscription  


 [2010-12-08 20:56 UTC] purebill (Ilya Sedlovsky)
Description: ------------ I've tried to get screenshot from the Selenium-RC server (using captureEntirePageScreenshotToString() method) and found out that the image data been sent from the server was not all data the server was trying to send in the response. As I've found out latter this is because server have been sending the Base64-encoded PNG file content using HTTP chunked transfer type and stream_get_contents() function, that is used to get the server response, not getting the full response but getting some part of it. Maybe the problem is caused by the bug in my version of PHP. But, to prevent from this kind of behavior, I propose to use cURL instead of stream_get_contents(), as cURL understand chunked-transfered response correctly. I've tried to use the code like this and it corrects the bug for me: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url ); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 600 ); $response = curl_exec($ch); curl_close($ch);

Comments