简体   繁体   中英

Omit port with Mule ESB http:request endpoint

I'm trying to use the Mule ESB http:request endpoint to get data from api.crossref.org . I've found that I get a 404 if the port number is included. That is, this request succeeds:

GET http://api.crossref.org/works?filter=doi%3A10.1080%2F10573560601158461&sort=score&order=desc HTTP/1.1
Host: api.crossref.org
<blank line>
<blank line>

but this one fails:

GET http://api.crossref.org:80/works?filter=doi%3A10.1080%2F10573560601158461&sort=score&order=desc HTTP/1.1
Host: api.crossref.org:80
<blank line>
<blank line>

Is there a way to get to force Mule to omit the port number from the headers? This also happens with HTTPS and 443.

You could try adding the Host header manually, meaning in a request builder:

Mule 3

<http:request config-ref="HTTP_Request_Configuration" path="test" method="GET">
    <http:request-builder>
        <http:header headerName="Host" value="api.crossref.org" />
    </http:request-builder>
</http:request>

Mule 4

  <http:request config-ref="HTTP_Request_Configuration" path="test" method="GET">
    <http:headers>
      #[{"Host" : "api.crossref.org"}]
    </http:headers>
  </http:request>

Servers should handle the Host header with the port but unfortunately some do not. See the HTTP Troubleshooting Guide for more details. HTH

只需使用您的 URL 尝试使用 http 的端口 80 和 https 的端口 443,这是默认端口,它应该可以工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM