Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Jetty 9 http client post and put problem

Hi,

On Thu, Apr 4, 2013 at 6:58 PM, Erich Bremer <erich@xxxxxxxxxxx> wrote:
> Hi,
>
>     I am testing a simple Jetty 9 http client with the following code:
>
>             HttpClient httpClient = new HttpClient();
>             URI uri = new
> URI("http://myserver.com/serverprog?param=http://someuri.com";);
>             httpClient.start();
>             HttpRequest r = new HttpRequest(httpClient, uri);
>             r.method(HttpMethod.POST);
>
> It works beautifully for POST, but if I change it to PUT, the
> "?param=http://someuri.com"; doesn't get passed to the server where it does
> with the POST.  Any thoughts?  Thanks, Erich

It's a bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=405044

Please don't instantiate HttpRequest directly.
Follow documentation at:
http://www.eclipse.org/jetty/documentation/current/http-client.html

Your code should be:

HttpClient httpClient = new HttpClient();
httpClient.start();
URI uri = new URI("http://myserver.com/serverprog?param=http://someuri.com";);
ContentResponse response = client.newRequest(uri).method(HttpMethod.PUT).send();

It's already fixed in latest master.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.


Back to the top