You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Oleg Kalnichevski (JIRA)" <ji...@apache.org> on 2014/03/14 15:21:42 UTC

[jira] [Resolved] (HTTPASYNC-72) Connecting to certain URLs causes a malformedInputException

     [ https://issues.apache.org/jira/browse/HTTPASYNC-72?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski resolved HTTPASYNC-72.
----------------------------------------

    Resolution: Invalid

The sever clearly sends garbage in the redirect location header. HttpClient is correct in rejecting it. However you can use a custom redirect strategy and attempt to rewrite the url into something valid.

Oleg 

{noformat}
[DEBUG] MainClientExec - [exchange: 1] start execution
[DEBUG] RequestAddCookies - CookieSpec selected: best-match
[DEBUG] RequestAuthCache - Auth cache not set in the context
[DEBUG] InternalHttpAsyncClient - [exchange: 1] Request connection for {}->http://fb.me:80
[DEBUG] PoolingNHttpClientConnectionManager - Connection request: [route: {}->http://fb.me:80][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
[DEBUG] PoolingNHttpClientConnectionManager - Connection leased: [id: http-outgoing-0][route: {}->http://fb.me:80][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
[DEBUG] InternalHttpAsyncClient - [exchange: 1] Connection allocated: http-outgoing-0 [ACTIVE]
[DEBUG] ManagedNHttpClientConnectionImpl - http-outgoing-0 192.168.42.191:39321<->173.252.110.27:80[ACTIVE][r:]: Set attribute http.nio.exchange-handler
[DEBUG] ManagedNHttpClientConnectionImpl - http-outgoing-0 192.168.42.191:39321<->173.252.110.27:80[ACTIVE][rw:]: Event set [w]
[DEBUG] HttpAsyncRequestExecutor - http-outgoing-0 [ACTIVE]: Connected
[DEBUG] ManagedNHttpClientConnectionImpl - http-outgoing-0 192.168.42.191:39321<->173.252.110.27:80[ACTIVE][rw:]: Set attribute http.nio.http-exchange-state
[DEBUG] HttpAsyncRequestExecutor - http-outgoing-0 [ACTIVE] Request ready
[DEBUG] MainClientExec - Start connection routing
[DEBUG] MainClientExec - Connection route established
[DEBUG] MainClientExec - [exchange: 1] Attempt 1 to execute request
[DEBUG] MainClientExec - Target auth state: UNCHALLENGED
[DEBUG] MainClientExec - Proxy auth state: UNCHALLENGED
[DEBUG] headers - http-outgoing-0 >> GET /2KmsOxszz HTTP/1.1
[DEBUG] headers - http-outgoing-0 >> Host: fb.me
[DEBUG] headers - http-outgoing-0 >> Connection: Keep-Alive
[DEBUG] headers - http-outgoing-0 >> User-Agent: Apache-HttpAsyncClient/4.0.1 (java 1.5)
[DEBUG] ManagedNHttpClientConnectionImpl - http-outgoing-0 192.168.42.191:39321<->173.252.110.27:80[ACTIVE][rw:]: Event set [w]
[DEBUG] MainClientExec - [exchange: 1] Request completed
[DEBUG] HttpAsyncRequestExecutor - http-outgoing-0 [ACTIVE] Request ready
[DEBUG] ManagedNHttpClientConnectionImpl - http-outgoing-0 192.168.42.191:39321<->173.252.110.27:80[ACTIVE][rw:w]: 117 bytes written
[DEBUG] ManagedNHttpClientConnectionImpl - http-outgoing-0 192.168.42.191:39321<->173.252.110.27:80[ACTIVE][r:w]: Event cleared [w]
[DEBUG] ManagedNHttpClientConnectionImpl - http-outgoing-0 192.168.42.191:39321<->173.252.110.27:80[ACTIVE][r:r]: 417 bytes read
[DEBUG] headers - http-outgoing-0 << HTTP/1.1 301 Moved Permanently
[DEBUG] headers - http-outgoing-0 << Content-Type: text/html; charset=utf-8
[DEBUG] headers - http-outgoing-0 << Content-Length: 0
[DEBUG] headers - http-outgoing-0 << Connection: keep-alive
[DEBUG] headers - http-outgoing-0 << Date: Fri, 14 Mar 2014 14:15:34 GMT
[DEBUG] headers - http-outgoing-0 << Location: http://chargeyourlife.lnwshop.com/product/375/ซองกันน้ำรุ่นใหญ่-สีส้ม-สำหรับ-samsung-galaxy-note-iphone-nexus-omnia-nokia-lumia-ฯลฯ
[DEBUG] headers - http-outgoing-0 << X-FB-Debug: xUf34BalBzj1D8YwsctUwsBL/XxaJBMhy97DfHot/IE=
[DEBUG] HttpAsyncRequestExecutor - http-outgoing-0 [ACTIVE] Response received
[DEBUG] MainClientExec - [exchange: 1] Response received HTTP/1.1 301 Moved Permanently
[DEBUG] DefaultRedirectStrategy - Redirect requested to location 'http://chargeyourlife.lnwshop.com/product/375/ซองกันน้ำรุ่นใหญ่-สีส้ม-สำหรับ-samsung-galaxy-note-iphone-nexus-omnia-nokia-lumia-ฯลฯ'
[DEBUG] ManagedNHttpClientConnectionImpl - http-outgoing-0 192.168.42.191:39321<->173.252.110.27:80[ACTIVE][r:r]: Shutdown
[DEBUG] ManagedNHttpClientConnectionImpl - http-outgoing-0 0.0.0.0:39321<->173.252.110.27:80[CLOSED][]: Shutdown
[DEBUG] PoolingNHttpClientConnectionManager - Connection manager is shutting down
[DEBUG] InternalHttpAsyncClient - [exchange: 1] connection aborted
[DEBUG] HttpAsyncRequestExecutor - http-outgoing-0 [CLOSED]: Disconnected
[DEBUG] PoolingNHttpClientConnectionManager - Connection manager shut down
[DEBUG] PoolingNHttpClientConnectionManager - Releasing connection: [id: http-outgoing-0][route: {}->http://fb.me:80][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
Exception in thread "main" [DEBUG] PoolingNHttpClientConnectionManager - Connection released: [id: http-outgoing-0][route: {}->http://fb.me:80][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
java.util.concurrent.ExecutionException: org.apache.http.ProtocolException: Invalid redirect URI: http://chargeyourlife.lnwshop.com/product/375/ซองกันน้ำรุ่นใหญ่-สีส้ม-สำหรับ-samsung-galaxy-note-iphone-nexus-omnia-nokia-lumia-ฯลฯ
	at org.apache.http.concurrent.BasicFuture.getResult(BasicFuture.java:68)
	at org.apache.http.concurrent.BasicFuture.get(BasicFuture.java:77)
	at Testing.main(Testing.java:18)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: org.apache.http.ProtocolException: Invalid redirect URI: http://chargeyourlife.lnwshop.com/product/375/ซองกันน้ำรุ่นใหญ่-สีส้ม-สำหรับ-samsung-galaxy-note-iphone-nexus-omnia-nokia-lumia-ฯลฯ
	at org.apache.http.impl.client.DefaultRedirectStrategy.createLocationURI(DefaultRedirectStrategy.java:197)
	at org.apache.http.impl.client.DefaultRedirectStrategy.getLocationURI(DefaultRedirectStrategy.java:145)
	at org.apache.http.impl.client.DefaultRedirectStrategy.getRedirect(DefaultRedirectStrategy.java:217)
	at org.apache.http.impl.nio.client.MainClientExec.handleResponse(MainClientExec.java:615)
	at org.apache.http.impl.nio.client.MainClientExec.responseReceived(MainClientExec.java:326)
	at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.responseReceived(DefaultClientExchangeHandlerImpl.java:148)
	at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.responseReceived(HttpAsyncRequestExecutor.java:224)
	at org.apache.http.impl.nio.client.LoggingAsyncRequestExecutor.responseReceived(LoggingAsyncRequestExecutor.java:112)
	at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:254)
	at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:73)
	at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:37)
	at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:113)
	at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:159)
	at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:338)
	at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:316)
	at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:277)
	at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:105)
	at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:584)
	at java.lang.Thread.run(Thread.java:722)
