-
Notifications
You must be signed in to change notification settings - Fork 255
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
Conversation
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); |
There was a problem hiding this comment.
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
@@ -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); | |||
} |
There was a problem hiding this comment.
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
@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
33f7462
to
522d72c
Compare
} | ||
|
||
|
||
private static class RawMessageHandler extends ChannelDuplexHandler { |
There was a problem hiding this comment.
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.
Thanks @jamesgorman2 ! |
Update
RawRequest
andHttpServerResponseImpl
so they returncontent-length: 0
and an empty body when no writes are made toHttpClientRequest
andHttpServerResponse
respectively.This also adds some regression level tests against the bytes sent and received from the server.
(#470, #520)