尝试使用Mule作为http代理

时间:2014-04-01 22:51:20

标签: mule

我尝试使用mule作为简单的http代理,但是看到从实际端点服务器发送的cookie不会传递给客户端。骡子响应只有一个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>

1 个答案:

答案 0 :(得分:0)

我认为您的问题不是将Cookie传递给客户端,但是您收到的Cookie会指向.google.com域,因此当他们来自localhost时,出于安全原因,基本的Web浏览器可能会拒绝它们域,即使它们没有被拒绝,也不会随后调用localhost发送它们。

现在,Cookie来自http出站作为列表,您可以使用

等内容进行迭代和更新
#[foreach (cookie: message.inboundProperties['Set-Cookie']) {cookie.domain='localhost'}] 

但是,当服务器没有设置cookie时,您还需要检查Set-Cookie属性是否存在不产生空指针异常。

用于调试代理应用程序,您也可以/应该记录从http出站收到的消息,以查看是否存在cookie。

从客户端/浏览器到代理服务器,我认为cookie应该可以正常工作,因为不涉及域数据。