Commit 243c9882 authored by Wandenberg Peixoto's avatar Wandenberg Peixoto Committed by Wandenberg

adding tests to use keep alive in subscribers connection

parent 57127bb9
......@@ -53,4 +53,25 @@ describe "Keepalive" do
socket.close
end
end
it "should accept subscribe many times using the same socket" do
channel = 'ch_test_subscribe_with_keepalive'
body_prefix = 'message to be sent'
get_messages = "GET /sub/#{channel} HTTP/1.1\r\nHost: test\r\n\r\n"
nginx_run_server(config.merge(:store_messages => 'off', :subscriber_mode => 'long-polling'), :timeout => 5) do |conf|
socket = open_socket(nginx_host, nginx_port)
socket_pub = open_socket(nginx_host, nginx_port)
1.upto(500) do |j|
socket.print(get_messages)
post_in_socket("/pub?id=#{channel}", "#{body_prefix} #{j.to_s.rjust(3, '0')}", socket_pub, "}\r\n")
headers, body = read_response_on_socket(socket, "\r\n0\r\n\r\n")
body.should eql("18\r\nmessage to be sent #{j.to_s.rjust(3, '0')}\r\n\r\n0\r\n\r\n")
end
socket.close
socket_pub.close
end
end
end
......@@ -59,6 +59,8 @@ ngx_http_push_stream_subscriber_handler(ngx_http_request_t *r)
ngx_http_push_stream_add_response_header(r, &NGX_HTTP_PUSH_STREAM_HEADER_ACCESS_CONTROL_ALLOW_HEADERS, &NGX_HTTP_PUSH_STREAM_ALLOWED_HEADERS);
}
r->keepalive = cf->keepalive;
if (r->method & NGX_HTTP_OPTIONS) {
return ngx_http_push_stream_send_only_header_response(r, NGX_HTTP_OK, NULL);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment