Skip to content

Commit

Permalink
Remove the special handling of status codes 204/304
Browse files Browse the repository at this point in the history
These codes are correctly handled by Netty via commit
netty/netty@70c5c48
  • Loading branch information
violetagg committed Sep 27, 2017
1 parent 4fb2365 commit 116466f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ext {
assertJVersion = '3.6.1'

// Libraries
nettyVersion = '4.1.15.Final'
nettyVersion = '4.1.16.Final'
jacksonDatabindVersion = '2.5.1'

// Testing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ final Mono<Void> withWebsocketSupport(String url,
@Override
protected void handleOutboundWithNoContent() {
int status = nettyResponse.status().code();
if (status == 204 || status == 205 || status == 304) {
if (status == 205) {
nettyResponse.headers()
.remove(HttpHeaderNames.TRANSFER_ENCODING)
.set(HttpHeaderNames.CONTENT_LENGTH, 0);
Expand Down
24 changes: 18 additions & 6 deletions src/test/java/reactor/ipc/netty/http/server/HttpServerTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -475,15 +475,27 @@ public void nonContentStatusCodes() {
}

private void checkResponse(String url, int port) {
Mono<HttpHeaders> response =
Mono<HttpClientResponse> response =
HttpClient.create(ops -> ops.port(port))
.get(url)
.flatMap(res -> Mono.just(res.responseHeaders()));
.get(url);

StepVerifier.create(response)
.expectNextMatches(h -> !h.contains("Transfer-Encoding") &&
h.contains("Content-Length") &&
Integer.parseInt(h.get("Content-Length")) == 0)
.expectNextMatches(r -> {
int code = r.status().code();
HttpHeaders h = r.responseHeaders();
if (code == 204 || code == 304) {
return !h.contains("Transfer-Encoding") &&
!h.contains("Content-Length");
}
else if (code == 205) {
return !h.contains("Transfer-Encoding") &&
h.contains("Content-Length") &&
Integer.parseInt(h.get("Content-Length")) == 0;
}
else {
return false;
}
})
.expectComplete()
.verify(Duration.ofSeconds(30));
}
Expand Down

0 comments on commit 116466f

Please sign in to comment.