Skip to content

Redirects are not follow the same way as the web browser #25

@ajusa

Description

@ajusa

If you use curly to do a POST request, and the server then returns a 302 redirect, curly will attempt to continue doing a POST request to the redirected URL. This is not what curl actually does by default - curl tries to mimic the browser and converts the 302 redirect into a GET.

The reason curly does this is the OPT_CUSTOMREQUEST flag - by setting this, it effectively tells libcurl to only use the specified method to do the request.

https://curl.se/libcurl/c/CURLOPT_CUSTOMREQUEST.html has more information.

The easiest fix for this is to set the CURLFOLLOW_OBEYCODE bit in https://curl.se/libcurl/c/CURLOPT_FOLLOWLOCATION.html - so instead of 1, set 2.

Let me know what you think, happy to send a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions