users@jersey.java.net

[Jersey] POST without body

From: Erik Hennum <efhennum_at_gmail.com>
Date: Wed, 22 Jan 2014 10:59:26 -0800

Hi, Jersey Folk:

We're trying to upgrade from 1.x to 2.x

On 1.x, we make a few POST requests that provides no body or Content-Type
header but accept a response.

The rationale for the empty body is the standard one in REST: the request
creates a new entity (in particular, a transaction) where all input for the
entity
creation is available on the server and no input is needed from the client.

I note that the following workaround was suggested when this question
came up recently:

    Client.newClient().target(...).request().post(Entity.entity(null,
"foo/bar"));
    http://markmail.org/message/4bmg5slbrfzgtusu

However, this workaround fails in our environment. It appears that, because
of the Content-Type header, the server waits for the client to send the body
until the request times out.

A null MediaType throws an IllegalArgumentException from Jersey.

Is there an alternative workaround that invokes POST with neither a body
or Content-Type header (so we can port these 1.x requests to 2.x)?


Thanks in advance,


Erik Hennum