For Programmers: Free Programming Magazines  


Home > Archive > ASP > April 2007 > gzip and binarysend









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author gzip and binarysend
.nLL

2007-04-25, 6:55 pm

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


.nLL

2007-04-25, 6:55 pm

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: ASPSESSIONIDQADTRBBQ=ACECKAMDNIDIFPIEEPO
DKIPH; path=/
Content-Encoding: gzip
Vary: Accept-Encoding
Transfer-Encoding: chunked


is it because Transfer-Encoding: chunked i cant get size working?



".nLL" <noone@here.com> 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
>
>



Anthony Jones

2007-04-26, 6:55 pm


".nLL" <noone@here.com> 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: ASPSESSIONIDQADTRBBQ=ACECKAMDNIDIFPIEEPO
DKIPH; 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" <noone@here.com> wrote in message
> news:BaMXh.60674$aB1.43298@fe3.news.blueyonder.co.uk...
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com