[GB.WEB]
* NEW: Do not compress PNG and JPEG responses. * NEW: Automatically emit the "Vary: Accept-Encoding" header when sending a compressed response. git-svn-id: svn://localhost/gambas/trunk@3449 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
7e327f1619
commit
9edec79f89
1 changed files with 17 additions and 5 deletions
|
@ -88,6 +88,15 @@ Public Sub Begin()
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
Private Sub ShouldCompress() As Boolean
|
||||||
|
|
||||||
|
If $sContentType = "image/jpeg" Then Return False
|
||||||
|
If $sContentType = "image/png" Then Return False
|
||||||
|
Return True
|
||||||
|
|
||||||
|
End
|
||||||
|
|
||||||
|
|
||||||
Public Sub End()
|
Public Sub End()
|
||||||
|
|
||||||
Dim sBuffer As String
|
Dim sBuffer As String
|
||||||
|
@ -104,11 +113,14 @@ Public Sub End()
|
||||||
|
|
||||||
sFile = Temp$("response")
|
sFile = Temp$("response")
|
||||||
|
|
||||||
If Split(CGI["HTTP_ACCEPT_ENCODING"], ",").Exist("gzip*", gb.Like) Then
|
If ShouldCompress() Then
|
||||||
If Stat(sFile).Size >= 128 Then
|
If Split(CGI["HTTP_ACCEPT_ENCODING"], ",").Exist("gzip*", gb.Like) Then
|
||||||
AddHeader("Content-Encoding", "gzip")
|
If Stat(sFile).Size >= 128 Then
|
||||||
Exec ["gzip", "-9", sFile] Wait
|
AddHeader("Content-Encoding", "gzip")
|
||||||
If Exist(sFile & ".gz") Then sFile &= ".gz"
|
AddHeader("Vary", "Accept-Encoding")
|
||||||
|
Exec ["gzip", "-9", sFile] Wait
|
||||||
|
If Exist(sFile & ".gz") Then sFile &= ".gz"
|
||||||
|
Endif
|
||||||
Endif
|
Endif
|
||||||
Endif
|
Endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue