gzip and binarysend
am 25.04.2007 19:25:53 von noone
hi. i have recently enabled gzip compression on my server and it works
fine. but i have noticed something wierd.
To protect my self from hotlinking i use a simple code to send my
download with binarysend method. here is the code for an image
download.
Set objStream = Server.CreateObject("ADODB.Stream")
Response.ContentType="image/jpeg"
'response.addheader "content-transfer-encoding", "binary"
response.addheader "Content-Disposition", "attachment;filename="&
filename & ";"
'Response.AddHeader "Content-Length", objStream.Size
objStream.Open
objStream.Type = 1
objStream.LoadFromFile strFilePath
Response.BinaryWrite objStream.Read
objStream.Close
Set objStream = Nothing
when i use this code without gzip compression (although size section
commented) it would send
Content-Length and filename correctly.
after enabling gzip this code stopped to send Content-Length and
filename.
any idea why it does that? is it my coding?
thanks
Re: gzip and binarysend
am 25.04.2007 19:29:20 von noone
after further test i couldn get
Response.AddHeader "Content-Length", objStream.Size
working. iis or asp refuses to send it but sends following
HTTP/1.1 200 OK
Cache-Control: private
Date: Wed, 25 Apr 2007 16:39:24 GMT
Content-Type: image/jpeg
Content-Disposition: attachment;filename=a.jpg;
Set-Cookie: ASPSESSIONIDQADTRBBQECKAMDNIDIFPIEEPODKIPH; path=/
Content-Encoding: gzip
Vary: Accept-Encoding
Transfer-Encoding: chunked
is it because Transfer-Encoding: chunked i cant get size working?
".nLL" wrote in message
news:BaMXh.60674$aB1.43298@fe3.news.blueyonder.co.uk...
> hi. i have recently enabled gzip compression on my server and it works
> fine. but i have noticed something wierd.
>
> To protect my self from hotlinking i use a simple code to send my
> download with binarysend method. here is the code for an image
> download.
>
> Set objStream = Server.CreateObject("ADODB.Stream")
> Response.ContentType="image/jpeg"
> 'response.addheader "content-transfer-encoding", "binary"
> response.addheader "Content-Disposition", "attachment;filename="&
> filename & ";"
> 'Response.AddHeader "Content-Length", objStream.Size
> objStream.Open
> objStream.Type = 1
> objStream.LoadFromFile strFilePath
> Response.BinaryWrite objStream.Read
> objStream.Close
> Set objStream = Nothing
>
>
> when i use this code without gzip compression (although size section
> commented) it would send
> Content-Length and filename correctly.
>
> after enabling gzip this code stopped to send Content-Length and
> filename.
>
> any idea why it does that? is it my coding?
>
> thanks
>
>
Re: gzip and binarysend
am 26.04.2007 18:07:59 von Anthony Jones
".nLL" wrote in message
news:QdMXh.60675$aB1.25836@fe3.news.blueyonder.co.uk...
> after further test i couldn get
>
> Response.AddHeader "Content-Length", objStream.Size
>
> working. iis or asp refuses to send it but sends following
>
> HTTP/1.1 200 OK
> Cache-Control: private
> Date: Wed, 25 Apr 2007 16:39:24 GMT
> Content-Type: image/jpeg
> Content-Disposition: attachment;filename=a.jpg;
> Set-Cookie: ASPSESSIONIDQADTRBBQECKAMDNIDIFPIEEPODKIPH; path=/
> Content-Encoding: gzip
> Vary: Accept-Encoding
> Transfer-Encoding: chunked
>
>
> is it because Transfer-Encoding: chunked i cant get size working?
>
You should not attempt to set the content-size header, IIS will do that for
you.
The whole point behind Chunked encoding is to be able to stream an as yet
undetermined number of bytes to the client. The chunks are encoded with
their own size. Chunked encoding has a final packet which when received
allows the total content size to be calculated.
>
>
> ".nLL" wrote in message
> news:BaMXh.60674$aB1.43298@fe3.news.blueyonder.co.uk...
> > hi. i have recently enabled gzip compression on my server and it works
> > fine. but i have noticed something wierd.
> >
> > To protect my self from hotlinking i use a simple code to send my
> > download with binarysend method. here is the code for an image
> > download.
> >
> > Set objStream = Server.CreateObject("ADODB.Stream")
> > Response.ContentType="image/jpeg"
> > 'response.addheader "content-transfer-encoding", "binary"
> > response.addheader "Content-Disposition", "attachment;filename="&
> > filename & ";"
> > 'Response.AddHeader "Content-Length", objStream.Size
> > objStream.Open
> > objStream.Type = 1
> > objStream.LoadFromFile strFilePath
> > Response.BinaryWrite objStream.Read
> > objStream.Close
> > Set objStream = Nothing
> >
> >
> > when i use this code without gzip compression (although size section
> > commented) it would send
> > Content-Length and filename correctly.
> >
> > after enabling gzip this code stopped to send Content-Length and
> > filename.
> >
> > any idea why it does that? is it my coding?
> >
> > thanks
> >
> >
>
>