DefaultAggregatedHttpResponse extends AbstractAggregatedHttpMessage implements AggregatedHttpResponse { @Override public ResponseHeaders headers() { return headers; } DefaultAggregatedHttpResponse(List<ResponseHeaders> informationals, ResponseHeaders headers,
                                 HttpData content, HttpHeaders trailers); @Override List<ResponseHeaders> informationals(); @Override HttpStatus status(); @Override ResponseHeaders headers(); @Override int hashCode(); @Override boolean equals(@Nullable Object obj); @Override String toString();  }
@Test void contentLengthIsNotSetWhen204Or205() { ResponseHeaders headers = ResponseHeaders.of(HttpStatus.NO_CONTENT, CONTENT_LENGTH, 100); assertThat(AggregatedHttpResponse.of(headers).headers().get(CONTENT_LENGTH)).isNull(); headers = ResponseHeaders.of(HttpStatus.RESET_CONTENT, CONTENT_LENGTH, 100); assertThat(AggregatedHttpResponse.of(headers).headers().get(CONTENT_LENGTH)).isNull(); headers = ResponseHeaders.of(HttpStatus.NOT_MODIFIED, CONTENT_LENGTH, 100); assertThat(AggregatedHttpResponse.of(headers).headers().getInt(CONTENT_LENGTH)).isEqualTo(100); }
@Test void contentLengthIsSet() { AggregatedHttpResponse res = AggregatedHttpResponse.of(HttpStatus.OK); assertThat(res.headers().getInt(CONTENT_LENGTH)).isEqualTo(6); res = AggregatedHttpResponse.of(HttpStatus.OK, PLAIN_TEXT_UTF_8, HttpData.ofUtf8("foo")); assertThat(res.headers().getInt(CONTENT_LENGTH)).isEqualTo(3); res = AggregatedHttpResponse.of(HttpStatus.OK, PLAIN_TEXT_UTF_8, HttpData.ofUtf8("")); assertThat(res.headers().getInt(CONTENT_LENGTH)).isEqualTo(0); final ResponseHeaders headers = ResponseHeaders.of(HttpStatus.OK, CONTENT_LENGTH, 1000000); assertThat(AggregatedHttpResponse.of(headers).headers().getInt(CONTENT_LENGTH)).isEqualTo(1000000); res = AggregatedHttpResponse.of(headers, HttpData.ofUtf8("foo")); assertThat(res.headers().getInt(CONTENT_LENGTH)).isEqualTo(3); }