hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thom Nichols <tmnich...@gmail.com>
Subject Re: Fluent HttpClient
Date Tue, 07 Jun 2011 16:22:41 GMT
Looks great, I'm really excited about this project. (I think I mentioned
before, I wrote an equivalent for Groovy:
http://groovy.codehaus.org/modules/http-builder/ )

Here's some more quick feedback:


Have a convenience method to get just the content-type value (without any
encoding part) or just the encoding without the content-type.  Note that the
content-encoding header is NOT the character set.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5  To get the
character set, you have to do this:
(see the next function down to get just the content-type without any
encoding parameter.)


One possibility would be to have a builder with a base URI, e.g.
 FluentRequest req = RequestBuilder.build("http://hc.apache.org",

but then allow the executed request to be against different paths, which
makes for easy REST interface implementation.  e.g.

FluentResponse resp1 = req.exec( '/httpcomponents-core-ga' )
FluentResponse resp2 = req.exec( '/httpcomponents-client-ga' )
I suppose the best way to implement this might be to implement clone() on
FluentRequest so you could essentially take a base configured request object
and copy it to add your specific changes.  Then you could call all the
setPath, addQueryParameter functions without needing an exec() method that
only can take pre-defined arguments.

So something like this:
 FluentRequest req = RequestBuilder.build("http://twitter.com/statuses/",

resp1 = req.clone().setPath("user_timeline.xml").exec();
resp2 = req.clone().setPath("update.xml").set(POST_METHOD).set( new
StringEntity("status=updated%20status") ).exec()

A shortcut to create a url-encoded post body from a HashMap with the correct
content-type set automatically would be super-handy :)

XML parsing:

(wishlist/ possibility) - ability to pass an XmlStreamReader instance
instead of getting the response as DOM?  Or pass an XPath string to get a
DOM element?

Also, note that if you're going to allow built-in XML parsing, you really
should have a catalog so that the HTTP DTD doesn't get requested every time
-- this is a recipe for disaster because eventually the w3c server will
start rejecting HTTP requests to the DTD URI, and the XML parsing will
fail.  See:

Here's an example of how to use an XML catalog:

Another wishlist item - built-in support for common content-encodings.
(Someone else may have mentioned it.)  Here's my implementation:

Thanks!  Although I wrote a client for Groovy, there are plenty of times
when I have to use Java (think Android) and this would be super-handy to
have.  Good work so far!


On Wed, Jun 1, 2011 at 11:40 AM, Xu, Lilu <cookieme@gmail.com> wrote:

> Hi,
> I almost finished the request execution module and most classes have been
> re-designed. Please have a look at the wiki pages [1] of this project and
> drop me some comments.
> The wiki pages contain some simple examples to illustrate how to use the
> facade API of httpclient.
> [1] http://code.google.com/p/fluent-hc/w/list
> --
> Best regards,
> Lilu

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message