开发者

Apache HttpComponents does not follow redirect request despite setting

I'm doing a POST to a web server of a MultipartEntity to upload a file. Apache HttpComponents version 4.1.

The response I get is a 302 re开发者_如何学Godirect. If I use a BasicResponseHandler that throws a ClientProtocolException. (The JavaDoc for BasicResponseHandler says that client may follow a redirect, which is pretty vague!)

The docs led me to believe that the client would automatically follow a redirect and return that response. I explicitly set HANDLE_REDIRECTS true in the client parameters.

What am I missing here?


Redirects of some request types (mainly entity enclosing ones such as POST and PUT) MAY NOT be executed automatically per requirements of the HTTP specification. You can override the default behaviour of HttpClient by using a custom RedirectStrategy.


May be it's the same issue as here: URLConnection Doesn't Follow Redirect . It follows only the same protocol, and doesn't redirect from HTTP to HTTPS (or some other combination of different protocols).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