Hi Allen,
seems like the client did not set the `Host` HTTP header, not sure why
would that be as I think most HTTP clients set it by default,

zoran

[1] https://issues.apache.org/jira/browse/CAMEL-5757

On Fri, Oct 20, 2017 at 6:30 PM, Bagwell, Allen F <[email protected]> wrote:
> I am trying to write a test that needs to contact a RESTful service and get 
> back a reply in JSON. I wanted a lightweight HTTP client, so I opted to use 
> the
>
>
> Here is what my prep processor does:
>
> exchange.getIn().setHeader(Exchange.ACCEPT_CONTENT_TYPE, "application/json");
> exchange.getIn().setHeader(Exchange.CONTENT_TYPE, "text/plain");
> exchange.getIn().setHeader(Exchange.HTTP_METHOD, POST);
> exchange.getIn().setBody("This is my test");
>
>
> Here is the route...
>
> <route id="test-contact">
>          <from uri="seda:input"/>
>          <process ref="prepProcessor"/>
>          <to uri="http4://localhost:7000/cxf/rest/contact"/>
>          <unmarshal ref="jsonResponse"/>
>          <log message="${body}" loggingLevel="INFO"/>
>          <to uri="mock:end"/>
> </route>
>
>
> Here's the  part of the log when the test starts to show I have a server set 
> up for the HTTP4 client to contact (it maps the "/contact" part of the URI in 
> a service bean):
>
> INFO: Setting the server's publish address to be 
> http://localhost:7000/cxf/rest
> INFO  20-Oct-2017 08:54:03.382, [main], Server - jetty-9.2.21.v20170120
> WARN  20-Oct-2017 08:54:03.410, [main], AbstractHandler - No Server set for 
> org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine$1@2ca6546f
> INFO  20-Oct-2017 08:54:03.415, [main], ServerConnector - Started 
> ServerConnector@73877e19{HTTP/1.1}{localhost:7000}
> INFO  20-Oct-2017 08:54:03.415, [main], Server - Started @10647ms
>
> Here is the log output from the moment the prepProcessor bean is invoked in 
> the test:
>
> DEBUG 20-Oct-2017 08:54:04.732, [Camel (test-context) thread #2 - 
> seda://input], PrepProcessor - {breadcrumbId=ID-arda-32947-1508514836918-0-6, 
> CamelAcceptContentType=application/json, CamelHttpMethod=POST, 
> Content-Type=text/plain}
> WARN  20-Oct-2017 08:54:04.980, [qtp632841653-70], HttpParser - badMessage: 
> 400 No Host for 
> HttpChannelOverHttp@47cfe850{r=0,c=false,a=IDLE,uri=/cxf/rest/contact}
>
> Can anyone spot what I'm doing wrong here? I followed the instructions off 
> the Camel-HTTP4 web page. It seemed pretty straight-forward, so I'm not 
> understanding why it can't find a host.
>
> Thanks!
> -Allen
>



-- 
Zoran Regvart

Reply via email to