You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Thorsten Scherler <th...@juntadeandalucia.es> on 2008/03/13 13:10:53 UTC

PostMethod now known as HttpPost

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?

TIA

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


Re: PostMethod now known as HttpPost

Posted by Thorsten Scherler <th...@juntadeandalucia.es>.
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


Re: PostMethod now known as HttpPost

Posted by Oleg Kalnichevski <ol...@apache.org>.
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, 

These methods are now provided by the EntityUtils class

http://hc.apache.org/httpcomponents-core/httpcore/apidocs/org/apache/http/util/EntityUtils.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.

Oleg

> TIA
> 
> salu2


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