mirror of
https://github.com/moparisthebest/curl
synced 2025-02-28 17:31:46 -05:00
tests/http_pipe.py: Python 3 support
The 2to3 tool converted socketserver (which I manually fixed up with an import fallback) and the print(e) line. The xrange option was converted to range, but it seems better to use the '*' operator here for simplicity. Signed-off-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
parent
c6c22aeb44
commit
87a3a924ce
@ -17,7 +17,10 @@
|
|||||||
# Modified by Linus Nielsen Feltzing for inclusion in the libcurl test
|
# Modified by Linus Nielsen Feltzing for inclusion in the libcurl test
|
||||||
# framework
|
# framework
|
||||||
#
|
#
|
||||||
import SocketServer
|
try:
|
||||||
|
import socketserver
|
||||||
|
except:
|
||||||
|
import SocketServer as socketserver
|
||||||
import argparse
|
import argparse
|
||||||
import re
|
import re
|
||||||
import select
|
import select
|
||||||
@ -251,24 +254,21 @@ class ResponseBuilder(object):
|
|||||||
self._processed_end = True
|
self._processed_end = True
|
||||||
|
|
||||||
elif path == '/1k.txt':
|
elif path == '/1k.txt':
|
||||||
str = '0123456789abcdef'
|
body = '0123456789abcdef' * 64
|
||||||
body = ''.join([str for num in xrange(64)])
|
|
||||||
result += self._BuildResponse(
|
result += self._BuildResponse(
|
||||||
'200 OK', ['Server: Apache',
|
'200 OK', ['Server: Apache',
|
||||||
'Content-Length: 1024',
|
'Content-Length: 1024',
|
||||||
'Cache-Control: max-age=60'], body)
|
'Cache-Control: max-age=60'], body)
|
||||||
|
|
||||||
elif path == '/10k.txt':
|
elif path == '/10k.txt':
|
||||||
str = '0123456789abcdef'
|
body = '0123456789abcdef' * 640
|
||||||
body = ''.join([str for num in xrange(640)])
|
|
||||||
result += self._BuildResponse(
|
result += self._BuildResponse(
|
||||||
'200 OK', ['Server: Apache',
|
'200 OK', ['Server: Apache',
|
||||||
'Content-Length: 10240',
|
'Content-Length: 10240',
|
||||||
'Cache-Control: max-age=60'], body)
|
'Cache-Control: max-age=60'], body)
|
||||||
|
|
||||||
elif path == '/100k.txt':
|
elif path == '/100k.txt':
|
||||||
str = '0123456789abcdef'
|
body = '0123456789abcdef' * 6400
|
||||||
body = ''.join([str for num in xrange(6400)])
|
|
||||||
result += self._BuildResponse(
|
result += self._BuildResponse(
|
||||||
'200 OK',
|
'200 OK',
|
||||||
['Server: Apache',
|
['Server: Apache',
|
||||||
@ -277,9 +277,7 @@ class ResponseBuilder(object):
|
|||||||
body)
|
body)
|
||||||
|
|
||||||
elif path == '/100k_chunked.txt':
|
elif path == '/100k_chunked.txt':
|
||||||
str = '0123456789abcdef'
|
body = self.Chunkify('0123456789abcdef' * 6400, 20480)
|
||||||
moo = ''.join([str for num in xrange(6400)])
|
|
||||||
body = self.Chunkify(moo, 20480)
|
|
||||||
body.append('0\r\n\r\n')
|
body.append('0\r\n\r\n')
|
||||||
body = ''.join(body)
|
body = ''.join(body)
|
||||||
|
|
||||||
@ -337,7 +335,7 @@ class ResponseBuilder(object):
|
|||||||
'%s' % (status, '\r\n'.join(headers), body))
|
'%s' % (status, '\r\n'.join(headers), body))
|
||||||
|
|
||||||
|
|
||||||
class PipelineRequestHandler(SocketServer.BaseRequestHandler):
|
class PipelineRequestHandler(socketserver.BaseRequestHandler):
|
||||||
"""Called on an incoming TCP connection."""
|
"""Called on an incoming TCP connection."""
|
||||||
|
|
||||||
def _GetTimeUntilTimeout(self):
|
def _GetTimeUntilTimeout(self):
|
||||||
@ -407,11 +405,11 @@ class PipelineRequestHandler(SocketServer.BaseRequestHandler):
|
|||||||
self.request.send(self._response_builder.WriteError(
|
self.request.send(self._response_builder.WriteError(
|
||||||
'200 OK', INFO_MESSAGE))
|
'200 OK', INFO_MESSAGE))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print e
|
print(e)
|
||||||
self.request.close()
|
self.request.close()
|
||||||
|
|
||||||
|
|
||||||
class PipelineServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
|
class PipelineServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user