Hi, Johannes, Httpclient is following the redirect (the "location" header), and the server is not writing anything back on this subsequent request. Looks like "/home.jsp" doesn't bother responding to HEAD requests! It seems fine with GET requests though. I just tried with telnet.
You should either tell HttpClient to not follow redirects, or use GET. Also, you should be setting the socket timeout and the connection timeout: Httpclient client = new HttpClient(); client.setTimeout( 30000 ); // 30 seconds client.setConnectionTimeout( 30000 ); // 30 seconds Part of me wishes HttpClient set these timeouts for us by default, and let us set them to -1 (infinite) if we really wanted to. yours, Julius Davies On Wed, 2005-02-03 at 17:20 +0100, Johannes Koch wrote: > Hi there, > > I tried to make a HEAD request to <http://www.niedersachsen.de/>. > > Code is like this: > > String uri = "http://www.niedersachsen.de/"; > HttpClient httpClient = new HttpClient(); > HttpMethod httpMethod = new HeadMethod(uri); > try > { > int responseCode = httpClient.executeMethod(httpMethod); > System.out.println(responseCode); > } > catch (Exception e) > { > e.printStackTrace(); > } > finally > { > httpMethod.releaseConnection(); > } > > I used HttpClient 2.0.2 or 3.0-rc1. Both hang at > > while ((ch = inputStream.read()) >= 0) { > > in HttpParser.readRawLine(InputStream inputStream) > > If I make a HEAD request via telnet, I get the following response: > > HTTP/1.1 302 Found > Date: Wed, 02 Mar 2005 15:53:03 GMT > Server: Apache > Location: http://www.niedersachsen.de/home.jsp > Content-Type: text/html; charset=iso-8859-1 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
