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

Empty body for zero length payloads #522

Merged
merged 2 commits into from
Jul 1, 2016

Conversation

jamesgorman2
Copy link
Collaborator

@jamesgorman2 jamesgorman2 commented Jun 26, 2016

Update RawRequest and HttpServerResponseImpl so they return content-length: 0 and an empty body when no writes are made to HttpClientRequest and HttpServerResponse respectively.

This also adds some regression level tests against the bytes sent and received from the server.

(#470, #520)

Update `RawRequest` and `HttpServerResponseImpl` so they return `content-length: 0` and an empty body
when no writes are made to `HttpClientRequest` and `HttpServerResponse` respectively.

This also adds some regression level tests against the bytes sent and received from the server.
headers = _copyHeaders();
headers.headers().set(HttpHeaderNames.CONTENT_LENGTH, 0);
}

Observable toReturn = Observable.just(headers);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cognate to ContentWriterImpl ll61

@jamesgorman2 jamesgorman2 changed the title Empty body for zero length payloads (#470, #520) Empty body for zero length payloads Jun 26, 2016
@@ -52,7 +52,7 @@ private HttpServerResponseImpl(final State<C> state) {
super(new OnSubscribe<Void>() {
@Override
public void call(Subscriber<? super Void> subscriber) {
state.sendHeaders().write(Observable.<C>empty()).unsafeSubscribe(subscriber);
state.sendHeaders().unsafeSubscribe(subscriber);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out this is write unnecessary - this was causing differing behaviour between

public Observable<Void> handle(HttpServerRequest<ByteBuf> request, HttpServerResponse<ByteBuf> response) {
    return response;
}

and

public Observable<Void> handle(HttpServerRequest<ByteBuf> request, HttpServerResponse<ByteBuf> response) {
    return response
        .sendHeaders();
}

the former previously returned with an empty chunk, the latter content-length: 0

@NiteshKant
Copy link
Member

@jamesgorman2 Thanks for this, good work.

When you address my review comment, I will be happy to pull this in.

Make in style of other tests byt hiding details.

Move client test code over to client rule

TO BE SQUASHED
@jamesgorman2 jamesgorman2 force-pushed the zero-content-length branch from 33f7462 to 522d72c Compare June 30, 2016 04:20
}


private static class RawMessageHandler extends ChannelDuplexHandler {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left this in to capture the response since there's no #channelProvider() method on the server side.

@NiteshKant NiteshKant merged commit a1b534f into ReactiveX:0.5.x Jul 1, 2016
@NiteshKant
Copy link
Member

Thanks @jamesgorman2 !

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

Successfully merging this pull request may close these issues.

2 participants