HttpClient with Feed Protocol

Took me a while to figure this out. If you’re using Apache’s HttpClient and need to change its default protocol from “http” to “feed”, this is how you do it in the code snippet below.

HttpClient client = new HttpClient();
URI uri = 
    new URI("feed://");
Protocol feedProtocol =
    new Protocol("feed", new DefaultProtocolSocketFactory(), 80); 
Protocol.registerProtocol("feed", feedProtocol);
    .setHost(uri.getHost(), 80, feedProtocol);

You can find Apache’s documentation and examples on this can be found here.

This entry was posted in code example, general, java. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s