php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59698 Redirects does not work as expected when using POST or PUT
Submitted: 2011-04-04 10:02 UTC Modified: 2011-05-13 20:16 UTC
From: djpate at gmail dot com Assigned: jawed (profile)
Status: Closed Package: oauth (PECL)
PHP Version: 5.3.1 OS: Ubuntu 10.10
Private report: No CVE-ID: None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
20 + 41 = ?
Subscribe to this entry?

 
 [2011-04-04 10:02 UTC] djpate at gmail dot com
Description:
------------
Hello again,

I'm writing a code to integrate google calendar api and I struggled to modify an Event using their API to finally realize that the problem came from the automatic redirect.

Reproduce code:
---------------
//This should work but doesn't

$this->oauth->fetch("https://www.google.com/calendar/feeds/default/private/full",$event,OAUTH_HTTP_METHOD_POST,array("Content-Type"=>"application/json","GData-Version"=>"2"));

//The working fix

$this->oauth->disableRedirects();
				
				$this->oauth->fetch("https://www.google.com/calendar/feeds/default/private/full",$event,OAUTH_HTTP_METHOD_POST,array("Content-Type"=>"application/json","GData-Version"=>"2"));
				
				$info = $this->oauth->getLastResponseInfo();
				
				if($info['http_code'] == 302){
					$this->oauth->fetch($info['redirect_url'],$event,OAUTH_HTTP_METHOD_POST,array("Content-Type"=>"application/json","GData-Version"=>"2"));
				}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-04-05 03:55 UTC] djpate at gmail dot com
The same bug appears when using DELETE method.
 [2011-04-13 12:10 UTC] hugh dot lomas at lodestarbpm dot com
I have had the same issue, and was going to submit a bug 
report.

I noticed that my POST submissions, when redirected, were 
being changed to GET methods when following the redirect.

After digging around for a long time, I found lines 1740-
1759 of OAuth.c in 1.1.0:
----------
if (soo->redirects >= OAUTH_MAX_REDIRS) {
   /*stuff*/
} else {
    ++soo->redirects;
    oauth_apply_url_redirect(&surl, soo-
>last_location_header);
    smart_str_0(&surl);
    final_http_method = OAUTH_HTTP_METHOD_GET;
}
----------

I'm not completely familiar with C or this code base, but it 
appears to me that the main suspect is line 1758, where it 
is setting the method to GET. 

In the context of the function, this appears that any time a 
redirect is followed, it defaults to GET.

This is a problem for me since I have to use a workaround 
similar to what djpate posted.
 [2011-04-13 13:29 UTC] jawed@php.net
Thx, I'll take this.

- JJ
 [2011-05-13 20:16 UTC] datibbaw@php.net
This bug has been fixed in SVN.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.

Please try again on trunk
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Oct 05 15:01:27 2024 UTC