Git Product home page Git Product logo

Comments (12)

xidianzxm avatar xidianzxm commented on May 17, 2024

也有这样的需求。match请求参数和请求体里面的判断放在一起,来改响应

from proxyee.

monkeyWie avatar monkeyWie commented on May 17, 2024

你是问这个项目的还是netty的http模块啊,这个项目的话可以直接通过HttpProxyInterceptPipeline访问到request和response

from proxyee.

xidianzxm avatar xidianzxm commented on May 17, 2024

pipeline再获取request的时候,是HttpRequest,不是FullHttpRequest;只能获取到Http请求头,不能获取到请求体,需要根据请求头和请求体进行match,来改响应

from proxyee.

monkeyWie avatar monkeyWie commented on May 17, 2024

这个目前没有,需要的话可以参考下FullResponseIntercept,或者在Intercept手动存下每一次的HttpContent直到读取到LastHttpContent再去解析

from proxyee.

xidianzxm avatar xidianzxm commented on May 17, 2024

请求我加了aggregator编码,直接解析FullHttpRequest,正在改,后面不懂得再向你咨询,多谢!

from proxyee.

xidianzxm avatar xidianzxm commented on May 17, 2024

HttpProxyServerHandle->handleProxyData(Channel channel, Object msg, boolean isHttp)
确认了msg是FullHttpRequest对象(能够打印出来http请求头和请求体)

HttpProxyClientHandle->channelRead(ChannelHandlerContext ctx, Object msg)
{...
HttpProxyInterceptPipeline interceptPipeline = ((HttpProxyServerHandle) clientChannel.pipeline().get("serverHandle")).getInterceptPipeline();

FullHttpRequest fullHttpRequest = (FullHttpRequest)interceptPipeline.getHttpRequest();
//上面这行代码,我调试使用,fullHttpRequest的只能拿到请求头,不能拿到请求体
//不知道为什么,能帮助解读下吗?
...

}

from proxyee.

xidianzxm avatar xidianzxm commented on May 17, 2024

作者可否实现 “根据请求头和请求体进行match,来改响应” 的功能?

from proxyee.

monkeyWie avatar monkeyWie commented on May 17, 2024

嗯 我看看能不能提供一个FullRequestIntercept

from proxyee.

xidianzxm avatar xidianzxm commented on May 17, 2024

Thanks!

from proxyee.

xidianzxm avatar xidianzxm commented on May 17, 2024

现在暂时绕了一下,从beforereqest里截取了请求体,然后把请求体中要过滤的内容放到请求头中,然后在match中进行请求头的判断。
期望后期FullRequestIntercept部分的check in,多谢大神!

from proxyee.

monkeyWie avatar monkeyWie commented on May 17, 2024

@xidianzxm 已经提交了3240814

from proxyee.

monkeyWie avatar monkeyWie commented on May 17, 2024

可以配合FullRequestIntercept+FullResponseIntercept一起使用

from proxyee.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.