Open q594054294 opened 2 years ago
实现了HttpProxyAcceptHandler,但是发现只会拦截CONNECT的请求方式,现在想拦截GET,POST等等
` private static final String RESPONE = \"\<!DOCTYPE html>\<html>\<body>\<p>{}\</p>\</body>\</html>\";
String body = StrFormatter.format(HttpProxyServer.RESPONE, "不支持" + method + "请求方式"); response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.METHOD_NOT_ALLOWED); response.headers().set(HttpHeaderNames.CONTENT_TYPE,"text/html"); response.headers().set(HttpHeaderNames.CONTENT_LENGTH,body.length()); response.content().writeBytes(body.getBytes(StandardCharsets.UTF_8)); clientChannel.writeAndFlush(response); clientChannel.writeAndFlush(content); `
使用curl请求,发现无法解析返回的数据,大佬们可以给点建议么?
使用的onAccept(HttpRequest request, Channel clientChannel)方法
你是不是没开https拦截
实现了HttpProxyAcceptHandler,但是发现只会拦截CONNECT的请求方式,现在想拦截GET,POST等等
` private static final String RESPONE = \"\<!DOCTYPE html>\<html>\<body>\<p>{}\</p>\</body>\</html>\";
String body = StrFormatter.format(HttpProxyServer.RESPONE, "不支持" + method + "请求方式"); response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.METHOD_NOT_ALLOWED); response.headers().set(HttpHeaderNames.CONTENT_TYPE,"text/html"); response.headers().set(HttpHeaderNames.CONTENT_LENGTH,body.length()); response.content().writeBytes(body.getBytes(StandardCharsets.UTF_8)); clientChannel.writeAndFlush(response); clientChannel.writeAndFlush(content); `
使用curl请求,发现无法解析返回的数据,大佬们可以给点建议么?