pmarschik / apache-http-async-socks

Demo how to use Apache HTTP async client over a SOCKv4 proxy
2 stars 0 forks source link

Absolute path in request #1

Open ov7a opened 9 years ago

ov7a commented 9 years ago

This code perfoms requests using absolute paths instead relative ones, i.e instead of

GET /headers HTTP/1.1

it produces

GET http://httpbin.org/headers HTTP/1.1

Not all servers can handle such requests correctly. Also, this is quite throublesome when ip is used in url (instead of hostname). This is also may cause errors with https.

Reason:

org.apache.http.impl.nio.client.MainClientExec:

  // Re-write request URI if needed
  rewriteRequestURI(state);
  ....
  if (route.getProxyHost() != null && !route.isTunnelled()) {
                // Make sure the request URI is absolute

So, if route has a proxy then absolute uri is used. One can make a custom RoutePlanner to set route as tunneled, but only http proxy tunnel is supported.

pmarschik commented 9 years ago

I have this already fixed in an internal project, when I have the time I will merge the code changes to this repository. IIRC I had to additionally implment a HttpRouteDirector and wire it up with reflection to the InternalHttpAsyncClient.exec.routDirector