From 1b4db8d9b70411d0e9761a42c6eaaa73408859e4 Mon Sep 17 00:00:00 2001 From: yuriyshafranyuk1 Date: Wed, 29 Mar 2017 19:16:46 +0300 Subject: [PATCH 1/2] Verify that request is not null. --- .../org/littleshoot/proxy/impl/ClientToProxyConnection.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/littleshoot/proxy/impl/ClientToProxyConnection.java b/src/main/java/org/littleshoot/proxy/impl/ClientToProxyConnection.java index 964858fbf..a50b33384 100644 --- a/src/main/java/org/littleshoot/proxy/impl/ClientToProxyConnection.java +++ b/src/main/java/org/littleshoot/proxy/impl/ClientToProxyConnection.java @@ -443,7 +443,7 @@ void respond(ProxyToServerConnection serverConnection, HttpFilters filters, // if this HttpResponse does not have any means of signaling the end of the message body other than closing // the connection, convert the message to a "Transfer-Encoding: chunked" HTTP response. This avoids the need // to close the client connection to indicate the end of the message. (Responses to HEAD requests "must be" empty.) - if (!ProxyUtils.isHEAD(currentHttpRequest) && !ProxyUtils.isResponseSelfTerminating(httpResponse)) { + if ((currentHttpRequest != null && !ProxyUtils.isHEAD(currentHttpRequest)) && !ProxyUtils.isResponseSelfTerminating(httpResponse)) { // if this is not a FullHttpResponse, duplicate the HttpResponse from the server before sending it to // the client. this allows us to set the Transfer-Encoding to chunked without interfering with netty's // handling of the response from the server. if we modify the original HttpResponse from the server, From 5285ccd65b8e633474cdfca9b297d47309de8d5d Mon Sep 17 00:00:00 2001 From: yuriyshafranyuk1 Date: Thu, 30 Mar 2017 14:26:17 +0300 Subject: [PATCH 2/2] Removed no needed parenthesis --- .../org/littleshoot/proxy/impl/ClientToProxyConnection.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/littleshoot/proxy/impl/ClientToProxyConnection.java b/src/main/java/org/littleshoot/proxy/impl/ClientToProxyConnection.java index a50b33384..32d8d01ec 100644 --- a/src/main/java/org/littleshoot/proxy/impl/ClientToProxyConnection.java +++ b/src/main/java/org/littleshoot/proxy/impl/ClientToProxyConnection.java @@ -443,7 +443,7 @@ void respond(ProxyToServerConnection serverConnection, HttpFilters filters, // if this HttpResponse does not have any means of signaling the end of the message body other than closing // the connection, convert the message to a "Transfer-Encoding: chunked" HTTP response. This avoids the need // to close the client connection to indicate the end of the message. (Responses to HEAD requests "must be" empty.) - if ((currentHttpRequest != null && !ProxyUtils.isHEAD(currentHttpRequest)) && !ProxyUtils.isResponseSelfTerminating(httpResponse)) { + if (currentHttpRequest != null && !ProxyUtils.isHEAD(currentHttpRequest) && !ProxyUtils.isResponseSelfTerminating(httpResponse)) { // if this is not a FullHttpResponse, duplicate the HttpResponse from the server before sending it to // the client. this allows us to set the Transfer-Encoding to chunked without interfering with netty's // handling of the response from the server. if we modify the original HttpResponse from the server,