[wp-hackers] wp_remote_get() fails but wget works?

Mike Walsh mpwalsh8 at gmail.com
Tue Feb 5 13:49:14 UTC 2013


On Mon, Feb 4, 2013 at 7:07 PM, Dion Hulse (dd32) <wordpress at dd32.id.au>wrote:

> If I had to guess, I'd say the Cookies are not being respected/applied
> for the Redirects, which will most likely cause a redirect loop.
> Hopefully that'll send you down the right rabbit hole..
>
>
> [ ... snipped ... ]

I think you are right based on what I am able to see comparing wget results
to wp_remote_get() results.

When I run wget, it returns the Google Form content after the 5th redirect.

When I run wp_remote_get(), the first 5 redirects match the wget run
exactly but instead of returning the form content, I get another redirect
for something which has already been requested (the service login URL).
 Saving the cookies from the wget run I have 4 cookies:  PREF, NID, S, GAPS
 All of the cookies appear in the data I am dumping from WP_Http but never
at the same time.

I then tried the command line version of cURL and it behaves the same way
that wp_remote_get() behaves, timing out after 50 retries (the default).
 However, if I run cURL and feed it the cookies file I saved from wget it
works!

This is where I am bit out of my depth.  It seems the GAPS cookie is what
the login service is looking for but it doesn't come through the redirect
so it gets into a loop.  Should cookies accumulate through a series of
redirects?  Based on my experiments, I think they should (or at least I
need them to) and I think that is happening with wget but isn't happening
with wp_remote_get() but I am not entirely sure.

Is there a recommended tool for examining headers that I could use for both
wp_remote_get() and wget?

Is there a way to have cookies pass through a series of redirects?

Thanks,

Mike

-- 
Mike Walsh - mpwalsh8 at gmail.com


More information about the wp-hackers mailing list