summaryrefslogtreecommitdiffhomepage
path: root/test/unit/http.py
diff options
context:
space:
mode:
authorAndrei Belov <defan@nginx.com>2019-11-14 19:29:00 +0300
committerAndrei Belov <defan@nginx.com>2019-11-14 19:29:00 +0300
commit7630539c44fcb188bba03a65af34e952a81f2f38 (patch)
tree2c80f0cd315cae8079a39ba98ed89e02b5e1931a /test/unit/http.py
parent70c9f18b6e8b25850bce8eb1edba4d100c3e55d2 (diff)
parent0a27f137de776925a24406cf6961c550824c63a0 (diff)
downloadunit-1.13.0-1.tar.gz
unit-1.13.0-1.tar.bz2
Merged with the default branch.1.13.0-1
Diffstat (limited to 'test/unit/http.py')
-rw-r--r--test/unit/http.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/test/unit/http.py b/test/unit/http.py
index 82a6bd6a..c7e3e36d 100644
--- a/test/unit/http.py
+++ b/test/unit/http.py
@@ -1,4 +1,5 @@
import re
+import time
import socket
import select
from unit.main import TestUnit
@@ -63,7 +64,7 @@ class TestHTTP(TestUnit):
if 'raw' not in kwargs:
req = ' '.join([start_str, url, http]) + crlf
- if body is not b'':
+ if body != b'':
if isinstance(body, str):
body = body.encode()
@@ -178,3 +179,20 @@ class TestHTTP(TestUnit):
headers[m.group(1)] = [headers[m.group(1)], m.group(2)]
return {'status': int(status), 'headers': headers, 'body': body}
+
+ def waitforsocket(self, port):
+ ret = False
+
+ for i in range(50):
+ try:
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.connect(('127.0.0.1', port))
+ ret = True
+ break
+ except:
+ sock.close()
+ time.sleep(0.1)
+
+ sock.close()
+
+ self.assertTrue(ret, 'socket connected')