[wp-hackers] WP_HTTP deflating small packets

Tim Nash tim at newmedias.co.uk
Tue Mar 1 14:15:27 UTC 2011


Hi all,
We have been having interesting problem with wp_http simple request
returns either a 1 or an error string.
Problem is instead of return a 1 it appears to be returning a binary
string. If we put more then 7 chars on the page then they are returned
happily.

$request = new WP_Http;
   $result = $request->request($url);
   if (is_wp_error($result)) {
       return FALSE;
   }
   if ($result['response']['code'] == 200) {
       // success
       return $result['body'];
   } else {
       return FALSE;
   }
What's being returned
Array ( [method] => GET [timeout] => 5 [redirection] => 5
[httpversion] => 1.0 [user-agent] => WordPress/3.1;
http://wordpress_dev [blocking] => 1 [headers] => Array (
[Accept-Encoding] => deflate;q=1.0, compress;q=0.5 ) [cookies] =>
Array ( ) [body] => [compress] => [decompress] => 1 [sslverify] => 1
[ssl] => [local] => )

The weird bit is:
Array ( [0] => Accept-Encoding: deflate;q=1.0, compress;q=0.5 )

Looking at wp_http this seems to being set and can't be overridden. We
have got round the problem as we are simply changing the return to
pass enough data but thats a hack rather then a solution, wondering if
anyone had come across this problem (that piece of code has been our
work horse for some time so its only a recent thing) and if anyone has
a solution.

Cheers
Tim

-- 
Tim Nash
Technical Director

Coding Futures Ltd
The Tannery
91 Kirkstall Road
Leeds
LS3 1HS

Company House Registration Number:  07350515
Company Registered in England and Wales

Contact Telephone: +44(0)113 2473850

The contents of this email is for the named parties, if you have
receieved this email in error please accept our apologises. Unless
separately mentioned the content of the email are considered private with
content belonging to the authors.

NewMedias is a brand for Coding Futures Ltd


More information about the wp-hackers mailing list