-1

I've rolled my own code to retrieve data from remote URLs using a HttpURLConnection. First I had to write custom code to handle gzipped content encoding, now I am encountering web servers that are serving up RSS feeds with a chunked Transfer-Encoding. I'm finding myself reimplementing a bunch of stuff that I'm sure has already been done.

I'm sure there is some library that will automatically handle the various ways that data can be returned from a web server and just give me an InputStream, can anyone recommend one (must be LGPL or similar license)?

Ideally I'm looking for a library that is currently maintained and which has a modern well-designed API.

In some cases I won't know the Content-type that will be returned in advance, and so may need to handle what is returned differently depending on this.

1
  • 1
    My first idea would be to look at Apache HttpClient – I don't know for sure it supports all your requirements, but it might considering how long it's been around for. Commented Jun 26, 2012 at 20:14

1 Answer 1

0

I know Apache Commons HttpComponents supports Content-Encoding as of 4.1+ (see here), using ContentEncodingHttpClient. DecompressingHttpClient should also work for 4.2+ (they have slightly different behavior in conjunction with caching).

Like millimoose said, it may not have everything. But I think it will be a better starting place.

Sign up to request clarification or add additional context in comments.

2 Comments

But what if you don't know whether the content will be encoded or compressed before you attempt to retrieve it?
@sanity, I believe that's fine. DecompressingHttpClient will ask for compressed content using Accept-Encoding, but will check the Content-Encoding to determine if the response actually was compressed.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.