hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Remis (JIRA)" <j...@apache.org>
Subject [jira] [Created] (HTTPCLIENT-1501) Fluent API not accepting form parameters
Date Thu, 24 Apr 2014 16:14:18 GMT
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: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message