Http client API
Chris Hegarty
chris.hegarty at oracle.com
Wed Aug 8 02:52:18 PDT 2012
On 08/08/2012 07:25, Sean Chou wrote:
>
> Is it possible to have methods like
>
> public abstract HTMLDocument getResponse(String request) in class
> HttpClient ?
Hi Sean,
I think what you are suggesting is content specific convenience methods,
something akin to URLConnection.getContent(), right? In my experience,
this type of interface can be a little problematic and not all that
widely used.
I'm personally not in favor of such convenience methods. I can see their
potential value, but this would appear to be a low level API and I don't
think it should favor one specific content type over another.
From my reading of the API it exposes various methods to access the
response body. It is quite easy to wrap one of these in a content
specific parser. For example, for xml you could do
XMLInputFactory xif = ...;
xif.createStreamReader(client.getResponse(request).getBodyAsInputStream());
OR
SAXParserFactory spf = ...;
spf.newSAXParser().parse(client.getResponse(request).getBodyAsInputStream(),
handler);
I think this gives the best flexibility without favoring one content
type parser, or one programming model, over another.
Does this make sense? Have I missed the point of your proposal? Maybe
others have a different view...
-Chris.
>
>
>
> On Wed, Aug 8, 2012 at 7:09 AM, Michael McMahon
> <michael.x.mcmahon at oracle.com <mailto:michael.x.mcmahon at oracle.com>> wrote:
>
> Hi,
>
> A new revision of the Http client API planned for jdk 8 can be viewed
> at the following link
>
> http://cr.openjdk.java.net/~__michaelm/httpclient/v0.3/
> <http://cr.openjdk.java.net/~michaelm/httpclient/v0.3/>
>
> We would like to review the api on this mailing list.
> So, all comments are welcome.
>
> Thanks
> Michael McMahon.
>
>
>
>
> --
> Best Regards,
> Sean Chou
>
More information about the net-dev
mailing list