Lines Matching defs:body
160 body = 'spamspamspam'
163 headers[header] = str(len(body))
164 conn.request('POST', '/', body, headers)
179 # Here, we're testing that methods expecting a body get a
180 # content-length set to zero if the body is empty (either None or '')
183 for method, body in itertools.product(methods_with_body, bodies):
187 conn.request(method, '/', body)
194 # the body is None because it might cause unexpected behaviour on the
206 'Header Content-Length set for empty body on {}'.format(method)
209 # If the body is set to '', that's considered to be "present but
211 # for methods that don't expect a body.
222 # If the body is set, make sure Content-Length is set.
288 body = "HTTP/1.1 200 OK\r\nFirst: val\r\n: nval\r\nSecond: val\r\n\r\n"
289 sock = FakeSocket(body)
298 body = (
309 sock = FakeSocket(body)
357 body = (
363 sock = FakeSocket(body)
405 _, _, body = self._parse_request(conn.sock.data)
406 body = self._parse_chunked(body)
407 self.assertEqual(body, self.expected_body)
418 _, headers, body = self._parse_request(conn.sock.data)
421 self.assertEqual(body, self.expected_body)
423 # explicit chunked, string body
430 _, headers, body = self._parse_request(conn.sock.data)
433 self.assertEqual(body, self.expected_body)
441 body=self._make_body())
442 _, headers, body = self._parse_request(conn.sock.data)
445 self.assertEqual(self._parse_chunked(body), self.expected_body)
454 _, headers, body = self._parse_request(conn.sock.data)
455 body = self._parse_chunked(body)
456 self.assertEqual(body, self.expected_body)
468 _, headers, body = self._parse_request(conn.sock.data)
471 self.assertEqual(body, b"0\r\n\r\n")
498 body = []
502 # parse body
512 body.append(chunk)
521 return b''.join(body)
622 'Entity body in unsupported format')
676 body = "HTTP/1.1 200 Ok\r\n\r\nText"
677 sock = FakeSocket(body)
689 body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText"
690 sock = FakeSocket(body)
701 body = "HTTP/1.1 200 Ok\r\nContent-Length: 4\r\n\r\nText"
702 sock = FakeSocket(body)
716 body = "HTTP/1.1 200 Ok\r\nContent-Length: 13\r\n\r\nText\r\nAnother"
717 sock = FakeSocket(body)
731 body = "HTTP/1.1 200 Ok\r\nContent-Length: 4\r\n\r\nText"
732 sock = FakeSocket(body)
750 body = "HTTP/1.1 200 Ok\r\nContent-Length: 4\r\n\r\nText"
751 sock = FakeSocket(body)
762 body = "HTTP/1.1 200 Ok\r\nContent-Length: 4\r\n\r\nText"
763 sock = FakeSocket(body)
778 body = "HTTP/1.1 200 Ok\r\n\r\nText"
779 sock = FakeSocket(body)
794 body = "HTTP/1.1 200 Ok\r\n\r\nText"
795 sock = FakeSocket(body)
813 body = "HTTP/1.1 200 Ok\r\nContent-Length: 10\r\n\r\nText"
814 sock = FakeSocket(body)
826 body = "HTTP/1.1 200 Ok\r\nContent-Length: 10\r\n\r\nText"
827 sock = FakeSocket(body)
870 'No body\r\n')
923 with open(__file__, 'rb') as body:
925 sock = FakeSocket(body)
927 conn.request('GET', '/foo', body)
971 def body():
979 conn.request('GET', '/foo', body(), {'Content-Length': '11'})
991 body = sock.data.split(b"\r\n\r\n", 1)[1]
992 self.assertEqual(body, expected)
1163 lambda: conn.request("PUT", "/url", "body"))
1172 body = "HTTP/1.1 200 Ok" + "k" * 65536 + "\r\n"
1173 resp = client.HTTPResponse(FakeSocket(body))
1177 body = (
1181 resp = client.HTTPResponse(FakeSocket(body))
1185 body = (
1189 resp = client.HTTPResponse(FakeSocket(body))
1198 body = (
1206 resp = client.HTTPResponse(FakeSocket(body))
1212 body = "HTTP/1.1 200 Ok"
1213 sock = FakeSocket(body)
1776 'Dummy body\r\n'
2033 """Test cases where a request includes a message body."""
2054 for body, expected in cases:
2055 with self.subTest(body):
2059 self.conn.request('PUT', '/url', body)
2069 self.conn.request("PUT", "/url", "body",
2076 self.conn.request("PUT", "/url", "body")
2081 self.assertEqual(b'body', f.read())
2084 self.conn.request("PUT", "/url", "body\xc1")
2089 self.assertEqual(b'body\xc1', f.read())
2092 self.conn.request("PUT", "/url", b"body\xc1")
2097 self.assertEqual(b'body\xc1', f.read())
2102 f.write("body")
2108 # No content-length will be determined for files; the body
2117 f.write(b"body\xc1")
2131 body = "HTTP/1.1 200 Ok\r\nMy-Header: first-value\r\nMy-Header: \
2133 sock = FakeSocket(body)