【问题标题】:remove favicon.ico request in mule删除 mule 中的 favicon.ico 请求
【发布时间】:2015-06-25 03:32:53
【问题描述】:

我正在使用 mule 工作室, 我正在尝试它的例子。

每当我发出 HTTP 浏览器请求时,都会同时出现 2 个请求, 其中第一个是 /favicon.ico,第二个请求是实际请求。

我的配置XML如下。

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="CE-3.2.1" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd 
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd ">
    <jms:activemq-connector name="Active_MQ" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>
    <flow name="Inititationflow" doc:name="Inititationflow">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8046" doc:name="HTTP"/>
        <echo-component doc:name="Echo"/>
        <jms:outbound-endpoint queue="BANK1" exchange-pattern="request-response" doc:name="JMS"/>
    </flow>
    <flow name="SampleTest" doc:name="SampleTest">
        <jms:inbound-endpoint queue="BANK1" connector-ref="Active_MQ" doc:name="JMS"/>
        <echo-component doc:name="Echo"/>
        <append-string-transformer message="AppendedPart" doc:name="Append String"/>
        <echo-component doc:name="Echo"/>
        <file:outbound-endpoint path="C:\Documents and Settings\balajik\Desktop" outputPattern="myfile.txt" doc:name="File"/>
    </flow>
</mule>

每当我发出 Http 浏览器请求时: lh:8046/manasa-sundarraman

当出现 2 个请求时,流程会执行两次。 请求是: 1) /favicon.ico 2) /manasa-桑德拉曼

我的问题是 /favicon.ico 是什么? 为什么它是作为一个请求来的? 如何避免?

【问题讨论】:

  • 网站图标是您在浏览器中看到的网站特定符号。查看 SO 页面标题左侧的图标。 AFAIK 它是控制对 favicon 的请求的浏览器...

标签: java http esb mule favicon


【解决方案1】:

我找到了清除 favicon.ico 请求的方法。 如果我们在两者之间添加过滤器,您将能够过滤 favicon.ico 请求。

<message-filter doc:name="Filter favicon">

<not-filter>

<wildcard-filter pattern="/favicon.ico" caseSensitive="true"/>

</not-filter>

</message-filter>

在回应 Http 请求后添加它可以解决问题

【讨论】:

    【解决方案2】:

    MuleSoft basic tutorial 提供了一个可以与 3.6+ 中的新 HTTP 侦听器一起使用的解决方案:

    <expression-filter expression="#[message.inboundProperties.'http.request.uri' != '/favicon.ico']" doc:name="Filter favicon"/>
    

    对于 3.5.0 及更低版本:

    <expression-filter expression="#[payload != '/favicon.ico']" doc:name="Filter favicon"/>
    

    【讨论】:

      猜你喜欢
      • 2015-02-05
      • 2010-11-22
      • 1970-01-01
      • 1970-01-01
      • 2019-01-20
      • 1970-01-01
      • 2022-12-12
      • 2016-11-25
      • 1970-01-01
      相关资源
      最近更新 更多