在Mule中移除favicon.ico请求

3

我正在使用Mule Studio,尝试其中的示例。

每当我发起HTTP浏览器请求时,会同时出现两个请求,第一个是/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-sunderraman
我的问题是什么是/favicon.ico? 为什么它会作为请求而来? 如何避免它?

网站图标是您在浏览器中看到的特定于网站的小符号。请查看SO页面标题左侧的图标。据我所知,这是浏览器控制请求网站图标的过程... - home
https://dev59.com/5HM_5IYBdhLWcg3wlEBH - home
2个回答

6

我发现了一种清除favicon.ico请求的方法。 如果我们在中间添加一个过滤器,你就能够过滤掉favicon.ico请求。

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

<not-filter>

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

</not-filter>

</message-filter>

在回显 Http 请求之后添加它可以解决此问题。

3
"MuleSoft基础教程"提供了一个可以与3.6+中的新HTTP Listener一起使用的解决方案。请参考:MuleSoft基础教程。"
<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"/>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接