Update web-platform-tests to revision 44702f2bc8ea98bc32b5b244f2fe63c6ce66d49d

This commit is contained in:
Josh Matthews 2017-11-15 12:15:13 -05:00
parent 85fa6409bb
commit c227604a2c
997 changed files with 45660 additions and 14650 deletions

View file

@ -351,17 +351,15 @@ class ErrorHandler(object):
response.set_error(self.status)
class StaticHandler(object):
def __init__(self, path, format_args, content_type, **headers):
class StringHandler(object):
def __init__(self, data, content_type, **headers):
"""Hander that reads a file from a path and substitutes some fixed data
:param path: Path to the template file to use
:param format_args: Dictionary of values to substitute into the template file
:param data: String to use
:param content_type: Content type header to server the response with
:param headers: List of headers to send with responses"""
with open(path) as f:
self.data = f.read() % format_args
self.data = data
self.resp_headers = [("Content-Type", content_type)]
for k, v in headers.iteritems():
@ -375,3 +373,18 @@ class StaticHandler(object):
def __call__(self, request, response):
rv = self.handler(request, response)
return rv
class StaticHandler(StringHandler):
def __init__(self, path, format_args, content_type, **headers):
"""Hander that reads a file from a path and substitutes some fixed data
:param path: Path to the template file to use
:param format_args: Dictionary of values to substitute into the template file
:param content_type: Content type header to server the response with
:param headers: List of headers to send with responses"""
with open(path) as f:
data = f.read() % format_args
return super(StaticHandler, self).__init__(data, content_type, **headers)