def test_007_get_arg(self):
# define a new handler that does a get_arg as well as a read_body
def new_app(env, start_response):
body = bytes_to_str(env['wsgi.input'].read())
a = cgi.parse_qs(body).get('a', [1])[0]
start_response('200 OK', [('Content-type', 'text/plain')])
return [six.b('a is %s, body is %s' % (a, body))]
self.site.application = new_app
sock = eventlet.connect(self.server_addr)
request = b'\r\n'.join((
b'POST / HTTP/1.0',
b'Host: localhost',
b'Content-Length: 3',
b'',
b'a=a'))
sock.sendall(request)
# send some junk after the actual request
sock.sendall(b'01234567890123456789')
result = read_http(sock)
self.assertEqual(result.body, b'a is a, body is a=a')
评论列表
文章目录