aboutsummaryrefslogtreecommitdiffstats
path: root/test.py
diff options
context:
space:
mode:
authoripknHama <ipknhama@gmail.com>2014-07-29 20:20:50 +0900
committeripknHama <ipknhama@gmail.com>2014-07-29 20:20:50 +0900
commitb7781b20ff8675ca0c860b017f3c3e7817b6eb37 (patch)
tree34685a9625b07406260417c9aee34ed127e80ccb /test.py
parent404b0b966ee85ffab87383610d48310e3ef6c537 (diff)
downloadcrow-b7781b20ff8675ca0c860b017f3c3e7817b6eb37.tar.gz
crow-b7781b20ff8675ca0c860b017f3c3e7817b6eb37.zip
Add HTTP/1.1 persistent connection timeout
manage Connection object life cycle using shared_ptr
Diffstat (limited to 'test.py')
-rw-r--r--test.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/test.py b/test.py
index 357d2d3..09d7a42 100644
--- a/test.py
+++ b/test.py
@@ -6,3 +6,22 @@ assert "3 bottles of beer!" == urllib.urlopen('http://localhost:18080/hello/3').
assert "100 bottles of beer!" == urllib.urlopen('http://localhost:18080/hello/100').read()
assert 400 == urllib.urlopen('http://localhost:18080/hello/500').getcode()
assert "3" == urllib.urlopen('http://localhost:18080/add_json', data='{"a":1,"b":2}').read()
+
+# test persistent connection
+import socket
+import time
+s = socket.socket()
+s.connect(('localhost', 18080))
+for i in xrange(10):
+ s.send('''GET / HTTP/1.1
+Host: localhost\r\n\r\n''');
+ assert 'Hello World!' in s.recv(1024)
+
+# test timeout
+s = socket.socket()
+s.connect(('localhost', 18080))
+print 'ERROR REQUEST'
+s.send('''GET / HTTP/1.1
+hHhHHefhwjkefhklwejfklwejf
+''')
+print s.recv(1024)