Remis created HTTPCLIENT-1501:
---------------------------------
Summary: Fluent API not accepting form parameters
Key: HTTPCLIENT-1501
URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1501
Project: HttpComponents HttpClient
Issue Type: Bug
Components: Fluent HC
Affects Versions: 4.3.3
Reporter: Remis
I just tried to run the example from
[http://hc.apache.org/httpcomponents-client-ga/tutorial/html/fluent.html]:
{code:title=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"));
}{code}
and I got an unexpected error (I was expecting a connection error):
{code}
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)
{code}
--
This message was sent by Atlassian JIRA
(v6.2#6252)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]