Does anyone know if the following table is still valid for HttpUrlConnection:
http://www.innovation.ch/java/HTTPClient/urlcon_vs_httpclient.html

If so, there are a couple of advantages to using HTTPClient with Solr:
- direct streaming to/from socket (could be important for very large
requests/responses)
- can read code/headers/body regardless what the response code is
- more flexible authorization (not used in Solr now, but could be in the future)
- can set timeouts

-Yonik

On 7/28/06, Andrew May <[EMAIL PROTECTED]> wrote:
I'm using HttpClient for indexing and searching and it seems to work well. You 
can either
POST files directly (only works in 3.1 alpha, use InputStreamRequestEntity in 
3.0):

       PostMethod post = new PostMethod(solrUrl);
       post.setRequestEntity(new FileRequestEntity(file, "application/xml"));
       int response = new HttpClient().executeMethod(post);

or send a String (e.g. the result of an XSLT transformation)

       PostMethod post = new PostMethod(solrUrl);
       post.setRequestEntity(new StringRequestEntity(text, "application/xml", 
"UTF-8"));
       int response = new HttpClient().executeMethod(post);

You can also pool connections if you're writing something multi-threaded.

-Andrew

Bertrand Delacretaz wrote:
> On 7/28/06, Yonik Seeley <[EMAIL PROTECTED]> wrote:
>
>> ...Getting all the little details of connection handling correct can be
>> tough... it's probably a good idea if we work toward common client
>> libraries so everyone doesn't have to reinvent them....
>
> Jakarta's HttpClient [1] is IMHO a good base for Java clients, and
> it's easy to use, see the PostXML example in [2].
>
> -Bertrand
>
> [1] http://jakarta.apache.org/commons/httpclient/
>
> [2]
> 
http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/examples/PostXML.java?revision=410848&view=markup
>

Reply via email to