jira-importer opened a new issue, #815:
URL: https://github.com/apache/httpcomponents-core/issues/815

   
**[yangqing](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=yangqing1976)**
 opened 
**[HTTPCORE-274](https://issues.apache.org/jira/browse/HTTPCORE-274?redirect=false)**
 and commented
   
   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:
   
   Connection:close
   Content-type:text/html
   Date:Sat, 04 Sep 2010 08:46:38 GMT
   Server:Microsoft-IIS/6.0
   X-Powered-By:ASP.NET
   PHP/5.2.8
   
   I then and a snippet in the for loop of the parseHeaders method of the class 
AbstractMessageParser.java to ignore this type of error.
   if(current.indexOf(':')<=0){
   continue;
   }
   
   It works for me, I hope someone can fix this problem.
   
   Thanks!
   
   
   
   ---
   
   **Affects:** 4.2-alpha1
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to