Bug 1653200 [wpt PR 24624] - Python 3: Port tests in fetch/api [part 2], a=testonly

Automatic update from web-platform-tests
Python 3: Port tests in fetch/api [part 2] (#24624)

--

wpt-commits: 69b245c9d25fe7cb4d5cb33e0626c1f0732f14d1
wpt-pr: 24624
This commit is contained in:
ziransun 2020-07-22 20:03:04 +00:00 коммит произвёл moz-wptsync-bot
Родитель fa9c5939c0
Коммит 977698b83a
7 изменённых файлов: 32 добавлений и 28 удалений

Просмотреть файл

@ -1,13 +1,13 @@
import time
def main(request, response):
delay = float(request.GET.first("ms", 1000)) / 1E3
count = int(request.GET.first("count", 50))
delay = float(request.GET.first(b"ms", 1000)) / 1E3
count = int(request.GET.first(b"count", 50))
time.sleep(delay)
response.headers.set("Transfer-Encoding", "chunked")
response.headers.set(b"Transfer-Encoding", b"chunked")
response.write_status_headers()
time.sleep(delay)
for i in xrange(count):
response.writer.write_content("a\r\nTEST_CHUNK\r\n")
for i in range(count):
response.writer.write_content(b"a\r\nTEST_CHUNK\r\n")
time.sleep(delay)
response.writer.write_content("garbage")
response.writer.write_content(b"garbage")

Просмотреть файл

@ -1,10 +1,12 @@
from wptserve.utils import isomorphic_encode
def main(request, response):
headers = [("X-Request-Method", request.method),
("X-Request-Content-Length", request.headers.get("Content-Length", "NO")),
("X-Request-Content-Type", request.headers.get("Content-Type", "NO")),
headers = [(b"X-Request-Method", isomorphic_encode(request.method)),
(b"X-Request-Content-Length", request.headers.get(b"Content-Length", b"NO")),
(b"X-Request-Content-Type", request.headers.get(b"Content-Type", b"NO")),
# Avoid any kind of content sniffing on the response.
("Content-Type", "text/plain")]
(b"Content-Type", b"text/plain")]
content = request.body
return headers, content

Просмотреть файл

@ -1,3 +1,3 @@
def main(request, response):
headers = [("Location", "")]
return 302, headers, ""
headers = [(b"Location", b"")]
return 302, headers, b""

Просмотреть файл

@ -1,7 +1,7 @@
def main(request, response):
headers = [("Content-type", request.GET.first("mime"))]
if "content" in request.GET and request.GET.first("content") == "empty":
content = ''
headers = [(b"Content-type", request.GET.first(b"mime"))]
if b"content" in request.GET and request.GET.first(b"content") == b"empty":
content = b''
else:
content = "console.log('Script loaded')"
content = b"console.log('Script loaded')"
return 200, headers, content

Просмотреть файл

@ -1,9 +1,11 @@
from wptserve.utils import isomorphic_encode
def main(request, response):
code = int(request.GET.first("code", 200))
text = request.GET.first("text", "OMG")
content = request.GET.first("content", "")
type = request.GET.first("type", "")
code = int(request.GET.first(b"code", 200))
text = request.GET.first(b"text", b"OMG")
content = request.GET.first(b"content", b"")
type = request.GET.first(b"type", b"")
status = (code, text)
headers = [("Content-Type", type),
("X-Request-Method", request.method)]
headers = [(b"Content-Type", type),
(b"X-Request-Method", isomorphic_encode(request.method))]
return status, headers, content

Просмотреть файл

@ -1,4 +1,4 @@
def main(request, response):
response.headers.set("Content-Type", "text/html")
response.headers.set("Custom", "\0")
return "<!doctype html><b>This is a document.</b>"
response.headers.set(b"Content-Type", b"text/html")
response.headers.set(b"Custom", b"\0")
return b"<!doctype html><b>This is a document.</b>"

Просмотреть файл

@ -1,4 +1,4 @@
def main(request, response):
response.headers.set("Content-Type", "text/javascript")
response.headers.set("Custom", "\0")
return "var thisIsJavaScript = 0"
response.headers.set(b"Content-Type", b"text/javascript")
response.headers.set(b"Custom", b"\0")
return b"var thisIsJavaScript = 0"