cURL / Mailing Lists / curl-library / Single Mail

curl-library

Disables POST, goes with GET

From: Shmulik Regev <shmulbox_at_gmail.com>
Date: Wed, 24 Jan 2007 18:50:32 +0200

Hi,

I'm using libcurl to simulate logins to a site that answers a login with a
302 (as many do). Instructing libcurl to follow redirects causes libcurl to
respond to this 302 with a GET, i.e. I get the "Disables POST, goes with
GET" debug message.

However, the original Content-Length and Content-Type headers are still
there, and in particular the existence of a non-zero Content-Length causes
the server to not respond to the request (or so I guess) and the entire
thing times out. Note that I used the HTTPHEADER option to manually set
these two fields, hence the custom headers mechanism overrides libcurl's
default behavior. Currently, I catch the debug info ('Disables POST, goes
with GET') and call curl_easy_setopt(CURLOPT_HTTPHEADER) with empty
Content-Length and Content-Type headers to remove them from the GET request.
This does the trick but seems somewhat kludgey.

My question is however, should libcurl automatically strip out these two
headers (and possibly others) when following redirects and switching from
POST to GET? If so, where would be the best place to do it?

Cheers,
Shmulik Regev
Received on 2007-01-24