0

I would like an HttpClient instance with a path built-in. So all HttpUriRequest's provided will have their URI appended not only to the host and port, but also the path.

For example, with an HttpClient configured for http://tempuri.org/path, an HttpUriRequest for some/more will make a request for http://tempuri.org/path/some/more.

Can DefaultHttpClient be configured to do this? If not, is there another HttpClient implementation which can do it?

David V
  • 11,531
  • 5
  • 42
  • 66
  • Did you read https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/DefaultHttpClient.html ? –  Sep 12 '12 at 20:24
  • Yes, and AbstractHttpClient, but I did not see anything which obviously solved my problem. – David V Sep 12 '12 at 20:30

1 Answers1

0

You could create your own class FixedPathHttpClient which extends the standard HttpClient.

There you can override executeMethod to append your path to the path of the method before passing it to super().

Philipp
  • 67,764
  • 9
  • 118
  • 153
  • I had hoped to avoid this solution, but I think it is my only option. Thanks for the recommendation. – David V Oct 01 '12 at 20:26