tags:

views:

1350

answers:

3

I have tried switching from a previous Post request to a Get request. Which assumes its a Get but eventually does a post.

I tried the following in PHP :

curl_setopt($curl_handle, CURLOPT_POSTFIELDS, null);
curl_setopt($curl_handle, CURLOPT_POST, FALSE);
curl_setopt($curl_handle, CURLOPT_HTTPGET, TRUE);

What am I missing?

Additional information: I already have a connection that's setup to do a POST request. That completes successfully but later on when I try to reuse the connection and switch back to GET using the setopts above it still ends up doing a POST internally with incomplete POST headers. The problem is it believes its doing a GET but ends up putting a POST header without the content-length parameter and the connection fails witha 411 ERROR.

A: 

Here is a pretty decent example of the difference:

http://www.weberdev.com/get_example-4606.html

Eli
+1  A: 
RC
A: 

Solved: The problem lies here. I set POST via both _CUSTOMREQUEST and _POST and the _CUSTOMREQUEST persisted as POST while _POST switched to _HTTPGET. The Server assumed the header from _CUSTOMREQUEST to be the right one and came back with a 411.

curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, 'POST');
gnosio