我尝试使用mule作为简单的http代理,但是看到从实际端点服务器发送的cookie不会传递到客户端。Mule response只有一个cookie。
<flow name="HelloWorld" doc:name="HelloWorld">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8888" doc:name="Http Endpoint"/>
<http:outbound-endpoint
method="GET" exchange-pattern="request-response"
address="http://www.google.com"
contentType="text/html" doc:name="HTTP" />
</flow>发布于 2014-04-03 03:50:16
我认为您的问题不是将cookies传递给客户端,而是您收到的cookies将指向localhost域,因此当它们来自本地主机域时,基本的web浏览器可能会出于安全原因拒绝它们,即使它们没有被拒绝,它们也不会随后续对.google.com的调用一起发送。
现在,cookie以列表的形式从http出站而来,您可以使用以下内容进行迭代和更新
#[foreach (cookie: message.inboundProperties['Set-Cookie']) {cookie.domain='localhost'}] 但您还需要检查是否存在Set-Cookie属性,以便在服务器未设置Cookie时不会产生空指针异常。
为了调试您的代理应用程序,您还可以/应该记录从http出站接收到的消息,以查看是否存在cookie。
从客户端/浏览器到代理服务器,我认为cookie应该工作得很好,因为不涉及域数据。
https://stackoverflow.com/questions/22798422
复制相似问题