Skip to content

hasResponseBody behaviour seems to be incosistent with the docs #1570

Closed
@silmeth

Description

@silmeth

The Response interface’s hasResponseBody documentation claims:

Return true if the response's body has been computed by an AsyncHandler. It will return false if the either AsyncHandler.onStatusReceived(HttpResponseStatus) or AsyncHandler.onHeadersReceived(HttpHeaders) returned AsyncHandler.State.ABORT

which I understand as true always if the AsyncHandler did not return ABORT from the onStatusReceived or onHeadersReceived (even if the body itself is empty, in such case I would expect to get empty byte array as the accumulated body).

And yet, if one uses the default AsyncCompletionHandler, which always returns CONTINUE from those two methods, if one gets a response with empty body (Content-Length: 0), then hasResponseBody() on the response returns false.

That is the case, because the NettyResponse, which is created by the AsyncCompletionHandler, implements it as:

  @Override
  public boolean hasResponseBody() {
    return isNonEmpty(bodyParts);
  }

I find this confusing, and believe this might be a bug.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions