hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Header and Content parsing and saving as html page
Date Fri, 11 Feb 2011 09:02:04 GMT
On Fri, 2011-02-11 at 00:39 -0800, CodingForever wrote:
> Thanks olegk for the answer,Now I am looking that. But I will ask something
> I wrote the code that below. How can I get the decoded content using header
> parameters ?

String s =
    "HTTP/1.1 200 OK\r\n"
    + "Server: whatever\r\n"
    + "Date: some date\r\n"
    + "Set-Cookie: c1=stuff\r\n"
    + "Transfer-Encoding: chunked\r\n"
    + "Content-Type: text/html; charset=ISO-8859-1\r\n"
    + "\r\n"
    + "5\r\n01234\r\n5\r\n56789\r\n6\r\nabcdef\r\n0\r\n\r\n test";
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(entity, HTTP.ASCII));

---

Oleg


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