Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b3fd35e

Browse files
authoredOct 27, 2022
fix: support custom host header on request proto change (#237)
1 parent df84eff commit b3fd35e

File tree

6 files changed

+5
-28
lines changed

6 files changed

+5
-28
lines changed
 

‎.vscode/launch.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Proxyee is a JAVA written HTTP proxy server library that supports HTTP, HTTPS, W
2525
<dependency>
2626
<groupId>com.github.monkeywie</groupId>
2727
<artifactId>proxyee</artifactId>
28-
<version>1.6.9</version>
28+
<version>1.7.0</version>
2929
</dependency>
3030
```
3131

‎README_zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Proxyee 是一个 JAVA 编写的 HTTP 代理服务器类库,支持 HTTP、HTTP
2525
<dependency>
2626
<groupId>com.github.monkeywie</groupId>
2727
<artifactId>proxyee</artifactId>
28-
<version>1.6.9</version>
28+
<version>1.7.0</version>
2929
</dependency>
3030
```
3131

‎pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.github.monkeywie</groupId>
77
<artifactId>proxyee</artifactId>
8-
<version>1.6.9</version>
8+
<version>1.7.0</version>
99

1010
<packaging>jar</packaging>
1111

‎src/main/java/com/github/monkeywie/proxyee/handler/HttpProxyServerHandler.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,6 @@ private void handleProxyData(Channel channel, Object msg, boolean isHttp) throws
287287
RequestProto newRP = ProtoUtil.getRequestProto(httpRequest);
288288
if (!newRP.equals(pipeRp)) {
289289
isChangeRp = true;
290-
// 更新Host请求头
291-
if ((pipeRp.getSsl() && pipeRp.getPort() == 443)
292-
|| (!pipeRp.getSsl() && pipeRp.getPort() == 80)) {
293-
httpRequest.headers().set(HttpHeaderNames.HOST, pipeRp.getHost());
294-
} else {
295-
httpRequest.headers().set(HttpHeaderNames.HOST, pipeRp.getHost() + ":" + pipeRp.getPort());
296-
}
297290
}
298291
}
299292

‎src/test/java/com/github/monkeywie/proxyee/InterceptForwardHttpProxyServer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.github.monkeywie.proxyee.server.HttpProxyServerConfig;
99
import com.github.monkeywie.proxyee.util.HttpUtil;
1010
import io.netty.channel.Channel;
11+
import io.netty.handler.codec.http.HttpHeaderNames;
1112
import io.netty.handler.codec.http.HttpRequest;
1213

1314
/**
@@ -37,6 +38,7 @@ public void beforeRequest(Channel clientChannel, HttpRequest httpRequest,
3738
pipeline.getRequestProto().setHost("www.taobao.com");
3839
pipeline.getRequestProto().setPort(443);
3940
pipeline.getRequestProto().setSsl(true);
41+
httpRequest.headers().set(HttpHeaderNames.HOST, "www.taobao.com");
4042
}
4143
pipeline.beforeRequest(clientChannel, httpRequest);
4244
}

0 commit comments

Comments
 (0)
Please sign in to comment.