Skip to content

Commit

Permalink
random size headers
Browse files Browse the repository at this point in the history
  • Loading branch information
liuganghuan committed Sep 6, 2023
1 parent e74c2c3 commit fe1d823
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/com/arloor/forwardproxy/session/Status.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.net.InetSocketAddress;
import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;

import static io.netty.handler.codec.http.HttpResponseStatus.INTERNAL_SERVER_ERROR;
import static io.netty.handler.codec.http.HttpResponseStatus.PROXY_AUTHENTICATION_REQUIRED;
Expand Down Expand Up @@ -142,8 +143,12 @@ public void operationComplete(ChannelFuture future) throws Exception {
String targetAddr = ((InetSocketAddress) outboundChannel.remoteAddress()).getAddress().getHostAddress();
session.setAttribute(TraceConstant.target.name(), targetAddr);
// Connection established use handler provided results
ChannelFuture responseFuture = channelContext.channel().writeAndFlush(
new DefaultHttpResponse(request.protocolVersion(), new HttpResponseStatus(200, "Connection Established")));
DefaultHttpResponse response = new DefaultHttpResponse(request.protocolVersion(), new HttpResponseStatus(200, "Connection Established"));
int size = ThreadLocalRandom.current().nextInt(150);
for (int i = 0; i < size; i++) {
response.headers().add("Server", "JavaHttpProxy");
}
ChannelFuture responseFuture = channelContext.channel().writeAndFlush(response);
responseFuture.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture channelFuture) {
Expand Down

0 comments on commit fe1d823

Please sign in to comment.