hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Gottlieb <bgottl...@gawquest.com>
Subject Re: HTTP Error 400. The request hostname is invalid.
Date Mon, 23 Mar 2015 12:59:39 GMT
It appears that the authorization line must be causing the issue:


THIS WORKS:
2015/03/23 08:48:05:580 EDT [DEBUG] headers - http-outgoing-0 >>
Authorization: Basic xxxxxBase64EncodedUserIDAndPasswordxxxxx
2015/03/23 08:48:05:580 EDT [DEBUG] headers - http-outgoing-0 >> Host:
webapi.avertest.com
2015/03/23 08:48:05:580 EDT [DEBUG] headers - http-outgoing-0 >>
Connection: Keep-Alive
2015/03/23 08:48:05:580 EDT [DEBUG] headers - http-outgoing-0 >>
User-Agent: Apache-HttpClient/4.4 (Java 1.5 minimum; Java/1.6.0_45)
2015/03/23 08:48:05:580 EDT [DEBUG] headers - http-outgoing-0 >>
Accept-Encoding: gzip,deflate
2015/03/23 08:48:07:929 EDT [DEBUG] headers - http-outgoing-0 << HTTP/1.1
200 OK

THIS FAILS (Notice the extra line after the user id password):
2015/03/23 05:11:05:491 EDT [DEBUG] headers - http-outgoing-0 >>
Authorization: Basic xxxxxBase64EncodedUserIDAndPasswordxxxxx

2015/03/23 05:11:05:491 EDT [DEBUG] headers - http-outgoing-0 >> Host:
webapi.avertest.com
2015/03/23 05:11:05:492 EDT [DEBUG] headers - http-outgoing-0 >>
Connection: Keep-Alive
2015/03/23 05:11:05:492 EDT [DEBUG] headers - http-outgoing-0 >>
User-Agent: Apache-HttpClient/4.4 (Java 1.5 minimum; Java/1.6.0)
2015/03/23 05:11:05:492 EDT [DEBUG] headers - http-outgoing-0 >>
Accept-Encoding: gzip,deflate
2015/03/23 05:11:05:549 EDT [DEBUG] headers - http-outgoing-0 << HTTP/1.1
400 Bad Request

Both do the same thing.  Why does one get the blank line after the Base64
encoded info?

import org.apache.commons.codec.binary.Base64;
...
String encoding = base64.encodeBase64String((userID + ":" +
password).getBytes());
....
HttpGet get = new HttpGet(url);
get.setHeader("Authorization", "Basic " + encodedAuth);
...


On Mon, Mar 23, 2015 at 4:52 AM, Oleg Kalnichevski <olegk@apache.org> wrote:

> On Sun, 2015-03-22 at 17:13 -0400, Bill Gottlieb wrote:
> > I use HttpClient 4.4 to connect to an IIS https REST web service.  When I
> > test from my PC everything works fine, returning data from the server
> > without issue.  I load the same code onto my IBM iSeries and receive the
> > following error "HTTP Error 400 - The request hostname is invalid.".
> Both
> > are using JDK 1.6.  The PC uses Oracle's and the iSeries uses IBM's JDK.
> >
> > The IIS folks have tried to change things on their end, to no avail.
> I've
> > tried with both of the following from my end, thinking the second would
> > work no matter what:
> >
> >       CloseableHttpClient browser = HttpClientBuilder.create().build();
> >       CloseableHttpClient browser =
> > HttpClients.custom().setSSLHostnameVerifier(new
> > NoopHostnameVerifier()).build();
> >
> > Does anybody have any ideas that could help me solve this problem?
> Thanks!
>
> Please produce and compare wire / context logs of both sessions
>
> http://hc.apache.org/httpcomponents-client-4.4.x/logging.html
>
> Oleg
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message