Skip to content

Commit

Permalink
fix: release bug
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie committed Apr 28, 2021
1 parent 5e00725 commit e65f6a2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Proxyee is a JAVA written HTTP proxy server library that supports HTTP, HTTPS, W
<dependency>
<groupId>com.github.monkeywie</groupId>
<artifactId>proxyee</artifactId>
<version>1.4.2</version>
<version>1.4.3</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Proxyee 是一个 JAVA 编写的 HTTP 代理服务器类库,支持 HTTP、HTTP
<dependency>
<groupId>com.github.monkeywie</groupId>
<artifactId>proxyee</artifactId>
<version>1.4.2</version>
<version>1.4.3</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.github.monkeywie</groupId>
<artifactId>proxyee</artifactId>
<version>1.4.2</version>
<version>1.4.3</version>
<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,25 @@ public final void afterResponse(Channel clientChannel, Channel proxyChannel,
// 判断是第一个处理FullResponse的拦截器是否匹配
boolean isFirstMatch = isMatch != null && isMatch == true;
// 判断后续的拦截器是否匹配
boolean isAfterMatch = isFirstMatch ? false : matchHandle(pipeline.getHttpRequest(), pipeline.getHttpResponse(), pipeline);
boolean isAfterMatch = isFirstMatch ? false : match(pipeline.getHttpRequest(), pipeline.getHttpResponse(), pipeline);
if (isFirstMatch || isAfterMatch) {
handleResponse(pipeline.getHttpRequest(), fullHttpResponse, pipeline);
if (fullHttpResponse.headers().contains(HttpHeaderNames.CONTENT_LENGTH)) {
httpResponse.headers().set(HttpHeaderNames.CONTENT_LENGTH, fullHttpResponse.content().readableBytes());
}
if (pipeline.getHttpRequest() instanceof FullHttpRequest) {
FullHttpRequest fullHttpRequest = (FullHttpRequest) pipeline.getHttpRequest();
if (fullHttpRequest.content().refCnt() > 0) {
ReferenceCountUtil.release(fullHttpRequest);
}
}
}
if (isFirstMatch) {
proxyChannel.pipeline().remove("decompress");
proxyChannel.pipeline().remove("aggregator");
}
} else {
this.isMatch = matchHandle(pipeline.getHttpRequest(), pipeline.getHttpResponse(), pipeline);
this.isMatch = match(pipeline.getHttpRequest(), pipeline.getHttpResponse(), pipeline);
if (this.isMatch) {
proxyChannel.pipeline().addAfter("httpCodec", "decompress", new HttpContentDecompressor());
proxyChannel.pipeline()
Expand All @@ -70,18 +76,6 @@ protected boolean isHtml(HttpRequest httpRequest, HttpResponse httpResponse) {
.matches("^text/html.*$");
}

private boolean matchHandle(HttpRequest httpRequest, HttpResponse httpResponse,
HttpProxyInterceptPipeline pipeline) {
boolean isMatch = match(httpRequest, httpResponse, pipeline);
if (httpRequest instanceof FullHttpRequest) {
FullHttpRequest fullHttpRequest = (FullHttpRequest) httpRequest;
if (fullHttpRequest.content().refCnt() > 0) {
ReferenceCountUtil.release(fullHttpRequest);
}
}
return isMatch;
}

/**
* 匹配到的响应会解码成FullResponse
*/
Expand Down

0 comments on commit e65f6a2

Please sign in to comment.