[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-1185?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13283298#comment-13283298
 ] 

Magnus Gustavsson commented on HTTPCLIENT-1185:
-----------------------------------------------

Thank you!

It worked perfectly fine with the SVN version. However, with the 4.2 release 
version it appears to have regressed (same code as in the original post)?


% java BadRequest          
org.apache.http.client.ClientProtocolException
        at 
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:909)
        at 
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
        at 
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
        at BadRequest.main(BadRequest.java:11)
Caused by: org.apache.http.HttpException: Unable to establish route: planned = 
{}->http://edu.mah.se; current = {}->http://www.edu.mah.se
        at 
org.apache.http.impl.client.DefaultRequestDirector.establishRoute(DefaultRequestDirector.java:842)
        at 
org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:645)
        at 
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:480)
        at 
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
        ... 3 more


Kind regards, Magnus
                
> IIS and fragments in "Location:" headers
> ----------------------------------------
>
>                 Key: HTTPCLIENT-1185
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1185
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 4.1.3
>            Reporter: Magnus Gustavsson
>             Fix For: 4.2 Final
>
>
> We're using HttpClient to check the validity of links on our site, and lately 
> users have been reporting that working links are incorrectly flagged as 
> invalid. Looking into the problem, I find that it all boils down to us using 
> code somewhat like this:
> import java.io.IOException;
> import org.apache.http.client.HttpClient;
> import org.apache.http.client.methods.HttpGet;
> import org.apache.http.impl.client.DefaultHttpClient;
> public class BadRequest {
>     public static void main(String[] args) {
>       try {
>           HttpClient httpclient = new DefaultHttpClient();
>           HttpGet httpget = new 
> HttpGet("http://www.edu.mah.se/KK3231/syllabus/";);
>           
> System.out.println(httpclient.execute(httpget).getStatusLine().getStatusCode());
>       } catch (IOException e) {
>           e.printStackTrace();
>       }
>     }
> }
> Compiling and running the above example with HttpClient 4.1.3 results in a 
> 400 code (20 April in 2012).
> Specifically in the following exchanges:
> GET /KK3231/syllabus/ HTTP/1.1
> Host: www.edu.mah.se
> Connection: Keep-Alive
> User-Agent: Apache-HttpClient/4.1.3 (java 1.5)
> HTTP/1.1 301 Moved Permanently
> Content-Type: text/html; charset=UTF-8
> Location: http://edu.mah.se/sv/Course/KK3231#Syllabus
> Server: Microsoft-IIS/7.5
> X-Powered-By: PHP/5.3.9
> X-Powered-By: ASP.NET
> Date: Fri, 20 Apr 2012 12:33:40 GMT
> Content-Length: 315
> GET /sv/Course/KK3231#Syllabus HTTP/1.1
> Host: edu.mah.se
> Connection: Keep-Alive
> User-Agent: Apache-HttpClient/4.1.3 (java 1.5)
> HTTP/1.1 400 Bad Request
> Content-Type: text/html; charset=us-ascii
> Server: Microsoft-HTTPAPI/2.0
> Date: Fri, 20 Apr 2012 12:33:40 GMT
> Connection: close
> Content-Length: 324
> I do realize that according to the HTTP 1.1 standard, the location header 
> returned by the server is invalid.
> However, all browsers seem to be able to handle a redirection like this. Thus 
> I can hardly tell users that the error is on the server side when they can 
> paste it into any browser and get a working page. So I was wondering if you 
> would consider adapting to the current state of things and perhaps strip 
> fragments from redirect URIs?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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

Reply via email to