Created
November 22, 2017 22:02
-
-
Save ywkaras/757413104c9b830cca0ea37be0619b1f to your computer and use it in GitHub Desktop.
gzip plugin brotli problems
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cache true | |
remove-accept-encoding true | |
compressible-content-type text/* | |
supported-algorithms br,gzip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import subprocess | |
Test.Summary = ''' | |
Test gzip plugin | |
''' | |
# Skip if plugin not present. | |
Test.SkipUnless(Condition.PluginExists('gzip.so')) | |
# Set up to check the output after the tests have run. | |
# | |
gzip_log_id = Test.Disk.File("gzip_short.log") | |
gzip_log_id.Content = "gzip.gold" | |
server = Test.MakeOriginServer("server") | |
request_header = { | |
"headers": "GET /foo HTTP/1.1\r\nHost: just.any.thing\r\n\r\n", "timestamp": "1469733493.993", "body": "" | |
} | |
# expected response from the origin server | |
response_header = { | |
"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n" + | |
'Etag: "359670651"\r\n' + | |
"Cache-Control: public, max-age=31536000\r\n" + | |
"Accept-Ranges: bytes\r\n" + | |
"Content-Type: text/text\r\n" + | |
"\r\n", | |
"timestamp": "1469733493.993", | |
"body": "lets go surfin now everybodys learnin how" | |
} | |
# add response to the server dictionary | |
server.addResponse("sessionfile.log", request_header, response_header) | |
# Define default ATS | |
ts = Test.MakeATSProcess("ts") | |
ts.Disk.records_config.update({ | |
#TEMP | |
'proxy.config.diags.debug.enabled': 1, | |
'proxy.config.diags.debug.tags': 'http|gzip', | |
'proxy.config.http.normalize_ae': 1, | |
}) | |
ts.Disk.remap_config.AddLine( | |
'map http://one.two.three/ http://127.0.0.1:{}/'.format(server.Variables.Port) + | |
' @plugin=gzip.so @pparam={}/gzip.config'.format(Test.TestDirectory) | |
) | |
# Ask the OS if the port is ready for connect() | |
# | |
def CheckPort(Port): | |
return lambda: 0 == subprocess.call('netstat --listen --tcp -n | grep -q :{}'.format(Port), shell=True) | |
LogTee = " 2>&1 | tee -a {}/gzip_long.log".format(Test.RunDirectory) | |
tr = Test.AddTestRun() | |
tr.Processes.Default.StartBefore(ts, ready=CheckPort(ts.Variables.port)) | |
tr.Processes.Default.StartBefore(server, ready=CheckPort(server.Variables.Port)) | |
tr.Processes.Default.ReturnCode = 0 | |
tr.Processes.Default.Command = ( | |
"curl --verbose --proxy http://127.0.0.1:{}".format(ts.Variables.port) + | |
" --header 'Accept-Encoding: gzip, deflate, br' 'http://one.two.three/foo'" + LogTee | |
) | |
tr = Test.AddTestRun() | |
tr.Processes.Default.ReturnCode = 0 | |
tr.Processes.Default.Command = ( | |
"curl --verbose --proxy http://127.0.0.1:{}".format(ts.Variables.port) + | |
" --header 'Accept-Encoding: gzip, deflate' 'http://one.two.three/foo'" + LogTee | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment