import binascii
from contextlib import closing
import copy
+import gzip
import threading
import datetime
from io import BytesIO
self.assertEqual(type(response.code), int)
self.assertEqual(type(response.effective_url), str)
+ def test_gzip(self):
+ # All the tests in this file should be using gzip, but this test
+ # ensures that it is in fact getting compressed, and also tests
+ # the httpclient's decompress=False option.
+ # Setting Accept-Encoding manually bypasses the client's
+ # decompression so we can see the raw data.
+ response = self.fetch(
+ "/chunk", decompress_response=False, headers={"Accept-Encoding": "gzip"}
+ )
+ self.assertEqual(response.headers["Content-Encoding"], "gzip")
+ self.assertNotEqual(response.body, b"asdfqwer")
+ # Our test data gets bigger when gzipped. Oops. :)
+ # Chunked encoding bypasses the MIN_LENGTH check.
+ self.assertEqual(len(response.body), 34)
+ f = gzip.GzipFile(mode="r", fileobj=response.buffer)
+ self.assertEqual(f.read(), b"asdfqwer")
+
def test_header_callback(self):
first_line = []
headers = {}
import collections
from contextlib import closing
import errno
-import gzip
import logging
import os
import re
response = yield client.fetch(self.get_url("/countdown/3"), max_redirects=3)
response.rethrow()
- def test_gzip(self):
- # All the tests in this file should be using gzip, but this test
- # ensures that it is in fact getting compressed.
- # Setting Accept-Encoding manually bypasses the client's
- # decompression so we can see the raw data.
- response = self.fetch(
- "/chunk", use_gzip=False, headers={"Accept-Encoding": "gzip"}
- )
- self.assertEqual(response.headers["Content-Encoding"], "gzip")
- self.assertNotEqual(response.body, b"asdfqwer")
- # Our test data gets bigger when gzipped. Oops. :)
- # Chunked encoding bypasses the MIN_LENGTH check.
- self.assertEqual(len(response.body), 34)
- f = gzip.GzipFile(mode="r", fileobj=response.buffer)
- self.assertEqual(f.read(), b"asdfqwer")
-
def test_max_redirects(self):
response = self.fetch("/countdown/5", max_redirects=3)
self.assertEqual(302, response.code)