To put this whole issue to an end this code produces no response and
times out, which in my opinion clearly indicates a server side issue:
Socket socket = SocketFactory.getDefault().
createSocket("www.niedersachsen.de", 80);
socket.setSoTimeout(5000);
try {
Writer out = new OutputStreamWriter(
socket.getOutputStream(), "ISO-8859-1");
out.write("HEAD / HTTP/1.1\r\n");
out.write("Host: www.niedersachsen.de:\r\n");
out.write("Agent: TEST\r\n");
out.write("\r\n");
out.flush();
BufferedReader in = new BufferedReader(
new InputStreamReader(socket.getInputStream(), "ISO-8859-1"));
String line = null;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
} finally {
socket.close();
}
The same code works just fine if HEAD is replaced with GET.
Oleg
On Wed, 2005-03-02 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]