hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: Request decoding
Date Wed, 16 Feb 2011 10:27:42 GMT
On 16 February 2011 09:44, CodingForever <nighttmmare@gmail.com> wrote:
>
> Hi, there
>
> I handled http responses using;
> ------------------------------------------------------------------------
> SessionInputBuffer inbuffer = new SessionInputBufferMockup(s,
> "US-ASCII");
> HttpResponseParser parser = new HttpResponseParser(
>    inbuffer,
>    BasicLineParser.DEFAULT,
>    new DefaultHttpResponseFactory(),
>    new BasicHttpParams());
> HttpResponse response = (HttpResponse) parser.parse();
> EntityDeserializer deserializer = new EntityDeserializer(new
> LaxContentLengthStrategy());
> HttpEntity entity = deserializer.deserialize(inbuffer, response);
> System.out.println(EntityUtils.toString(response.getEntity(), HTTP.ASCII));
>
> ----------------------------------------------------------
>
>
> I want to do same thing for user requests(get,post)
> and I wrote this(below code) but the request.setEntity(Entity vs.) method
> does not exist.

Because not all requests support content. You cannot add an entity to
a GET method.

> How can I do that ?

Check and cast to BasicHttpEntityEnclosingRequest

>
> ---------------------------------------------------------------
> SessionInputBuffer inbuffer = new SessionInputBufferMockup(bytes);
> HttpRequestParser parser = new HttpRequestParser(inbuffer,
> BasicLineParser.DEFAULT, new DefaultHttpRequestFactory(), new
> BasicHttpParams());
> HttpRequest request = (HttpRequest) parser.parse();
> EntityDeserializer deserializer = new EntityDeserializer(new
> LaxContentLengthStrategy());
> HttpEntity entity = deserializer.deserialize(inbuffer, request);
> request.setEntity(entity);           // ERROR
> BasicHttpContext context = new BasicHttpContext();
> RequestContent  processor = new RequestContent();
> processor.process(request, context);
> entity = request.getEntity();       // ERROR
> System.out.println(EntityUtils.toString(entity));
> --------------------------------------------------------------------------
> --
> View this message in context: http://old.nabble.com/Request-decoding-tp30936612p30936612.html
> Sent from the HttpClient-User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

---------------------------------------------------------------------
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