Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-6185

http4 component should always filter 'host' header

    XMLWordPrintableJSON

Details

    • Novice

    Description

      Exchanges originating from a CXF consumer get an incorrect 'host' http-header when directed to a http4 producer. The problem is that the cxf consumer copies the incoming 'host' header to the message, and the http4 producer copies this to the outgoing message. The http component does not do that.

      When sending a http request the HttpProducer copies headers from the incomming message to the HTTP request. The 'host' header should not be copied since it (according to the http spec) should always contain the name of the server the request is sent to.
      This has already been addressed for bridge endpoints (CAMEL-5757), but is always an issue.

      The easiest fix seems to be to add the 'host' header to the list of out going filters in org.apache.camel.component.http4.HttpHeaderFilterStrategy.initialize() i.e.:

      getOutFilter().add("host");
      

      Once this is done the special handling (i.e. removal of) of 'host' header in case of bridgeEndpoint inside HttpProducer can be removed (since the strategy will remove it):

                  // Need to remove the Host key as it should be not used 
                  exchange.getIn().getHeaders().remove("host");
      

      Attachments

        1. CAMEL-6185-3.patch
          20 kB
          Christian Posta

        Activity

          People

            ceposta Christian Posta
            fhoeben Fried Hoeben
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: