HttpConversionUtil#toHttpResponse should use false in isRequest
parameter (#10760)
Motivation: `HttpConversionUtil#toHttpResponse` translates `Http2Headers` to `HttpResponse`. It uses `#addHttp2ToHttpHeaders(..., boolean isRequest)` to do so. However, `isRequest` field is set to `true` instead of `false`. It should be set to `false` because we're doing conversion of Response not Request. Modification: Changed `true` to `false`. Result: Correctly translates `Http2Headers` to `HttpResponse`.
This commit is contained in:
parent
d1cf9774d5
commit
c5077a3d87
@ -318,7 +318,7 @@ public final class HttpConversionUtil {
|
||||
// HTTP/1.1 status line.
|
||||
final HttpResponse msg = new DefaultHttpResponse(HttpVersion.HTTP_1_1, status, validateHttpHeaders);
|
||||
try {
|
||||
addHttp2ToHttpHeaders(streamId, http2Headers, msg.headers(), msg.protocolVersion(), false, true);
|
||||
addHttp2ToHttpHeaders(streamId, http2Headers, msg.headers(), msg.protocolVersion(), false, false);
|
||||
} catch (final Http2Exception e) {
|
||||
throw e;
|
||||
} catch (final Throwable t) {
|
||||
|
@ -189,4 +189,22 @@ public class HttpConversionUtilTest {
|
||||
assertFalse(outHeaders.contains(TRANSFER_ENCODING));
|
||||
assertFalse(outHeaders.contains(UPGRADE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void http2ToHttpHeaderTest() throws Exception {
|
||||
Http2Headers http2Headers = new DefaultHttp2Headers();
|
||||
http2Headers.status("200");
|
||||
http2Headers.path("/meow"); // HTTP/2 Header response should not contain 'path' in response.
|
||||
http2Headers.set("cat", "meow");
|
||||
|
||||
HttpHeaders httpHeaders = new DefaultHttpHeaders();
|
||||
HttpConversionUtil.addHttp2ToHttpHeaders(3, http2Headers, httpHeaders, HttpVersion.HTTP_1_1, false, true);
|
||||
assertFalse(httpHeaders.contains(HttpConversionUtil.ExtensionHeaderNames.PATH.text()));
|
||||
assertEquals("meow", httpHeaders.get("cat"));
|
||||
|
||||
httpHeaders.clear();
|
||||
HttpConversionUtil.addHttp2ToHttpHeaders(3, http2Headers, httpHeaders, HttpVersion.HTTP_1_1, false, false);
|
||||
assertTrue(httpHeaders.contains(HttpConversionUtil.ExtensionHeaderNames.PATH.text()));
|
||||
assertEquals("meow", httpHeaders.get("cat"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user