Hi Marek,
Are you proposing adding the necessary API methods but throwing
RuntimeExceptions unless some flag is set? I would support this
approach, although in practice I don't think you'll need such a flag
because we're talking about legal requests. Whether a request is "legal
but non-sense" is a subjective matter. To prove my point, I'll provide
you with specific examples for the use-cases I was inquiring about:
* POST with a Content-Type but no body
o When a parent resource may be used to create different kinds of
child resources, the Content-Type is used to specify which kind
of resource to create.
o Example
+ Create a new "terminal" by invoking POST /companies/5 with
Content-Type: application/vnd.company.terminal
+ Create a new "expense report" by invoking POST /companies/5
with Content-Type: application/vnd.company.expense-report
* POST without either a Content-Type or body
o Used to insert a new element into a collection (there is no
confusion about the kind of child resource being created).
o Example: Create a new "transaction" by invoking POST
/transactions:
http://stackoverflow.com/a/147299/14731
Gili
On 07/11/2013 10:15 AM, Marek Potociar wrote:
> I see a conflict between what we as Jersey implementors want (make
> sure that Jersey client does not produce requests that do not make
> sense) and what you as a unit test developer want (be as flexible as
> possible).
>
> Off the top of my head, one solution is to stick to low-level HTTP
> client libraries for these legal, but non-sense tests. Other solution
> would be to provide some switch in Jersey (and/or the underlying
> connectors) that will force Jersey to ignore any validation/correction
> of these ill requests. Clearly we need some time to think about it and
> come up with the good resolution. Please feel free to file an
> improvement request for this.
>
> Marek
>
> On 05 Nov 2013, at 22:26, cowwoc <cowwoc_at_bbs.darktech.org
> <mailto:cowwoc_at_bbs.darktech.org>> wrote:
>
>>
>> Unit tests. The server might be written in Jersey but I have no
>> guarantee that the client will be. In general, we must be able to
>> test all legal use-cases (even if they are not meaningful) otherwise
>> we have no way of hardening the server against 3rd-party clients.
>>
>> Thanks,
>> Gili
>>
>> On 05/11/2013 3:49 PM, Marek Potociar wrote:
>>> Legal does not necessarily mean meaningful or correct. Why do you
>>> want to do it?
>>>
>>> Marek
>>>
>>> On 26 Oct 2013, at 22:12, cowwoc <cowwoc_at_bbs.darktech.org
>>> <mailto:cowwoc_at_bbs.darktech.org>> wrote:
>>>
>>>> Hi,
>>>>
>>>> I just noticed something funny. It seems to be impossible to
>>>> send POST requests to a URI:
>>>>
>>>> 1. With a Content-Type but no body
>>>> 2. Without either a Content-Type or body
>>>>
>>>> Why is that? I believe both of these use-cases are legal.
>>>>
>>>> Thanks,
>>>> Gili
>>>
>>
>