summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMikhail Galanin <mgalanin@mimecast.com>2018-08-31 10:12:36 +0100
committerMikhail Galanin <mgalanin@mimecast.com>2018-08-31 10:12:36 +0100
commitee6aa02264fe5d86d3f5da228bb14cad13840071 (patch)
tree263d8161820d1170a30fe7628665c7f19d1d6946 /test
parentbad44f28f5b25218d92619cca8e2d54559e3ec31 (diff)
downloadrspamd-ee6aa02264fe5d86d3f5da228bb14cad13840071.tar.gz
rspamd-ee6aa02264fe5d86d3f5da228bb14cad13840071.zip
[Test] Read the whole response from dummy http
Diffstat (limited to 'test')
-rw-r--r--test/functional/lua/tcp.lua47
1 files changed, 33 insertions, 14 deletions
diff --git a/test/functional/lua/tcp.lua b/test/functional/lua/tcp.lua
index 5b0f474bc..21bb0c6e7 100644
--- a/test/functional/lua/tcp.lua
+++ b/test/functional/lua/tcp.lua
@@ -54,25 +54,44 @@ local function http_simple_tcp_symbol(task)
end
local data
- is_ok, data = connection:read_once();
+ local got_content = ''
+ repeat
+ is_ok, data = connection:read_once();
+ logger.errx(task, 'read_once: is_ok: %1, data: %2', is_ok, data)
+ if not is_ok then
+ task:insert_result('HTTP_SYNC_ERROR', 1.0, data)
+ return
+ else
+ got_content = got_content .. data
+ end
+ if got_content:find('hello') then
+ -- dummy_http.py responds with either hello world or hello post
+ break
+ end
+ until false
- logger.errx(task, 'read_once: is_ok: %1, data: %2', is_ok, data)
- if not is_ok then
- task:insert_result('HTTP_SYNC_ERROR', 1.0, data)
- else
- task:insert_result('HTTP_SYNC_RESPONSE', 1.0, data)
- end
+ task:insert_result('HTTP_SYNC_RESPONSE', 1.0, got_content)
is_ok, err = connection:write("POST /request2 HTTP/1.1\r\n\r\n")
logger.errx(task, 'write[2] %1, %2', is_ok, err)
- is_ok, data = connection:read_once();
- logger.errx(task, 'read_once[2]: is_ok %1, data: %2', is_ok, data)
- if not is_ok then
- task:insert_result('HTTP_SYNC_ERROR_2', 1.0, data)
- else
- task:insert_result('HTTP_SYNC_RESPONSE_2', 1.0, data)
- end
+ got_content = ''
+ repeat
+ is_ok, data = connection:read_once();
+ logger.errx(task, 'read_once[2]: is_ok %1, data: %2', is_ok, data)
+ if not is_ok then
+ task:insert_result('HTTP_SYNC_ERROR_2', 1.0, data)
+ return
+ else
+ got_content = got_content .. data
+ end
+ if got_content:find('hello') then
+ -- dummy_http.py responds with either hello world or hello post
+ break
+ end
+ until false
+
+ task:insert_result('HTTP_SYNC_RESPONSE_2', 1.0, data)
connection:close()
end