[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
|
||||
|
||||
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()
|
||||
|
||||
Dim sBuffer As String
|
||||
|
@ -104,11 +113,14 @@ Public Sub End()
|
|||
|
||||
sFile = Temp$("response")
|
||||
|
||||
If Split(CGI["HTTP_ACCEPT_ENCODING"], ",").Exist("gzip*", gb.Like) Then
|
||||
If Stat(sFile).Size >= 128 Then
|
||||
AddHeader("Content-Encoding", "gzip")
|
||||
Exec ["gzip", "-9", sFile] Wait
|
||||
If Exist(sFile & ".gz") Then sFile &= ".gz"
|
||||
If ShouldCompress() Then
|
||||
If Split(CGI["HTTP_ACCEPT_ENCODING"], ",").Exist("gzip*", gb.Like) Then
|
||||
If Stat(sFile).Size >= 128 Then
|
||||
AddHeader("Content-Encoding", "gzip")
|
||||
AddHeader("Vary", "Accept-Encoding")
|
||||
Exec ["gzip", "-9", sFile] Wait
|
||||
If Exist(sFile & ".gz") Then sFile &= ".gz"
|
||||
Endif
|
||||
Endif
|
||||
Endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue