Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.3.3
-
None
Description
I just tried to run the example from http://hc.apache.org/httpcomponents-client-ga/tutorial/html/fluent.html:
Test.java
public static void main(final String[] args) throws Exception { // Execute a POST with a custom header through the proxy containing a request body // as an HTML form and save the result to the file Request.Post("http://somehost/some-form") .addHeader("X-Custom-header", "stuff") .viaProxy(new HttpHost("myproxy", 8080)) .bodyForm(Form.form().add("username", "vip").add("password", "secret").build()) .execute().saveContent(new File("result.dump")); }
and I got an unexpected error (I was expecting a connection error, but it seems that HttpClient failed before the request was sent):
Exception in thread "main" java.lang.IllegalStateException: POST request cannot enclose an entity
at org.apache.http.client.fluent.Request.body(Request.java:299)
at org.apache.http.client.fluent.Request.bodyString(Request.java:331)
at org.apache.http.client.fluent.Request.bodyForm(Request.java:312)
at org.apache.http.client.fluent.Request.bodyForm(Request.java:316)
Attachments
Issue Links
- duplicates
-
HTTPCLIENT-1474 HTTP POST with Fluent HC is broken
- Closed