Skip to content

ServerResource throws away response entities. #848

@defnull

Description

@defnull

How to reproduce:

@Put
public void putData() {
    setStatus(Status.SUCCESS_NO_CONTENT)
    Representation repr = new StringRepresentation("", MediaType.TEXT_PLAIN);
    repr.setModificationDate(addr.modified);
    getResponse().setEntity(repr);
}

Expected behavior:
An empty HTTP response body, but with correct Date and Content-Type headers.

Observed behavior:
No Date and Content-Type header in the HTTP response.

Why?
The implementation of Representation.isAvailable() ignores the available-flag if the size of the entity is 0. ServerResource.handle() throws away the entity if it is not available (or empty) and replaces it with the return value of the annotated method, even for void methods.

If I explicitly set a response entity, I expect it to be honored in the response, regardless of its content, as long as it is marked available. Currently, it is not.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions