hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexey Panchenko <alex.panche...@gmail.com>
Subject Re: How to test compressed response
Date Tue, 24 Apr 2012 09:55:59 GMT
Just don't add spaces in the beginning of the lines.

On Tue, Apr 24, 2012 at 16:52,  <Michael.Fankanowsky@t-systems.com> wrote:
> No - doesn't work (just forgot to mention it in my post).
> I did it after my last header field "Content-Length:".
>
> Kind regards,
>
> Michael
>
> -----Ursprüngliche Nachricht-----
> Von: Sam Crawford [mailto:samcrawford@gmail.com]
> Gesendet: Dienstag, 24. April 2012 11:20
> An: HttpClient User Discussion
> Betreff: Re: How to test compressed response
>
> You need two CRLF after your final HTTP header. So try using:
>
> +" Content-Encoding: gzip\r\n\r\n";
>
> Thanks,
>
> Sam
>
>
> On 24 April 2012 10:14,  <Michael.Fankanowsky@t-systems.com> wrote:
>> My fault. After adding the necessary CRLF it works.
>> String sHeader = "HTTP/1.1 200 OK\r\n"
>>                           +" Server: Apache\r\n"
>>                           +" Content-Type: text/html\r\n"
>>                           +" Content-Encoding: gzip\r\n";
>>
>> But when I receive the response I have only one header containing all header fields
together [Server: Apache Content-Type: text/html Content-Encoding: gzip] and I can't iterate
nor pick a special header out. I guess in my example above I should have at least three headers.
Something else what I did wrong?
>>
>> Kind regards,
>>
>> Michael
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Fankanowsky, Michael
>> Gesendet: Montag, 23. April 2012 10:33
>> An: httpclient-users@hc.apache.org
>> Betreff: How to test compressed response
>>
>> Hi all,
>>
>> I just want to test the handling of compressed responses. I have some java code which
can do the compression of content and which listens to http get requests. But I actually have
no idea how to send the response respectively which streams/writers to use and how to combine
the message header and the compressed content.
>> My last try was building a byteArray:
>>
>> int contentLength = 0;
>> v
>>
>> // parameter String message comes with call of method byte[] content =
>> message.getBytes("ISO-8859-1"); byte[] compressedContent = new
>> byte[1000]; byte[] bHeader; byte[] response; int numOfBytes;
>>
>> Deflater def = new Deflater(Deflater.BEST_COMPRESSION);
>> def.setInput(content);
>> def.finish();
>> contentLength = def.deflate(compressedContent); sHeader += "
>> Content-Length: "+contentLength; bHeader =
>> sHeader.getBytes("ISO-8859-1"); numOfBytes = bHeader.length +
>> compressedContent.length; response = new byte[numOfBytes];
>> System.arraycopy(bHeader, 0, response, 0, bHeader.length);
>> System.arraycopy(compressedContent, 0, response,
>>                 bHeader.length, compressedContent.length);
>>
>> But on client side I receive a ClientProtocolException: Invalid header.
>>
>> Any hints?
>>
>> Kind regards,
>>
>> Michael
>> ---------------------------------------------------------------------
>> 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
>>
>
> ---------------------------------------------------------------------
> 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
>

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