Thanks to visit codestin.com
Credit goes to github.com

Skip to content

java实现http代理服务器,支持https,websocket。可拦截处理http、https报文

Notifications You must be signed in to change notification settings

fengqilin/proxyee

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java实现HTTP代理服务器

支持HTTP、HTTPS、WebSocket,HTTPS采用动态签发证书,可以拦截http、https的报文并进行处理。
例如:http(s)协议抓包,http(s)动态替换请求内容或响应内容等等。

原生java实现(仅做为demo,不支持拦截)

    new NativeHttpProxyServer().start(9002);

基于netty实现

    new NettyHttpProxyServer().start(9001);
    //拦截处理
    new  NettyHttpProxyServer().initProxyInterceptFactory(new ProxyInterceptFactory() {
                @Override
                public HttpProxyIntercept build() {
                    return new HttpProxyIntercept() {
                        @Override
                        public boolean beforeRequest(Channel channel, HttpRequest httpRequest) {
                            return false;
                        }
    
                        @Override
                        public boolean beforeRequest(Channel channel, HttpContent httpContent) {
                            return false;
                        }
    
                        @Override
                        public boolean afterResponse(Channel channel, HttpResponse httpResponse) {
                            //修改响应头
                            httpResponse.headers().set("Intercept","111");
                            return false;
                        }
    
                        @Override
                        public boolean afterResponse(Channel channel, HttpContent httpContent) {
                            return false;
                        }
                    };
                }
            }).start(8999);

流程

SSL握手

SSL握手

HTTP通讯

HTTP通讯

About

java实现http代理服务器,支持https,websocket。可拦截处理http、https报文

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%