N
N
Nikita Roschenko2015-08-04 16:26:29
PHP
Nikita Roschenko, 2015-08-04 16:26:29

How to set method for follow location in cURL?

Good afternoon, I came across a strange behavior of curl, its essence is as follows:
There is a page to which we send curl post data.
The page returns "HTTP/1.1 302 Found" in response to us, which is a normal response.
Further, when CURLOPT_FOLLOWLOCATION = true is set, curl tries to send a POST request again but to a new location.
Is there any way to make curl go to a new location using the GET method?
PS I can't give an example code, because third-party libraries are used.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander N++, 2015-08-04
@Avillions

It is forbidden.
CURLOPT_FOLLOWLOCATION This option was conceived for this, if the response is 301, 302 then send the same request to the redirected address.
As a solution.
Wait for a response from the first request without ending the curl session to change options and send a GET.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question