Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hasResponseBody behaviour seems to be incosistent with the docs #1570

Closed
silmeth opened this issue Aug 8, 2018 · 2 comments
Closed

hasResponseBody behaviour seems to be incosistent with the docs #1570

silmeth opened this issue Aug 8, 2018 · 2 comments
Assignees
Milestone

Comments

@silmeth
Copy link

silmeth commented Aug 8, 2018

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.

@slandelle
Copy link
Contributor

I agree that the actual behavior doesn't match the javadoc.

IMHO, the current javadoc has nothing to do with the current method name hasResponseBody. Such method should be named something like isAborted and sadly it's complicated to fix it until next major release.

So I'd rather fix the javadoc to mach current behavior.

@slandelle slandelle added this to the 3.5.3 milestone Aug 27, 2018
@slandelle slandelle self-assigned this Aug 27, 2018
@slandelle
Copy link
Contributor

Thanks for reporting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants