curl-library
Re: Patch for 301/302 redirect after post
Date: Mon, 4 Aug 2008 12:59:40 +0200 (CEST)
On Mon, 4 Aug 2008, Martin Drasar wrote:
>> You can easily detect 301/302 codes yourself when having it activated and
>> then make them cause errors get returned.
>
> Can I? When CURLOPT_FOLLOWLOCATION is turned on? Please tell me how, because
> that would render half of my patch unneeded.
Sure, just use the HEADERFUNCTION and parse the headers you get passed to it.
Identifying the first status line in a response should be easy.
> I understand that you don't want to fill the code with overly specific
> features and having bool CURLOPT_POST302 is better than nothing for sure...
I would even prefer to proceed like this:
1 - CURLOPT_POST301 gets renamed to CURLOPT_POSTREDIR (while of course still
supporting the old name for a number of years ahead) - of course if
someone has a better idea for a name I'm open for it.
2 - CURLOPT_POSTREDIR then takes the original options 0 to act as default and
1 to change the 301 behavior. Then we add 2 to just change the 302
behavior and 3 to change both 301 and 302.
3 - Then we create a few nice defines for these magic values so that we don't
have to use magic constant numbers in app source code.
What do you say?
-- / daniel.haxx.seReceived on 2008-08-04