How to handle redirection in post method using HttpClient?

In my application, I send the xml file to the server, but sometimes the server sends back 302 and then redirects.

However, after redirecting, the method becomes GET, not POST, and my data in the XML file cannot be delivered to the server.

And finally, the status code I received is 404.

Is there a way to handle the redirect yourself? Can I do something when a redirect occurs?

Can anybody help? thanks.

+3
source share
2 answers

From RFC 2616 :

302 , GET HEAD, , , , .

, 'POST, redirect, GET' idiom?

Apache HTTP. :

_httpClient = new DefaultHttpClient();
_httpClient.getParams().setParameter(
    ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE);
+5

302 GET, 303 . , HttpClient ...:-P

, - HTTP- , . , , - - , , , .

PHP - , HTTP - . , cURL , ?

0

Source: https://habr.com/ru/post/1626593/


All Articles