<p>I want to be able to access custom URLs with apache httpclient. Something like this:</p>

<pre><code>HttpClient client = new HttpClient();
HttpMethod method = new GetMethod("media:///squishy.jpg");
int statusCode = client.executeMethod(method);
</code></pre>

<p>Can I somehow register a custom URL handler? Or should I just register one with Java, using</p>

<pre><code>URL.setURLStreamHandlerFactory(...)
</code></pre>

<p>Regards.</p>

I don't think there's a way to do this in commons httpclient. It doesn't make a whole lot of sense either, after all it is a HTTP client and "media:///squishy.jpg" is not HTTP, so all the code to implement the HTTP protocol probably couldn't be used anyways.
```
```
URL.setURLStreamHandlerFactory(...)
```
```
could be the way to go, but you'll probably have to do a lot of protocol coding by hand, depending on your "media"-protocol.