buggy
stringlengths
35
5.03k
fixed
stringlengths
46
62.5k
def bltinlink(name): 'key = %s' % key, '#ffffff', '#ee77aa', '<br>'.join(results)) return 'Search Results', contents def html_getfile(path): """Get and display a source file listing safely.""" path = urllib.parse.unquote(path) with tokenize.open(path) as fp: ...
def bltinlink(name): 'key = %s' % key, '#ffffff', '#ee77aa', '<br>'.join(results)) return 'Search Results', contents def html_topics(): """Index of topic texts available."""
def get_html_page(url): op, _, url = url.partition('=') if op == "search?key": title, content = html_search(url) elif op == "getfile?key": title, content = html_getfile(url) elif op == "topic?key": ...
def get_html_page(url): op, _, url = url.partition('=') if op == "search?key": title, content = html_search(url) elif op == "topic?key": # try topics first, then objects. try:
def test_url_requests(self): ("topic?key=def", "Pydoc: KEYWORD def"), ("topic?key=STRINGS", "Pydoc: TOPIC STRINGS"), ("foobar", "Pydoc: Error - foobar"), ("getfile?key=foobar", "Pydoc: Error - getfile?key=foobar"), ] with self.restrict_walk_packages()...
def test_url_requests(self): ("topic?key=def", "Pydoc: KEYWORD def"), ("topic?key=STRINGS", "Pydoc: TOPIC STRINGS"), ("foobar", "Pydoc: Error - foobar"), ] with self.restrict_walk_packages(): for url, title in requests: self.call_url_h...
def default_urlconf(request): var s = link.getElementsByTagName('span')[0]; var uarr = String.fromCharCode(0x25b6); var darr = String.fromCharCode(0x25bc); s.innerHTML = s.innerHTML == uarr ? darr : uarr; return false; } function switchPastebinFriendly(link) { s1 = "Switch to...
def default_urlconf(request): var s = link.getElementsByTagName('span')[0]; var uarr = String.fromCharCode(0x25b6); var darr = String.fromCharCode(0x25bc); s.textContent = s.textContent == uarr ? darr : uarr; return false; } function switchPastebinFriendly(link) { s1 = "Switc...
class ChapterXtra1Admin(admin.ModelAdmin): class ArticleAdmin(admin.ModelAdmin): list_display = ('content', 'date', callable_year, 'model_year', 'modeladmin_year', 'model_year_reversed') list_filter = ('date', 'section') view_on_site = False fieldsets = (
class ChapterXtra1Admin(admin.ModelAdmin): class ArticleAdmin(admin.ModelAdmin): list_display = ('content', 'date', callable_year, 'model_year', 'modeladmin_year', 'model_year_reversed', 'section') list_editable = ('section',) list_filter = ('date', 'section') view_on_site = False ...
from django.utils.encoding import python_2_unicode_compatible class Section(models.Model): """ A simple section that links to articles, to test linking to related items
from django.utils.encoding import python_2_unicode_compatible @python_2_unicode_compatible class Section(models.Model): """ A simple section that links to articles, to test linking to related items
class Section(models.Model): """ name = models.CharField(max_length=100) @property def name_property(self): """
class Section(models.Model): """ name = models.CharField(max_length=100) def __str__(self): return self.name @property def name_property(self): """
def test_cancel_delete_related_confirmation(self): self.assertEqual(Pizza.objects.count(), 1) self.assertEqual(Topping.objects.count(), 2) def test_list_editable_raw_id_fields(self): parent = ParentWithUUIDPK.objects.create(title='test') parent2 = ParentWithUUIDPK.objects.create(tit...
def test_cancel_delete_related_confirmation(self): self.assertEqual(Pizza.objects.count(), 1) self.assertEqual(Topping.objects.count(), 2) def test_list_editable_popups(self): """ list_editable foreign keys have add/change popups. """ from selenium.webdriver.support....
def render_full(self, evalex=False, secret=None, evalex_trusted=True): """Render the Full HTML page with the traceback info.""" exc = escape(self.exception) return PAGE_HTML % { 'evalex': evalex and 'true' or 'false', 'evalex_trusted': eval...
def render_full(self, evalex=False, secret=None, evalex_trusted=True): """Render the Full HTML page with the traceback info.""" exc = escape(self.exception) ptext = escape(self.plaintext) return PAGE_HTML % { 'evalex': evalex and 'true' or 'false...
def render_full(self, evalex=False, secret=None, 'exception': exc, 'exception_type': escape(self.exception_type), 'summary': self.render_summary(include_title=False), 'plaintext': self.plaintext, 'plaintext_cs': re.sub('-{2,}', '-'...
def render_full(self, evalex=False, secret=None, 'exception': exc, 'exception_type': escape(self.exception_type), 'summary': self.render_summary(include_title=False), 'plaintext': ptext, 'plaintext_cs': re.sub('-{2,}', '-', self.pl...
def load(klass): for path in klass.CONF_PATHS: if os.path.exists(path): with open(path, 'r') as conf: config.configure(yaml.load(conf)) return config def configure(self, conf={}):
def load(klass): for path in klass.CONF_PATHS: if os.path.exists(path): with open(path, 'r') as conf: config.configure(yaml.safe_load(conf)) return config def configure(self, conf={}):
# tests.conf_tests # Testing the configuration module for Confire # # Author: Benjamin Bengfort <benjamin@bengfort.com>
# tests.test_conf # Testing the configuration module for Confire # # Author: Benjamin Bengfort <benjamin@bengfort.com>
# Copyright (C) 2014 Bengfort.com # For license information, see LICENSE.txt # # ID: conf_tests.py [] benjamin@bengfort.com $ """ Testing the configuration module for Confire
# Copyright (C) 2014 Bengfort.com # For license information, see LICENSE.txt # # ID: test_conf.py [] benjamin@bengfort.com $ """ Testing the configuration module for Confire
# tests.descriptors_tests # Implements a base SettingsDescriptor for advanced configurations # # Author: Benjamin Bengfort <benjamin@bengfort.com>
# tests.test_descriptors # Implements a base SettingsDescriptor for advanced configurations # # Author: Benjamin Bengfort <benjamin@bengfort.com>
# Copyright (C) 2015 Bengfort.com # For license information, see LICENSE.txt # # ID: descriptors_tests.py [] benjamin@bengfort.com $ """ Implements a base SettingsDescriptor for advanced configurations
# Copyright (C) 2015 Bengfort.com # For license information, see LICENSE.txt # # ID: test_descriptors.py [] benjamin@bengfort.com $ """ Implements a base SettingsDescriptor for advanced configurations
# tests.environ_tests # Tests the environment configuration ability # # Author: Benjamin Bengfort <benjamin@bengfort.com>
# tests.test_environ # Tests the environment configuration ability # # Author: Benjamin Bengfort <benjamin@bengfort.com>
# Copyright (C) 2014 Bengfort.com # For license information, see LICENSE.txt # # ID: environ_tests.py [] benjamin@bengfort.com $ """ Tests the environment configuration ability
# Copyright (C) 2014 Bengfort.com # For license information, see LICENSE.txt # # ID: test_environ.py [] benjamin@bengfort.com $ """ Tests the environment configuration ability
# tests.paths_tests # Testing the paths descriptor # # Author: Benjamin Bengfort <benjamin@bengfort.com>
# tests.test_paths # Testing the paths descriptor # # Author: Benjamin Bengfort <benjamin@bengfort.com>
# Copyright (C) 2014 Bengfort.com # For license information, see LICENSE.txt # # ID: paths_tests.py [] benjamin@bengfort.com $ """ Testing the paths descriptor
# Copyright (C) 2014 Bengfort.com # For license information, see LICENSE.txt # # ID: test_paths.py [] benjamin@bengfort.com $ """ Testing the paths descriptor
setup( name="waitress", version="1.3.1", author="Zope Foundation and Contributors", author_email="zope-dev@zope.org", maintainer="Pylons Project",
setup( name="waitress", version="1.4.0", author="Zope Foundation and Contributors", author_email="zope-dev@zope.org", maintainer="Pylons Project",
import re from io import BytesIO from waitress.compat import ( tostr, urlparse, unquote_bytes_to_wsgi, ) from waitress.buffers import OverflowableBuffer from waitress.receiver import ( FixedStreamReceiver, ChunkedReceiver, ) from waitress.utilities import ( find_double_newline, RequestEn...
import re from io import BytesIO from waitress.buffers import OverflowableBuffer from waitress.compat import tostr, unquote_bytes_to_wsgi, urlparse from waitress.receiver import ChunkedReceiver, FixedStreamReceiver from waitress.utilities import ( BadRequest, RequestEntityTooLarge, RequestHeaderFieldsTooLa...
class ParsingError(Exception): pass class HTTPRequestParser(object): """A structure that collects the HTTP request.
class ParsingError(Exception): pass class TransferEncodingNotImplemented(Exception): pass class HTTPRequestParser(object): """A structure that collects the HTTP request.
def received(self, data): """ if self.completed: return 0 # Can't consume any more. datalen = len(data) br = self.body_rcv if br is None: # In header. s = self.header_plus + data index = find_double_newline(s) if index ...
def received(self, data): """ if self.completed: return 0 # Can't consume any more. datalen = len(data) br = self.body_rcv if br is None: # In header. max_header = self.adj.max_request_header_size s = self.header_plus + data ...
def received(self, data): except ParsingError as e: self.error = BadRequest(e.args[0]) self.completed = True else: if self.body_rcv is None: # no content-length header and not a t-...
def received(self, data): except ParsingError as e: self.error = BadRequest(e.args[0]) self.completed = True except TransferEncodingNotImplemented as e: self.error = ServerNotImplemented(e.args[0]) ...
def received(self, data): elif br.completed: # The request (with the body) is ready to use. self.completed = True if self.chunked: # We've converted the chunked transfer encoding request # body into a normal request body...
def received(self, data): elif br.completed: # The request (with the body) is ready to use. self.completed = True if self.chunked: # We've converted the chunked transfer encoding request # body into a normal request bod...
def received(self, data): # appear to the client to be an entirely non-chunked HTTP # request with a valid content-length. self.headers["CONTENT_LENGTH"] = str(br.__len__()) return consumed def parse_header(self, header_plus):
def received(self, data): # appear to the client to be an entirely non-chunked HTTP # request with a valid content-length. self.headers["CONTENT_LENGTH"] = str(br.__len__()) return consumed def parse_header(self, header_plus):
def parse_header(self, header_plus): Parses the header_plus block of text (the headers plus the first line of the request). """ index = header_plus.find(b"\n") if index >= 0: first_line = header_plus[:index].rstrip() header = header_plus[index + 1 :] ...
def parse_header(self, header_plus): Parses the header_plus block of text (the headers plus the first line of the request). """ index = header_plus.find(b"\r\n") if index >= 0: first_line = header_plus[:index].rstrip() header = header_plus[index + 2 :] ...
def parse_header(self, header_plus): index = line.find(b":") if index > 0: key = line[:index] if b"_" in key: continue value = line[index + 1 :].strip()
def parse_header(self, header_plus): index = line.find(b":") if index > 0: key = line[:index] if key != key.strip(): raise ParsingError("Invalid whitespace after field-name") if b"_" in key: continue ...
def parse_header(self, header_plus): # should not see the HTTP_TRANSFER_ENCODING header; we pop it # here te = headers.pop("TRANSFER_ENCODING", "") if te.lower() == "chunked": self.chunked = True buf = OverflowableBuffer(self.adj.inbuf_over...
def parse_header(self, header_plus): # should not see the HTTP_TRANSFER_ENCODING header; we pop it # here te = headers.pop("TRANSFER_ENCODING", "") encodings = [encoding.strip().lower() for encoding in te.split(",") if encoding] for encoding in encodings: ...
def parse_header(self, header_plus): try: cl = int(headers.get("CONTENT_LENGTH", 0)) except ValueError: cl = 0 self.content_length = cl if cl > 0: buf = OverflowableBuffer(self.adj.inbuf_overflow)
def parse_header(self, header_plus): try: cl = int(headers.get("CONTENT_LENGTH", 0)) except ValueError: raise ParsingError("Content-Length is invalid") self.content_length = cl if cl > 0: buf = OverflowableBuffer(self.adj.i...
def get_header_lines(header): Splits the header into lines, putting multi-line headers together. """ r = [] lines = header.split(b"\n") for line in lines: if line.startswith((b" ", b"\t")): if not r: # https://corte.si/posts/code/pathod/pythonservers/index.html
def get_header_lines(header): Splits the header into lines, putting multi-line headers together. """ r = [] lines = header.split(b"\r\n") for line in lines: if b"\r" in line or b"\n" in line: raise ParsingError('Bare CR or LF found in header line "%s"' % tostr(line)) if ...
"""Data Chunk Receiver """ from waitress.utilities import find_double_newline from waitress.utilities import BadRequest class FixedStreamReceiver(object):
"""Data Chunk Receiver """ from waitress.utilities import BadRequest, find_double_newline class FixedStreamReceiver(object):
def __len__(self): def received(self, data): "See IStreamConsumer" rm = self.remain if rm < 1: self.completed = True # Avoid any chance of spinning return 0 datalen = len(data) if rm <= datalen: self.buf.append(data[:rm]) self....
def __len__(self): def received(self, data): "See IStreamConsumer" rm = self.remain if rm < 1: self.completed = True # Avoid any chance of spinning return 0 datalen = len(data) if rm <= datalen: self.buf.append(data[:rm]) se...
def getbuf(self): class ChunkedReceiver(object): chunk_remainder = 0 control_line = b"" all_chunks_received = False trailer = b"" completed = False
def getbuf(self): class ChunkedReceiver(object): chunk_remainder = 0 validate_chunk_end = False control_line = b"" chunk_end = b"" all_chunks_received = False trailer = b"" completed = False
def __len__(self): def received(self, s): # Returns the number of bytes consumed. if self.completed: return 0 orig_size = len(s) while s: rm = self.chunk_remainder if rm > 0: # Receive the remainder of a chunk. to_w...
def __len__(self): def received(self, s): # Returns the number of bytes consumed. if self.completed: return 0 orig_size = len(s) while s: rm = self.chunk_remainder if rm > 0: # Receive the remainder of a chunk. t...
def received(self, s): except ValueError: # garbage in input self.error = BadRequest("garbage in chunked encoding input") sz = 0 if sz > 0: # Start a new chunk. ...
def received(self, s): except ValueError: # garbage in input self.error = BadRequest("garbage in chunked encoding input") sz = 0 if sz > 0: # Start a new chunk. ...
def received(self, s): else: # Receive the trailer. trailer = self.trailer + s if trailer.startswith(b"\r\n"): # No trailer. self.completed = True return orig_size - (len(trailer) - 2) ...
def received(self, s): else: # Receive the trailer. trailer = self.trailer + s if trailer.startswith(b"\r\n"): # No trailer. self.completed = True return orig_size - (len(trailer) - 2) ...
def received(self, s): # Finished the trailer. self.completed = True self.trailer = trailer[:pos] return orig_size - (len(trailer) - pos) return orig_size def getfile(self):
def received(self, s): # Finished the trailer. self.completed = True self.trailer = trailer[:pos] return orig_size - (len(trailer) - pos) return orig_size def getfile(self):
def execute(self): status, headers, body = e.to_response() self.status = status self.response_headers.extend(headers) if self.version == "1.1": connection = self.request.headers.get("CONNECTION", "").lower() if connection == "close": self.response_...
def execute(self): status, headers, body = e.to_response() self.status = status self.response_headers.extend(headers) # We need to explicitly tell the remote client we are closing the # connection, because self.close_on_finish is set, and we are going to # slam the door i...
def test_del_channel(self): def test_received(self): inst, sock, map = self._makeOneWithMap() inst.server = DummyServer() inst.received(b"GET / HTTP/1.1\n\n") self.assertEqual(inst.server.tasks, [inst]) self.assertTrue(inst.requests)
def test_del_channel(self): def test_received(self): inst, sock, map = self._makeOneWithMap() inst.server = DummyServer() inst.received(b"GET / HTTP/1.1\r\n\r\n") self.assertEqual(inst.server.tasks, [inst]) self.assertTrue(inst.requests)
def test_received_preq_not_completed(self): inst.request = preq preq.completed = False preq.empty = True inst.received(b"GET / HTTP/1.1\n\n") self.assertEqual(inst.requests, ()) self.assertEqual(inst.server.tasks, [])
def test_received_preq_not_completed(self): inst.request = preq preq.completed = False preq.empty = True inst.received(b"GET / HTTP/1.1\r\n\r\n") self.assertEqual(inst.requests, ()) self.assertEqual(inst.server.tasks, [])
def test_received_preq_completed_empty(self): inst.request = preq preq.completed = True preq.empty = True inst.received(b"GET / HTTP/1.1\n\n") self.assertEqual(inst.request, None) self.assertEqual(inst.server.tasks, [])
def test_received_preq_completed_empty(self): inst.request = preq preq.completed = True preq.empty = True inst.received(b"GET / HTTP/1.1\r\n\r\n") self.assertEqual(inst.request, None) self.assertEqual(inst.server.tasks, [])
def test_received_preq_error(self): inst.request = preq preq.completed = True preq.error = True inst.received(b"GET / HTTP/1.1\n\n") self.assertEqual(inst.request, None) self.assertEqual(len(inst.server.tasks), 1) self.assertTrue(inst.requests)
def test_received_preq_error(self): inst.request = preq preq.completed = True preq.error = True inst.received(b"GET / HTTP/1.1\r\n\r\n") self.assertEqual(inst.request, None) self.assertEqual(len(inst.server.tasks), 1) self.assertTrue(inst.requests)
def test_received_preq_completed_connection_close(self): preq.completed = True preq.empty = True preq.connection_close = True inst.received(b"GET / HTTP/1.1\n\n" + b"a" * 50000) self.assertEqual(inst.request, None) self.assertEqual(inst.server.tasks, []) def test_rec...
def test_received_preq_completed_connection_close(self): preq.completed = True preq.empty = True preq.connection_close = True inst.received(b"GET / HTTP/1.1\r\n\r\n" + b"a" * 50000) self.assertEqual(inst.request, None) self.assertEqual(inst.server.tasks, []) def test...
def test_received_headers_finished_expect_continue_false(self): preq.completed = False preq.empty = False preq.retval = 1 inst.received(b"GET / HTTP/1.1\n\n") self.assertEqual(inst.request, preq) self.assertEqual(inst.server.tasks, []) self.assertEqual(inst.outbuf...
def test_received_headers_finished_expect_continue_false(self): preq.completed = False preq.empty = False preq.retval = 1 inst.received(b"GET / HTTP/1.1\r\n\r\n") self.assertEqual(inst.request, preq) self.assertEqual(inst.server.tasks, []) self.assertEqual(inst.ou...
def test_received_headers_finished_expect_continue_true(self): preq.headers_finished = True preq.completed = False preq.empty = False inst.received(b"GET / HTTP/1.1\n\n") self.assertEqual(inst.request, preq) self.assertEqual(inst.server.tasks, []) self.assertEqual...
def test_received_headers_finished_expect_continue_true(self): preq.headers_finished = True preq.completed = False preq.empty = False inst.received(b"GET / HTTP/1.1\r\n\r\n") self.assertEqual(inst.request, preq) self.assertEqual(inst.server.tasks, []) self.assertE...
def test_received_headers_finished_expect_continue_true_sent_true(self): preq.completed = False preq.empty = False inst.sent_continue = True inst.received(b"GET / HTTP/1.1\n\n") self.assertEqual(inst.request, preq) self.assertEqual(inst.server.tasks, []) self.asse...
def test_received_headers_finished_expect_continue_true_sent_true(self): preq.completed = False preq.empty = False inst.sent_continue = True inst.received(b"GET / HTTP/1.1\r\n\r\n") self.assertEqual(inst.request, preq) self.assertEqual(inst.server.tasks, []) self....
def _read_echo(self, fp): return line, headers, echo.parse_response(body) def test_date_and_server(self): to_send = "GET / HTTP/1.0\n" "Content-Length: 0\n\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def _read_echo(self, fp): return line, headers, echo.parse_response(body) def test_date_and_server(self): to_send = "GET / HTTP/1.0\r\nContent-Length: 0\r\n\r\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_date_and_server(self): def test_bad_host_header(self): # https://corte.si/posts/code/pathod/pythonservers/index.html to_send = "GET / HTTP/1.0\n" " Host: 0\n\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_date_and_server(self): def test_bad_host_header(self): # https://corte.si/posts/code/pathod/pythonservers/index.html to_send = "GET / HTTP/1.0\r\n Host: 0\r\n\r\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_bad_host_header(self): self.assertTrue(headers.get("date")) def test_send_with_body(self): to_send = "GET / HTTP/1.0\n" "Content-Length: 5\n\n" to_send += "hello" to_send = tobytes(to_send) self.connect()
def test_bad_host_header(self): self.assertTrue(headers.get("date")) def test_send_with_body(self): to_send = "GET / HTTP/1.0\r\nContent-Length: 5\r\n\r\n" to_send += "hello" to_send = tobytes(to_send) self.connect()
def test_send_with_body(self): self.assertEqual(echo.body, b"hello") def test_send_empty_body(self): to_send = "GET / HTTP/1.0\n" "Content-Length: 0\n\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_send_with_body(self): self.assertEqual(echo.body, b"hello") def test_send_empty_body(self): to_send = "GET / HTTP/1.0\r\nContent-Length: 0\r\n\r\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_multiple_requests_without_body(self): self.sock = orig_sock def test_without_crlf(self): data = "Echo\nthis\r\nplease" s = tobytes( "GET / HTTP/1.0\n" "Connection: close\n" "Content-Length: %d\n" "\n" "%s" % (len(data), da...
def test_multiple_requests_without_body(self): self.sock = orig_sock def test_without_crlf(self): data = "Echo\r\nthis\r\nplease" s = tobytes( "GET / HTTP/1.0\r\n" "Connection: close\r\n" "Content-Length: %d\r\n" "\r\n" "%s" % (len...
def test_large_body(self): # 1024 characters. body = "This string has 32 characters.\r\n" * 32 s = tobytes( "GET / HTTP/1.0\n" "Content-Length: %d\n" "\n" "%s" % (len(body), body) ) self.connect() self.sock.send(s)
def test_large_body(self): # 1024 characters. body = "This string has 32 characters.\r\n" * 32 s = tobytes( "GET / HTTP/1.0\r\nContent-Length: %d\r\n\r\n%s" % (len(body), body) ) self.connect() self.sock.send(s)
def test_many_clients(self): h.close() def test_chunking_request_without_content(self): header = tobytes("GET / HTTP/1.1\n" "Transfer-Encoding: chunked\n\n") self.connect() self.sock.send(header) self.sock.send(b"0\r\n\r\n")
def test_many_clients(self): h.close() def test_chunking_request_without_content(self): header = tobytes("GET / HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n") self.connect() self.sock.send(header) self.sock.send(b"0\r\n\r\n")
def test_chunking_request_with_content(self): control_line = b"20;\r\n" # 20 hex = 32 dec s = b"This string has 32 characters.\r\n" expected = s * 12 header = tobytes("GET / HTTP/1.1\n" "Transfer-Encoding: chunked\n\n") self.connect() self.sock.send(header) fp = ...
def test_chunking_request_with_content(self): control_line = b"20;\r\n" # 20 hex = 32 dec s = b"This string has 32 characters.\r\n" expected = s * 12 header = tobytes("GET / HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n") self.connect() self.sock.send(header) fp...
def test_chunking_request_with_content(self): def test_broken_chunked_encoding(self): control_line = "20;\r\n" # 20 hex = 32 dec s = "This string has 32 characters.\r\n" to_send = "GET / HTTP/1.1\nTransfer-Encoding: chunked\n\n" to_send += control_line + s # garbage in input...
def test_chunking_request_with_content(self): def test_broken_chunked_encoding(self): control_line = "20;\r\n" # 20 hex = 32 dec s = "This string has 32 characters.\r\n" to_send = "GET / HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n" to_send += control_line + s + "\r\n" # g...
def test_broken_chunked_encoding(self): self.assertline(line, "400", "Bad Request", "HTTP/1.1") cl = int(headers["content-length"]) self.assertEqual(cl, len(response_body)) self.assertEqual( sorted(headers.keys()), ["content-length", "content-type", "date", "server"] ...
def test_broken_chunked_encoding(self): self.assertline(line, "400", "Bad Request", "HTTP/1.1") cl = int(headers["content-length"]) self.assertEqual(cl, len(response_body)) self.assertTrue(b"Chunk not properly terminated" in response_body) self.assertEqual( sorted(hea...
def test_keepalive_http_10(self): # Handling of Keep-Alive within HTTP 1.0 data = "Default: Don't keep me alive" s = tobytes( "GET / HTTP/1.0\n" "Content-Length: %d\n" "\n" "%s" % (len(data), data) ) self.connect() self.sock.send(s)
def test_keepalive_http_10(self): # Handling of Keep-Alive within HTTP 1.0 data = "Default: Don't keep me alive" s = tobytes( "GET / HTTP/1.0\r\nContent-Length: %d\r\n\r\n%s" % (len(data), data) ) self.connect() self.sock.send(s)
def test_keepalive_http10_explicit(self): # the corresponding header data = "Keep me alive" s = tobytes( "GET / HTTP/1.0\n" "Connection: Keep-Alive\n" "Content-Length: %d\n" "\n" "%s" % (len(data), data) ) self.connect()
def test_keepalive_http10_explicit(self): # the corresponding header data = "Keep me alive" s = tobytes( "GET / HTTP/1.0\r\n" "Connection: Keep-Alive\r\n" "Content-Length: %d\r\n" "\r\n" "%s" % (len(data), data) ) self.c...
def test_keepalive_http_11(self): # All connections are kept alive, unless stated otherwise data = "Default: Keep me alive" s = tobytes( "GET / HTTP/1.1\n" "Content-Length: %d\n" "\n" "%s" % (len(data), data) ) self.connect() self.sock.send(s)
def test_keepalive_http_11(self): # All connections are kept alive, unless stated otherwise data = "Default: Keep me alive" s = tobytes( "GET / HTTP/1.1\r\nContent-Length: %d\r\n\r\n%s" % (len(data), data) ) self.connect() self.sock.send(s)
def test_keepalive_http11_explicit(self): # Explicitly set keep-alive data = "Default: Keep me alive" s = tobytes( "GET / HTTP/1.1\n" "Connection: keep-alive\n" "Content-Length: %d\n" "\n" "%s" % (len(data), data) ) self...
def test_keepalive_http11_explicit(self): # Explicitly set keep-alive data = "Default: Keep me alive" s = tobytes( "GET / HTTP/1.1\r\n" "Connection: keep-alive\r\n" "Content-Length: %d\r\n" "\r\n" "%s" % (len(data), data) ) ...
def test_keepalive_http11_connclose(self): # specifying Connection: close explicitly data = "Don't keep me alive" s = tobytes( "GET / HTTP/1.1\n" "Connection: close\n" "Content-Length: %d\n" "\n" "%s" % (len(data), data) ) ...
def test_keepalive_http11_connclose(self): # specifying Connection: close explicitly data = "Don't keep me alive" s = tobytes( "GET / HTTP/1.1\r\n" "Connection: close\r\n" "Content-Length: %d\r\n" "\r\n" "%s" % (len(data), data) ...
def test_keepalive_http11_connclose(self): def test_proxy_headers(self): to_send = ( "GET / HTTP/1.0\n" "Content-Length: 0\n" "Host: www.google.com:8080\n" "X-Forwarded-For: 192.168.1.1\n" "X-Forwarded-Proto: https\n" "X-Forwarded-Port...
def test_keepalive_http11_connclose(self): def test_proxy_headers(self): to_send = ( "GET / HTTP/1.0\r\n" "Content-Length: 0\r\n" "Host: www.google.com:8080\r\n" "X-Forwarded-For: 192.168.1.1\r\n" "X-Forwarded-Proto: https\r\n" "X-Forw...
def test_expect_continue(self): # specifying Connection: close explicitly data = "I have expectations" to_send = tobytes( "GET / HTTP/1.1\n" "Connection: close\n" "Content-Length: %d\n" "Expect: 100-continue\n" "\n" "%s" % (...
def test_expect_continue(self): # specifying Connection: close explicitly data = "I have expectations" to_send = tobytes( "GET / HTTP/1.1\r\n" "Connection: close\r\n" "Content-Length: %d\r\n" "Expect: 100-continue\r\n" "\r\n" ...
def test_short_body(self): # check to see if server closes connection when body is too short # for cl header to_send = tobytes( "GET /short_body HTTP/1.0\n" "Connection: Keep-Alive\n" "Content-Length: 0\n" "\n" ) self.connect() ...
def test_short_body(self): # check to see if server closes connection when body is too short # for cl header to_send = tobytes( "GET /short_body HTTP/1.0\r\n" "Connection: Keep-Alive\r\n" "Content-Length: 0\r\n" "\r\n" ) self.connec...
def test_long_body(self): # check server doesnt close connection when body is too short # for cl header to_send = tobytes( "GET /long_body HTTP/1.0\n" "Connection: Keep-Alive\n" "Content-Length: 0\n" "\n" ) self.connect() se...
def test_long_body(self): # check server doesnt close connection when body is too short # for cl header to_send = tobytes( "GET /long_body HTTP/1.0\r\n" "Connection: Keep-Alive\r\n" "Content-Length: 0\r\n" "\r\n" ) self.connect() ...
def tearDown(self): def test_http10_generator(self): body = string.ascii_letters to_send = ( "GET / HTTP/1.0\n" "Connection: Keep-Alive\n" "Content-Length: %d\n\n" % len(body) ) to_send += body to_send = tobytes(to_send)
def tearDown(self): def test_http10_generator(self): body = string.ascii_letters to_send = ( "GET / HTTP/1.0\r\n" "Connection: Keep-Alive\r\n" "Content-Length: %d\r\n\r\n" % len(body) ) to_send += body to_send = tobytes(to_send)
def test_http10_generator(self): def test_http10_list(self): body = string.ascii_letters to_send = ( "GET /list HTTP/1.0\n" "Connection: Keep-Alive\n" "Content-Length: %d\n\n" % len(body) ) to_send += body to_send = tobytes(to_send)
def test_http10_generator(self): def test_http10_list(self): body = string.ascii_letters to_send = ( "GET /list HTTP/1.0\r\n" "Connection: Keep-Alive\r\n" "Content-Length: %d\r\n\r\n" % len(body) ) to_send += body to_send = tobytes(to_send)
def test_http10_list(self): def test_http10_listlentwo(self): body = string.ascii_letters to_send = ( "GET /list_lentwo HTTP/1.0\n" "Connection: Keep-Alive\n" "Content-Length: %d\n\n" % len(body) ) to_send += body to_send = tobytes(to_send)
def test_http10_list(self): def test_http10_listlentwo(self): body = string.ascii_letters to_send = ( "GET /list_lentwo HTTP/1.0\r\n" "Connection: Keep-Alive\r\n" "Content-Length: %d\r\n\r\n" % len(body) ) to_send += body to_send = tobytes(...
def test_http10_listlentwo(self): def test_http11_generator(self): body = string.ascii_letters to_send = "GET / HTTP/1.1\n" "Content-Length: %s\n\n" % len(body) to_send += body to_send = tobytes(to_send) self.connect()
def test_http10_listlentwo(self): def test_http11_generator(self): body = string.ascii_letters to_send = "GET / HTTP/1.1\r\nContent-Length: %s\r\n\r\n" % len(body) to_send += body to_send = tobytes(to_send) self.connect()
def test_http11_generator(self): def test_http11_list(self): body = string.ascii_letters to_send = "GET /list HTTP/1.1\n" "Content-Length: %d\n\n" % len(body) to_send += body to_send = tobytes(to_send) self.connect()
def test_http11_generator(self): def test_http11_list(self): body = string.ascii_letters to_send = "GET /list HTTP/1.1\r\nContent-Length: %d\r\n\r\n" % len(body) to_send += body to_send = tobytes(to_send) self.connect()
def test_http11_list(self): def test_http11_listlentwo(self): body = string.ascii_letters to_send = "GET /list_lentwo HTTP/1.1\n" "Content-Length: %s\n\n" % len(body) to_send += body to_send = tobytes(to_send) self.connect()
def test_http11_list(self): def test_http11_listlentwo(self): body = string.ascii_letters to_send = "GET /list_lentwo HTTP/1.1\r\nContent-Length: %s\r\n\r\n" % len(body) to_send += body to_send = tobytes(to_send) self.connect()
def test_short_body(self): # check to see if server closes connection when body is too short # for cl header to_send = tobytes( "GET /short_body HTTP/1.0\n" "Connection: Keep-Alive\n" "Content-Length: 0\n" "\n" ) self.connect() ...
def test_short_body(self): # check to see if server closes connection when body is too short # for cl header to_send = tobytes( "GET /short_body HTTP/1.0\r\n" "Connection: Keep-Alive\r\n" "Content-Length: 0\r\n" "\r\n" ) self.connec...
def test_long_body(self): # check server doesnt close connection when body is too long # for cl header to_send = tobytes( "GET /long_body HTTP/1.0\n" "Connection: Keep-Alive\n" "Content-Length: 0\n" "\n" ) self.connect() sel...
def test_long_body(self): # check server doesnt close connection when body is too long # for cl header to_send = tobytes( "GET /long_body HTTP/1.0\r\n" "Connection: Keep-Alive\r\n" "Content-Length: 0\r\n" "\r\n" ) self.connect() ...
def test_equal_body(self): # check server doesnt close connection when body is equal to # cl header to_send = tobytes( "GET /equal_body HTTP/1.0\n" "Connection: Keep-Alive\n" "Content-Length: 0\n" "\n" ) self.connect() self....
def test_equal_body(self): # check server doesnt close connection when body is equal to # cl header to_send = tobytes( "GET /equal_body HTTP/1.0\r\n" "Connection: Keep-Alive\r\n" "Content-Length: 0\r\n" "\r\n" ) self.connect() ...
def test_equal_body(self): def test_no_content_length(self): # wtf happens when there's no content-length to_send = tobytes( "GET /no_content_length HTTP/1.0\n" "Connection: Keep-Alive\n" "Content-Length: 0\n" "\n" ) self.connect() ...
def test_equal_body(self): def test_no_content_length(self): # wtf happens when there's no content-length to_send = tobytes( "GET /no_content_length HTTP/1.0\r\n" "Connection: Keep-Alive\r\n" "Content-Length: 0\r\n" "\r\n" ) self.connec...
def tearDown(self): def test_request_body_too_large_with_wrong_cl_http10(self): body = "a" * self.toobig to_send = "GET / HTTP/1.0\n" "Content-Length: 5\n\n" to_send += body to_send = tobytes(to_send) self.connect()
def tearDown(self): def test_request_body_too_large_with_wrong_cl_http10(self): body = "a" * self.toobig to_send = "GET / HTTP/1.0\r\nContent-Length: 5\r\n\r\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_wrong_cl_http10(self): def test_request_body_too_large_with_wrong_cl_http10_keepalive(self): body = "a" * self.toobig to_send = "GET / HTTP/1.0\n" "Content-Length: 5\n" "Connection: Keep-Alive\n\n" to_send += body to_send = tobytes(to_send) ...
def test_request_body_too_large_with_wrong_cl_http10(self): def test_request_body_too_large_with_wrong_cl_http10_keepalive(self): body = "a" * self.toobig to_send = "GET / HTTP/1.0\r\nContent-Length: 5\r\nConnection: Keep-Alive\r\n\r\n" to_send += body to_send = tobytes(to_send) ...
def test_request_body_too_large_with_wrong_cl_http10_keepalive(self): def test_request_body_too_large_with_no_cl_http10(self): body = "a" * self.toobig to_send = "GET / HTTP/1.0\n\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_wrong_cl_http10_keepalive(self): def test_request_body_too_large_with_no_cl_http10(self): body = "a" * self.toobig to_send = "GET / HTTP/1.0\r\n\r\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_no_cl_http10(self): def test_request_body_too_large_with_no_cl_http10_keepalive(self): body = "a" * self.toobig to_send = "GET / HTTP/1.0\nConnection: Keep-Alive\n\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_no_cl_http10(self): def test_request_body_too_large_with_no_cl_http10_keepalive(self): body = "a" * self.toobig to_send = "GET / HTTP/1.0\r\nConnection: Keep-Alive\r\n\r\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_no_cl_http10_keepalive(self): def test_request_body_too_large_with_wrong_cl_http11(self): body = "a" * self.toobig to_send = "GET / HTTP/1.1\n" "Content-Length: 5\n\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_no_cl_http10_keepalive(self): def test_request_body_too_large_with_wrong_cl_http11(self): body = "a" * self.toobig to_send = "GET / HTTP/1.1\r\nContent-Length: 5\r\n\r\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_wrong_cl_http11(self): def test_request_body_too_large_with_wrong_cl_http11_connclose(self): body = "a" * self.toobig to_send = "GET / HTTP/1.1\nContent-Length: 5\nConnection: close\n\n" to_send += body to_send = tobytes(to_send) self.con...
def test_request_body_too_large_with_wrong_cl_http11(self): def test_request_body_too_large_with_wrong_cl_http11_connclose(self): body = "a" * self.toobig to_send = "GET / HTTP/1.1\r\nContent-Length: 5\r\nConnection: close\r\n\r\n" to_send += body to_send = tobytes(to_send) ...
def test_request_body_too_large_with_wrong_cl_http11_connclose(self): def test_request_body_too_large_with_no_cl_http11(self): body = "a" * self.toobig to_send = "GET / HTTP/1.1\n\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_wrong_cl_http11_connclose(self): def test_request_body_too_large_with_no_cl_http11(self): body = "a" * self.toobig to_send = "GET / HTTP/1.1\r\n\r\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_no_cl_http11(self): def test_request_body_too_large_with_no_cl_http11_connclose(self): body = "a" * self.toobig to_send = "GET / HTTP/1.1\nConnection: close\n\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_no_cl_http11(self): def test_request_body_too_large_with_no_cl_http11_connclose(self): body = "a" * self.toobig to_send = "GET / HTTP/1.1\r\nConnection: close\r\n\r\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_no_cl_http11_connclose(self): def test_request_body_too_large_chunked_encoding(self): control_line = "20;\r\n" # 20 hex = 32 dec s = "This string has 32 characters.\r\n" to_send = "GET / HTTP/1.1\nTransfer-Encoding: chunked\n\n" repeat = control_...
def test_request_body_too_large_with_no_cl_http11_connclose(self): def test_request_body_too_large_chunked_encoding(self): control_line = "20;\r\n" # 20 hex = 32 dec s = "This string has 32 characters.\r\n" to_send = "GET / HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n" repeat = co...
def tearDown(self): self.stop_subprocess() def test_before_start_response_http_10(self): to_send = "GET /before_start_response HTTP/1.0\n\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def tearDown(self): self.stop_subprocess() def test_before_start_response_http_10(self): to_send = "GET /before_start_response HTTP/1.0\r\n\r\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_before_start_response_http_10(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_before_start_response_http_11(self): to_send = "GET /before_start_response HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_before_start_response_http_10(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_before_start_response_http_11(self): to_send = "GET /before_start_response HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_before_start_response_http_11(self): self.assertEqual(cl, len(response_body)) self.assertTrue(response_body.startswith(b"Internal Server Error")) self.assertEqual( sorted(headers.keys()), ["content-length", "content-type", "date", "server"] ) # connection has...
def test_before_start_response_http_11(self): self.assertEqual(cl, len(response_body)) self.assertTrue(response_body.startswith(b"Internal Server Error")) self.assertEqual( sorted(headers.keys()), ["connection", "content-length", "content-type", "date", "server"] ) # ...
def test_before_start_response_http_11(self): def test_before_start_response_http_11_close(self): to_send = tobytes( "GET /before_start_response HTTP/1.1\n" "Connection: close\n\n" ) self.connect() self.sock.send(to_send)
def test_before_start_response_http_11(self): def test_before_start_response_http_11_close(self): to_send = tobytes( "GET /before_start_response HTTP/1.1\r\nConnection: close\r\n\r\n" ) self.connect() self.sock.send(to_send)
def test_before_start_response_http_11_close(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_after_start_response_http10(self): to_send = "GET /after_start_response HTTP/1.0\n\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_before_start_response_http_11_close(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_after_start_response_http10(self): to_send = "GET /after_start_response HTTP/1.0\r\n\r\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_after_start_response_http10(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_after_start_response_http11(self): to_send = "GET /after_start_response HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_after_start_response_http10(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_after_start_response_http11(self): to_send = "GET /after_start_response HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_after_start_response_http11(self): self.assertEqual(cl, len(response_body)) self.assertTrue(response_body.startswith(b"Internal Server Error")) self.assertEqual( sorted(headers.keys()), ["content-length", "content-type", "date", "server"] ) # connection has b...
def test_after_start_response_http11(self): self.assertEqual(cl, len(response_body)) self.assertTrue(response_body.startswith(b"Internal Server Error")) self.assertEqual( sorted(headers.keys()), ["connection", "content-length", "content-type", "date", "server"] ) # co...
def test_after_start_response_http11(self): def test_after_start_response_http11_close(self): to_send = tobytes( "GET /after_start_response HTTP/1.1\n" "Connection: close\n\n" ) self.connect() self.sock.send(to_send)
def test_after_start_response_http11(self): def test_after_start_response_http11_close(self): to_send = tobytes( "GET /after_start_response HTTP/1.1\r\nConnection: close\r\n\r\n" ) self.connect() self.sock.send(to_send)
def test_after_start_response_http11_close(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_after_write_cb(self): to_send = "GET /after_write_cb HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_after_start_response_http11_close(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_after_write_cb(self): to_send = "GET /after_write_cb HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_after_write_cb(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_in_generator(self): to_send = "GET /in_generator HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_after_write_cb(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_in_generator(self): to_send = "GET /in_generator HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def tearDown(self): self.stop_subprocess() def test_filelike_http11(self): to_send = "GET /filelike HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect()
def tearDown(self): self.stop_subprocess() def test_filelike_http11(self): to_send = "GET /filelike HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect()
def test_filelike_http11(self): # connection has not been closed def test_filelike_nocl_http11(self): to_send = "GET /filelike_nocl HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect()
def test_filelike_http11(self): # connection has not been closed def test_filelike_nocl_http11(self): to_send = "GET /filelike_nocl HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect()
def test_filelike_nocl_http11(self): # connection has not been closed def test_filelike_shortcl_http11(self): to_send = "GET /filelike_shortcl HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect()
def test_filelike_nocl_http11(self): # connection has not been closed def test_filelike_shortcl_http11(self): to_send = "GET /filelike_shortcl HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect()
def test_filelike_shortcl_http11(self): # connection has not been closed def test_filelike_longcl_http11(self): to_send = "GET /filelike_longcl HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect()
def test_filelike_shortcl_http11(self): # connection has not been closed def test_filelike_longcl_http11(self): to_send = "GET /filelike_longcl HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect()
def test_filelike_longcl_http11(self): # connection has not been closed def test_notfilelike_http11(self): to_send = "GET /notfilelike HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect()
def test_filelike_longcl_http11(self): # connection has not been closed def test_notfilelike_http11(self): to_send = "GET /notfilelike HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect()