Skip to content

ProxyContext.sendResponse is not completed if the body is set to nullΒ #110

@tsegismont

Description

@tsegismont

Consider this method that configures the response:

  private static void setReturnAsNotChanged(ProxyContext context) {
    // @formatter:off
    context.response()
        .setBody(null)
        .setStatusCode(Response.Status.NOT_MODIFIED.getStatusCode())
        .setStatusMessage(Response.Status.NOT_MODIFIED.getReasonPhrase())
        .headers()
            .remove(HttpHeaders.CONTENT_LENGTH)
            .remove(HttpHeaders.CONTENT_TYPE)
            .remove(HttpHeaders.CONTENT_ENCODING);
    // @formatter:on
  }

The body is set to null because the user doesn't want to send anything to the client.

When context.sendResponse() is invoked, the returned future is never completed.

This happens because the completionHander is not invoked when the body is null:

if (body == null) {
proxiedResponse.end();
return;
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions