By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,203 Members | 1,249 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,203 IT Pros & Developers. It's quick & easy.

gzip and binarysend

P: n/a
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
Apr 25 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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=ACECKAMDNIDIFPIEEPODKIPH; path=/
Content-Encoding: gzip
Vary: Accept-Encoding
Transfer-Encoding: chunked
is it because Transfer-Encoding: chunked i cant get size working?

".nLL" <no***@here.comwrote in message
news:Ba*******************@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


Apr 25 '07 #2

P: n/a

".nLL" <no***@here.comwrote in message
news:Qd*******************@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=ACECKAMDNIDIFPIEEPODKIPH; 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" <no***@here.comwrote in message
news:Ba*******************@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


Apr 26 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.