Return-Path: X-Original-To: apmail-hc-dev-archive@www.apache.org Delivered-To: apmail-hc-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 63C0B61AD for ; Tue, 14 Jun 2011 11:34:42 +0000 (UTC) Received: (qmail 52300 invoked by uid 500); 14 Jun 2011 11:34:42 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 52247 invoked by uid 500); 14 Jun 2011 11:34:41 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 52239 invoked by uid 99); 14 Jun 2011 11:34:41 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Jun 2011 11:34:41 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of cookieme@gmail.com designates 209.85.210.179 as permitted sender) Received: from [209.85.210.179] (HELO mail-iy0-f179.google.com) (209.85.210.179) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Jun 2011 11:34:34 +0000 Received: by iym7 with SMTP id 7so5592434iym.10 for ; Tue, 14 Jun 2011 04:34:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=+8tIbVeRFTc0aRZ5r975bNjbkz8z4FpfYUtCpKcOd9o=; b=Ms2YICc50L/WkGXQVQ9TSFsRBTOkrBmm7zCJReKBf+t/s4EPT4Ug3C/sr1qM0atY/O rjkx1ybk61fu8526mvoOHqgDGtZxTt//Zs+1Y2Z5fnE8WqCyDwgfcDQdU8GvafBuATFZ 6x4vm2znm5YQgfvmPnOtsR8IRqX65Lc2uQzUY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=RM4wnE83EtpBUN0JQ/qfreR661zOi/10Bdw3cpaBrlQVX05CmRPByFjtntQWA/LimL lx0Qn14k63TX/7Q7X1H1AOYBmuCRPzotqUGMsU49MtNJy1soogMqWBDoXdzNk0mEsCVJ JWAP3XiATN9i7YCJgpHp+wckALC4QEChGK284= MIME-Version: 1.0 Received: by 10.43.61.65 with SMTP id wv1mr7008534icb.336.1308051252264; Tue, 14 Jun 2011 04:34:12 -0700 (PDT) Received: by 10.42.177.133 with HTTP; Tue, 14 Jun 2011 04:34:12 -0700 (PDT) In-Reply-To: References: Date: Tue, 14 Jun 2011 14:34:12 +0300 Message-ID: Subject: Re: Fluent HttpClient From: "Xu, Lilu" To: HttpComponents Project Content-Type: multipart/alternative; boundary=bcaec51b1c2b3d3e9404a5aa6afa X-Virus-Checked: Checked by ClamAV on apache.org --bcaec51b1c2b3d3e9404a5aa6afa Content-Type: text/plain; charset=ISO-8859-1 Hi Thom, thank you very much! Your suggestions really help me a lot. Currently, I added a pair of methods named encodingOn() and encodingOff() to support the URI escaping. Example codes are in the Encoding Swicher part of WikiPage of UriBuilder [1]. [1] http://code.google.com/p/fluent-hc/wiki/UriBuilder On Tue, Jun 7, 2011 at 7:22 PM, Thom Nichols wrote: > 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: > > FluentResponse: > > 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: > > https://fisheye.codehaus.org/browse/gmod/httpbuilder/tags/0.5.1/src/main/java/groovyx/net/http/ParserRegistry.java?hb=true#to128 > (see the next function down to get just the content-type without any > encoding parameter.) > > I have already updated the HttpResponse part [2], and now the content-type value and charset can be accessed directly. [2] http://code.google.com/p/fluent-hc/wiki/FluentResponse > FluentRequest: > > One possibility would be to have a builder with a base URI, e.g. > FluentRequest req = RequestBuilder.build("http://hc.apache.org", > GET_METHOD); > > 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/", > GET_METHOD); > > resp1 = req.clone().setPath("user_timeline.xml").exec(); > resp2 = req.clone().setPath("update.xml").set(POST_METHOD).set( new > StringEntity("status=updated%20status") ).exec() > I use another way to implement this job. The main idea is using UriBuilder's setPath(String) method. You may find the example code on the bottom of the WikiPage of UriBuilder [1]. [1] http://code.google.com/p/fluent-hc/wiki/UriBuilder > > A shortcut to create a url-encoded post body from a HashMap with the > correct > content-type set automatically would be super-handy :) > > Now we have the setQuery(HashMap) method to set the query part of an URI. But if we do the similar things to create a POST body, how to detect the content-type if the value set of the HashMap consisted of multiple types instances? For example: entity:HashMap { "key1" : value1, "key2" : value2 } where value1 is an Integer or String, and value2 is a binary stream (e.g. byte[])? > 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: > http://www.w3.org/blog/systeam/2008/02/08/w3c_s_excessive_dtd_traffic/ > > I am not quite familiar with the XML parsing. Why does the built-in XML parsing need to request to W3C server every time? Does it mean that we would not able to parse XML without an Internet connection? > Here's an example of how to use an XML catalog: > > https://fisheye.codehaus.org/browse/gmod/httpbuilder/tags/0.5.1/src/main/java/groovyx/net/http/ParserRegistry.java?hb=true#to103 > > https://fisheye.codehaus.org/browse/gmod/httpbuilder/tags/0.5.1/src/main/resources/catalog > > Another wishlist item - built-in support for common content-encodings. > (Someone else may have mentioned it.) Here's my implementation: > > https://fisheye.codehaus.org/browse/gmod/httpbuilder/tags/0.5.1/src/main/java/groovyx/net/http/ContentEncoding.java?hb=true > > https://fisheye.codehaus.org/browse/gmod/httpbuilder/tags/0.5.1/src/main/java/groovyx/net/http/GZIPEncoding.java?hb=true > > https://fisheye.codehaus.org/browse/gmod/httpbuilder/tags/0.5.1/src/main/java/groovyx/net/http/DeflateEncoding.java?hb=true > > 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! > > -Thom > > > On Wed, Jun 1, 2011 at 11:40 AM, Xu, Lilu 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 > > > -- Best regards, Lilu --bcaec51b1c2b3d3e9404a5aa6afa--