Return-Path: X-Original-To: apmail-hc-httpclient-users-archive@www.apache.org Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DA6409204 for ; Tue, 24 Apr 2012 09:56:27 +0000 (UTC) Received: (qmail 71683 invoked by uid 500); 24 Apr 2012 09:56:25 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 71628 invoked by uid 500); 24 Apr 2012 09:56:25 -0000 Mailing-List: contact httpclient-users-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-users@hc.apache.org Received: (qmail 71414 invoked by uid 99); 24 Apr 2012 09:56:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Apr 2012 09:56:24 +0000 X-ASF-Spam-Status: No, hits=0.3 required=5.0 tests=FREEMAIL_REPLY,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of alex.panchenko@gmail.com designates 209.85.214.179 as permitted sender) Received: from [209.85.214.179] (HELO mail-ob0-f179.google.com) (209.85.214.179) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Apr 2012 09:56:19 +0000 Received: by obbuo19 with SMTP id uo19so738945obb.10 for ; Tue, 24 Apr 2012 02:55:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=WD0r1VV/TjbjnlyP5TrM64xi1XN7tfjKUkMM1LmvCVE=; b=VbsGDPRHivi/sO3BkOy7fxg6aqN91r6JNupbyppc6xdUNDO6TobvETQaQo+wiZ8OZg jjzvsro2sxmqgmElymgh7v84UmVDbrfZYysFmkeEY+cyzC2bbEIIaaxXhgIFQabfvO4I 9aKhz+cgchnGKfdS1hZqcVG4IJUb1ipub7E5O8yrUrJFP6in4cmfALEU8q6x/KmbWxkW 27P1nGfiTWyngWE+RdGCDDPbBJvv4t0rLsOkvmkQhHl1cYOW3UlLcHTsXFICqyb7TowA uKBZ3DgwR3UXLouoBCNsKPR1jfqsr/T6z2ZC6qzlEm5eFiMCBL6DlgzqrOjLQcUDIvcC 2zsg== MIME-Version: 1.0 Received: by 10.60.20.38 with SMTP id k6mr27940357oee.26.1335261359142; Tue, 24 Apr 2012 02:55:59 -0700 (PDT) Received: by 10.182.37.202 with HTTP; Tue, 24 Apr 2012 02:55:59 -0700 (PDT) In-Reply-To: <3B8CC2E826F6B844B471DC3DF590CB45ED2AE7BC58@HE111490.emea1.cds.t-internal.com> References: <3B8CC2E826F6B844B471DC3DF590CB45ED2AE7B5C6@HE111490.emea1.cds.t-internal.com> <3B8CC2E826F6B844B471DC3DF590CB45ED2AE7BBF4@HE111490.emea1.cds.t-internal.com> <3B8CC2E826F6B844B471DC3DF590CB45ED2AE7BC58@HE111490.emea1.cds.t-internal.com> Date: Tue, 24 Apr 2012 16:55:59 +0700 Message-ID: Subject: Re: How to test compressed response From: Alexey Panchenko To: HttpClient User Discussion Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Just don't add spaces in the beginning of the lines. On Tue, Apr 24, 2012 at 16:52, 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=C3=BCngliche 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, =C2=A0 wrote: >> My fault. After adding the necessary CRLF it works. >> String sHeader =3D "HTTP/1.1 200 OK\r\n" >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 +" Server: Apache\r\n" >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 +" Content-Type: text/html\r\n" >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 +" Content-Encoding: gzip\r\n"; >> >> But when I receive the response I have only one header containing all he= ader fields together [Server: Apache Content-Type: text/html Content-Encodi= ng: 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 d= id wrong? >> >> Kind regards, >> >> Michael >> >> -----Urspr=C3=BCngliche 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 ja= va code which can do the compression of content and which listens to http g= et requests. But I actually have no idea how to send the response respectiv= ely 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 =3D 0; >> v >> >> // parameter String message comes with call of method byte[] content =3D >> message.getBytes("ISO-8859-1"); byte[] compressedContent =3D new >> byte[1000]; byte[] bHeader; byte[] response; int numOfBytes; >> >> Deflater def =3D new Deflater(Deflater.BEST_COMPRESSION); >> def.setInput(content); >> def.finish(); >> contentLength =3D def.deflate(compressedContent); sHeader +=3D " >> Content-Length: "+contentLength; bHeader =3D >> sHeader.getBytes("ISO-8859-1"); numOfBytes =3D bHeader.length + >> compressedContent.length; response =3D new byte[numOfBytes]; >> System.arraycopy(bHeader, 0, response, 0, bHeader.length); >> System.arraycopy(compressedContent, 0, response, >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 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