cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: Weird 302 error loop

From: andrew baird <andybaird_at_gmail.com>
Date: Wed, 22 Aug 2007 16:12:32 -0500

All I had to do was set a cookie file:

curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");

That did the trick! Thanks for the help Daniel.

The next thing I want to do is be able to post things to this page. I can
carry post data just fine, but the problem now is the page that it gets sent
to shifts around to other locations a couple of times before finally making
it to the form:

HTTP/1.0 302 Moved Temporarily
Date: Wed, 22 Aug 2007 20:20:22 GMT
Server: Apache/2.0.55 (Unix) PHP/5.2.1
X-Powered-By: PHP/5.2.1
Set-Cookie: PHPSESSID=d1670bd6e41cb27243b13b4072603587; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
Pragma: no-cache
Set-Cookie:
ExpiredPost=a%3A4%3A%7Bs%3A8%3A%22study_id%22%3Bs%3A5%3A%2285545%22%3Bs%3A13%3A%22department_id%22%3Bs%3A2%3A%2212%22%3Bs%3A14%3A%22frm_stm_status%22%3Bs%3A1%3A%221%22%3Bs%3A5%3A%22notes%22%3Bs%3A11%3A%22Okay+i+will%22%3B%7D
Location: /index.php?redir=/app/stm/index.php&action=save_notes
Content-Length: 0
Content-Type: text/html; charset=iso-8859-1
X-Cache: MISS from wc02.inet.mesa1.secureserver.net
Connection: close

HTTP/1.0 302 Moved Temporarily
Date: Wed, 22 Aug 2007 20:20:23 GMT
Server: Apache/2.0.55 (Unix) PHP/5.2.1
X-Powered-By: PHP/5.2.1
Set-Cookie: PHPSESSID=aed0e6f3aec7d4ee0d20c7d27c328e8b; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
Pragma: no-cache
Location:
?main_action=do_login&auth=1&redir=/app/stm/index.php&action=save_notes
Content-Length: 0
Content-Type: text/html; charset=iso-8859-1
X-Cache: MISS from wc01.inet.mesa1.secureserver.net
Connection: close

HTTP/1.0 302 Moved Temporarily
Date: Wed, 22 Aug 2007 20:20:23 GMT
Server: Apache/2.0.55 (Unix) PHP/5.2.1
X-Powered-By: PHP/5.2.1
Set-Cookie: PHPSESSID=bbb4ebc97d9529038ec9a3067b443e03; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
Pragma: no-cache
Set-Cookie: ExpiredPost=deleted; expires=Tue, 22-Aug-2006 20:20:22 GMT
Location: /app/stm/index.php?main_action=do_login&auth=1&action=save_notes
Content-Length: 0
Content-Type: text/html; charset=iso-8859-1
X-Cache: MISS from wc04.inet.mesa1.secureserver.net
Connection: close

HTTP/1.0 200 OK
Date: Wed, 22 Aug 2007 20:20:23 GMT
Server: Apache/2.0.55 (Unix) PHP/5.2.1
X-Powered-By: PHP/5.2.1
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
Pragma: no-cache
Set-Cookie: ExpiredPost=deleted; expires=Tue, 22-Aug-2006 20:20:22 GMT
Content-Length: 6208
Content-Type: text/html; charset=iso-8859-1
X-Cache: MISS from wc01.inet.mesa1.secureserver.net
Connection: close

Error. Cannot save study note because study_id is not defined!.

It looks to me l ike what happens is when it finally hits the right form,
its no longer sending the post data. Any ideas?

On 8/21/07, Daniel Stenberg <daniel_at_haxx.se> wrote:
>
> On Tue, 21 Aug 2007, andrew baird wrote:
>
> > I set up my PHP script as follows [domains, users, and passwords have
> been
> > censored]:
>
> Do note that this script doesn't enable libcurl's "cookie engine", it only
> sets a single string to pass in the cookie header. I bet that's not what
> the
> site wants.
>
> > This goes on for about 20 more responses. Each time the location is
> > different, but it does eventually loop and start hitting the same
> locations
> > over. The final response is a 302 error with a Location header, but for
> > whatever reason cURL doesn't follow it. Perhaps this is a preventative
> > feature of cURL?
>
> libcurl has a set amount of maximum number of redirects to follow,
> possibly
> you reached that.
>
> Also, you should consider using CURLOPT_VERBOSE to compare the request
> headers
> as well with the request headers you've recorded with livehttpheaders...
>
> --
> Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-08-22