On 07 Nov 2013, at 16:41, cowwoc <cowwoc_at_bbs.darktech.org> wrote:
> 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.
What I'm thinking is to make a flag (which could be by default enabled in the Jersey test client and) that would make sure Jersey is not trying to remove any headers. (Even though in this case I think we have a different problem - look at the post(...) method javadoc and the sentece about overwriting Content-* headers; there is also a related bug filed on that already, IIRC).
> 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
> 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.
That is not very RESTful. Representation should not drive the resource "type".
>
> 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
Yuck! I certainly would not want to support the above, or make it any easier to support that. If you want to create new resources like this, you should better design a separate "collection" URIs for that - /companies/5/teminals , /companies/5/expense-reports
> POST without either a Content-Type or body
> Used to insert a new element into a collection (there is no confusion about the kind of child resource being created).
> Example: Create a new "transaction" by invoking POST /transactions: http://stackoverflow.com/a/147299/14731
This is doable, right?
Marek
> 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> 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> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I just noticed something funny. It seems to be impossible to send POST requests to a URI:
>>>>> With a Content-Type but no body
>>>>> Without either a Content-Type or body
>>>>> Why is that? I believe both of these use-cases are legal.
>>>>>
>>>>> Thanks,
>>>>> Gili
>>>>
>>>
>>
>