hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <thorsten.scherler....@juntadeandalucia.es>
Subject Re: PostMethod now known as HttpPost
Date Fri, 14 Mar 2008 07:57:34 GMT
On Thu, 2008-03-13 at 20:58 +0100, Oleg Kalnichevski wrote:
> On Thu, 2008-03-13 at 13:10 +0100, Thorsten Scherler wrote:
> > Hi all,
> > 
> > I am ATM trying to integrate latest httpclient into Droids. I have some
> > "old" code that is based on a prior version of the client.
> > 
> > Some method/class name changes I found myself but some I am not sure how
> > to implement them.
> > 
> > When my old code was:
> > PostMethod filePost = new PostMethod(solrBase);
> > filePost.addRequestHeader("Content-type", "text/xml; charset=utf-8");
> > filePost.addRequestHeader("User-Agent", AGENT);
> > filePost.setRequestBody(new URL(srcUrl).openStream());
> > 
> > Now I do:
> > HttpPost filePost = null;
> > filePost = new HttpPost(solrBase);
> > filePost.addHeader("Content-type", "text/xml; charset=utf-8");
> > filePost.addHeader("User-Agent", AGENT);
> > InputStreamEntity reqEntity = new InputStreamEntity(src, -1);
> > filePost.setEntity(reqEntity);
> > 
> > But for the following I could not found the corresponding method:
> > public String getResponseCharSet() {
> >   return filePost.getResponseCharSet();
> > }
> > 
> > public String getResponseBodyAsString() {
> >   return filePost.getResponseBodyAsString();
> > }
> > 
> > Can you point me to the new methods?
> > 
> 
> Hi Thorsten, 

Hi Oleg,

> 
> These methods are now provided by the EntityUtils class
> 
> http://hc.apache.org/httpcomponents-core/httpcore/apidocs/org/apache/http/util/EntityUtils.html

thanks very much.

Big dooh! I was looking for the class in
http://hc.apache.org/httpcomponents-client/httpclient/apidocs/index.html.

> 
> Generally I would recommend avoiding consuming response entities as
> strings in the real life application unless you are absolutely sure they
> are of reasonable / limited length.

Yeah, I think I will drop the getResponseBodyAsString for now out of the
very good reason you give above.

Thanks for your response Oleg.

salu2
-- 
Thorsten Scherler                                 thorsten.at.apache.org
Open Source Java                      consulting, training and solutions


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message