Skip to content

Commit

Permalink
Test adding Connection: close header, see #7
Browse files Browse the repository at this point in the history
  • Loading branch information
ecovaci committed Apr 8, 2022
1 parent 988b99e commit c944602
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.HttpHostConnectException;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.kpax.winfoom.annotation.ThreadSafe;
import org.kpax.winfoom.config.ProxyConfig;
Expand Down Expand Up @@ -88,6 +89,8 @@ void handleRequest(final ClientConnection clientConnection, final ProxyInfo prox

response.removeHeaders(HttpHeaders.VIA);
response.removeHeaders(HttpHeaders.PROXY_AUTHENTICATE);
response.removeHeaders(HttpHeaders.CONNECTION);// Remove the Connection header
// in order to add Connection: close header later.

for (Header header : response.getAllHeaders()) {
if (HttpHeaders.TRANSFER_ENCODING.equals(header.getName())) {
Expand All @@ -109,6 +112,10 @@ void handleRequest(final ClientConnection clientConnection, final ProxyInfo prox
}
}

clientConnection.write(
HttpUtils.createHttpHeader(HttpHeaders.CONNECTION,
HTTP.CONN_CLOSE));

// Empty line marking the end
// of header's section
clientConnection.writeln();
Expand Down

0 comments on commit c944602

Please sign in to comment.