hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "yangqing (JIRA)" <j...@apache.org>
Subject [jira] [Created] (HTTPCORE-274) Invalid Header
Date Sun, 04 Sep 2011 09:14:09 GMT
Invalid Header

                 Key: HTTPCORE-274
                 URL: https://issues.apache.org/jira/browse/HTTPCORE-274
             Project: HttpComponents HttpCore
          Issue Type: Bug
          Components: HttpCore
    Affects Versions: 4.2-alpha1
         Environment: windows7, ie9, chrome13, jdk7
            Reporter: yangqing
            Priority: Minor

When I tried to get a page using HttpClient, I got the exception below, the url is "http://ss.97down.info/mimi/file.php/L87S8KD.html".

Caused by: org.apache.http.ProtocolException: Invalid header: <meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />
	at org.apache.http.impl.io.AbstractMessageParser.parseHeaders(AbstractMessageParser.java:226)
	at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:261)
	at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:284)
	at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:247)
	at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:219)
	at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:300)
	at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:127)
	at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:645)
	at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:464)
	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)

The page can be displayed normally in IE and Chrome. I traced the source code of HttpCore,
and find this line in BufferedHeader.java, 
 int colon = buffer.indexOf(':');
I found that except other normal headers, there was really an odd header, the value is :
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
The format is ugly, there is no colon in it, and caused an exception.

The orginal header the Chrome gets is like:

HTTP/1.1 200 OK
Connection: close
Date: Sat, 04 Sep 2010 08:46:38 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-Powered-By: PHP/5.2.8
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Content-type: text/html

Yes, it's malformated, but Chrome parsed it as:

Date:Sat, 04 Sep 2010 08:46:38 GMT

I then and a snippet in the for loop of the parseHeaders method of the class AbstractMessageParser.java
to ignore this type of error.

It works for me, I hope someone can fix this problem.


This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira


To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org

View raw message