Caused by: java.net.URISyntaxException: Illegal character in path at index 48: http://chargeyourlife.lnwshop.com/product/375/ซองกันน้ำรุ่นใหญ่-สีส้ม-สำหรับ-samsung-galaxy-note-iphone-nexus-omnia-nokia-lumia-ฯลฯ
	at java.net.URI$Parser.fail(URI.java:2829)
	at java.net.URI$Parser.checkChars(URI.java:3002)
	at java.net.URI$Parser.parseHierarchical(URI.java:3086)
	at java.net.URI$Parser.parse(URI.java:3034)
	at java.net.URI.<init>(URI.java:595)
	at org.apache.http.impl.client.DefaultRedirectStrategy.createLocationURI(DefaultRedirectStrategy.java:186)
	... 18 more
{noformat}

>  Connecting to certain URLs causes a malformedInputException
> ------------------------------------------------------------
>
>                 Key: HTTPASYNC-72
>                 URL: https://issues.apache.org/jira/browse/HTTPASYNC-72
>             Project: HttpComponents HttpAsyncClient
>          Issue Type: Bug
>    Affects Versions: 4.0-beta4
>         Environment: Ubuntu 13.10
>            Reporter: Rainer Hind
>            Priority: Minor
>         Attachments: Bug.java
>
>
> When attempting to get the future object after executing a request, a malformedInputException is thrown. I believe this is due to non-ascii characters in the location header (since the page in the example code is a Thai website, with Thai characters in the URL). 
> When connecting to the problem site, there is no issue. However, when connecting to a site which redirects to the problem site, the exception is thrown.
> See the attached code for an example.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

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