Commit b98f25ef authored by Wandenberg Peixoto's avatar Wandenberg Peixoto

rertuning only header when sending response 304 for long polling connections

parent 19398213
......@@ -27,6 +27,6 @@
#define NGX_HTTP_PUSH_STREAM_MODULE_VERSION_H_
static const ngx_str_t NGX_HTTP_PUSH_STREAM_TAG = ngx_string("0.3.3");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_COMMIT = ngx_string("f6cf36f7d03be43f59d8f9d14b0f332d1ff7f3db");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_COMMIT = ngx_string("d0fe86d4193ffd6797a3fa63011d511b45dde97c");
#endif /* NGX_HTTP_PUSH_STREAM_MODULE_VERSION_H_ */
......@@ -395,6 +395,7 @@ ngx_http_push_stream_respond_to_subscribers(ngx_http_push_stream_channel_t *chan
if (subscriber->longpolling) {
ngx_http_push_stream_queue_elem_t *prev = (ngx_http_push_stream_queue_elem_t *) ngx_queue_prev(&cur->queue);
ngx_http_push_stream_add_response_header(subscriber->request, &NGX_HTTP_PUSH_STREAM_HEADER_TRANSFER_ENCODING, &NGX_HTTP_PUSH_STREAM_HEADER_CHUNCKED);
ngx_http_push_stream_add_polling_headers(subscriber->request, msg->time, msg->tag, subscriber->request->pool);
ngx_http_send_header(subscriber->request);
......
......@@ -217,7 +217,6 @@ ngx_http_push_stream_subscriber_polling_handler(ngx_http_request_t *r, ngx_http_
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
worker_subscriber->longpolling = 1;
ngx_http_push_stream_add_response_header(r, &NGX_HTTP_PUSH_STREAM_HEADER_TRANSFER_ENCODING, &NGX_HTTP_PUSH_STREAM_HEADER_CHUNCKED);
if (ngx_http_push_stream_registry_subscriber_locked(r, worker_subscriber) == NGX_ERROR) {
ngx_shmtx_unlock(&shpool->mutex);
......
......@@ -104,6 +104,7 @@ ngx_http_push_stream_delete_unrecoverable_channels(ngx_http_push_stream_shm_data
ngx_shmtx_unlock(&shpool->mutex);
if (subscriber->longpolling) {
ngx_http_push_stream_add_response_header(subscriber->request, &NGX_HTTP_PUSH_STREAM_HEADER_TRANSFER_ENCODING, &NGX_HTTP_PUSH_STREAM_HEADER_CHUNCKED);
ngx_http_push_stream_add_polling_headers(subscriber->request, ngx_time(), 0, subscriber->request->pool);
ngx_http_send_header(subscriber->request);
......@@ -646,10 +647,7 @@ ngx_http_push_stream_send_response_finalize_for_longpolling_by_timeout(ngx_http_
ngx_http_push_stream_run_cleanup_pool_handler(r->pool, (ngx_pool_cleanup_pt) ngx_http_push_stream_cleanup_request_context);
ngx_http_push_stream_add_polling_headers(r, ngx_time(), 0, r->pool);
r->headers_out.status = NGX_HTTP_NOT_MODIFIED;
ngx_http_send_header(r);
ngx_http_push_stream_send_response_text(r, NGX_HTTP_PUSH_STREAM_LAST_CHUNK.data, NGX_HTTP_PUSH_STREAM_LAST_CHUNK.len, 1);
ngx_http_push_stream_send_only_header_response(r, NGX_HTTP_NOT_MODIFIED, NULL);
ngx_http_finalize_request(r, NGX_DONE);
}
......
......@@ -333,7 +333,7 @@ class TestSubscriberLongPolling < Test::Unit::TestCase
assert_equal(304, sub.response_header.status, "Wrong status")
assert_equal(Time.now.utc.strftime("%a, %d %b %Y %T %Z"), sub.response_header['LAST_MODIFIED'].to_s, "Wrong header")
assert_equal("0", sub.response_header['ETAG'].to_s, "Wrong header")
assert_equal("", sub.response, "Wrong header")
assert_equal(0, sub.response_header.content_length, "Wrong response")
EventMachine.stop
}
......@@ -360,7 +360,7 @@ class TestSubscriberLongPolling < Test::Unit::TestCase
assert_equal(304, sub.response_header.status, "Wrong status")
assert_equal(Time.now.utc.strftime("%a, %d %b %Y %T %Z"), sub.response_header['LAST_MODIFIED'].to_s, "Wrong header")
assert_equal("0", sub.response_header['ETAG'].to_s, "Wrong header")
assert_equal("", sub.response, "Wrong header")
assert_equal(0, sub.response_header.content_length, "Wrong response")
EventMachine.stop
}
......@@ -386,7 +386,7 @@ class TestSubscriberLongPolling < Test::Unit::TestCase
assert_equal(304, sub.response_header.status, "Wrong status")
assert_equal(Time.now.utc.strftime("%a, %d %b %Y %T %Z"), sub.response_header['LAST_MODIFIED'].to_s, "Wrong header")
assert_equal("0", sub.response_header['ETAG'].to_s, "Wrong header")
assert_equal("", sub.response, "Wrong header")
assert_equal(0, sub.response_header.content_length, "Wrong response")
EventMachine.stop
}
......@@ -406,7 +406,7 @@ class TestSubscriberLongPolling < Test::Unit::TestCase
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :timeout => 30
sub.callback {
assert_equal(304, sub.response_header.status, "Wrong status")
assert_equal("", sub.response, "Wrong header")
assert_equal(0, sub.response_header.content_length, "Wrong response")
EventMachine.stop
}
......
......@@ -22,6 +22,7 @@ class TestSubscriberPolling < Test::Unit::TestCase
assert_equal(304, sub_1.response_header.status, "Wrong status")
assert_equal("", sub_1.response_header['LAST_MODIFIED'].to_s, "Wrong header")
assert_equal("", sub_1.response_header['ETAG'].to_s, "Wrong header")
assert_equal(0, sub_1.response_header.content_length, "Wrong response")
EventMachine.stop
}
......@@ -41,6 +42,7 @@ class TestSubscriberPolling < Test::Unit::TestCase
assert_equal(304, sub_1.response_header.status, "Wrong status")
assert_equal(headers['If-Modified-Since'], sub_1.response_header['LAST_MODIFIED'].to_s, "Wrong header")
assert_equal(headers['If-None-Match'], sub_1.response_header['ETAG'].to_s, "Wrong header")
assert_equal(0, sub_1.response_header.content_length, "Wrong response")
EventMachine.stop
}
......@@ -88,6 +90,7 @@ class TestSubscriberPolling < Test::Unit::TestCase
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers, :timeout => 30
sub_2.callback {
assert_equal(304, sub_2.response_header.status, "Wrong status")
assert_equal(0, sub_2.response_header.content_length, "Wrong response")
assert_equal(sub_1.response_header['LAST_MODIFIED'], sub_2.response_header['LAST_MODIFIED'].to_s, "Wrong header")
assert_equal(sub_1.response_header['ETAG'], sub_2.response_header['ETAG'].to_s, "Wrong header")
......@@ -132,6 +135,7 @@ class TestSubscriberPolling < Test::Unit::TestCase
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers, :timeout => 30
sub_2.callback {
assert_equal(304, sub_2.response_header.status, "Wrong status")
assert_equal(0, sub_2.response_header.content_length, "Wrong response")
assert_equal(sub_1.response_header['LAST_MODIFIED'], sub_2.response_header['LAST_MODIFIED'].to_s, "Wrong header")
assert_equal(sub_1.response_header['ETAG'], sub_2.response_header['ETAG'].to_s, "Wrong header")
......@@ -177,6 +181,7 @@ class TestSubscriberPolling < Test::Unit::TestCase
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers, :timeout => 30
sub_2.callback {
assert_equal(304, sub_2.response_header.status, "Wrong status")
assert_equal(0, sub_2.response_header.content_length, "Wrong response")
assert_equal(sub_1.response_header['LAST_MODIFIED'], sub_2.response_header['LAST_MODIFIED'].to_s, "Wrong header")
assert_equal(sub_1.response_header['ETAG'], sub_2.response_header['ETAG'].to_s, "Wrong header")
......@@ -221,6 +226,7 @@ class TestSubscriberPolling < Test::Unit::TestCase
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_2.to_s + '/' + channel_1.to_s).get :head => headers, :timeout => 30
sub_2.callback {
assert_equal(304, sub_2.response_header.status, "Wrong status")
assert_equal(0, sub_2.response_header.content_length, "Wrong response")
assert_equal(sub_1.response_header['LAST_MODIFIED'], sub_2.response_header['LAST_MODIFIED'].to_s, "Wrong header")
assert_equal(sub_1.response_header['ETAG'], sub_2.response_header['ETAG'].to_s, "Wrong header")
......@@ -239,6 +245,7 @@ class TestSubscriberPolling < Test::Unit::TestCase
sub_4 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_2.to_s + '/' + channel_1.to_s).get :head => headers, :timeout => 30
sub_4.callback {
assert_equal(304, sub_4.response_header.status, "Wrong status")
assert_equal(0, sub_4.response_header.content_length, "Wrong response")
assert_equal(sub_3.response_header['LAST_MODIFIED'], sub_4.response_header['LAST_MODIFIED'].to_s, "Wrong header")
assert_equal(sub_3.response_header['ETAG'], sub_4.response_header['ETAG'].to_s, "Wrong header")
......@@ -279,6 +286,7 @@ class TestSubscriberPolling < Test::Unit::TestCase
assert_equal(304, sub_1.response_header.status, "Wrong status")
assert_equal("", sub_1.response_header['LAST_MODIFIED'].to_s, "Wrong header")
assert_equal("", sub_1.response_header['ETAG'].to_s, "Wrong header")
assert_equal(0, sub_1.response_header.content_length, "Wrong response")
EventMachine.stop
}
......@@ -302,6 +310,7 @@ class TestSubscriberPolling < Test::Unit::TestCase
assert_equal(304, sub_1.response_header.status, "Wrong status")
assert_equal(headers['If-Modified-Since'], sub_1.response_header['LAST_MODIFIED'].to_s, "Wrong header")
assert_equal(headers['If-None-Match'], sub_1.response_header['ETAG'].to_s, "Wrong header")
assert_equal(0, sub_1.response_header.content_length, "Wrong response")
EventMachine.stop
}
......@@ -357,6 +366,7 @@ class TestSubscriberPolling < Test::Unit::TestCase
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers, :timeout => 30
sub_2.callback {
assert_equal(304, sub_2.response_header.status, "Wrong status")
assert_equal(0, sub_2.response_header.content_length, "Wrong response")
assert_equal(sub_1.response_header['LAST_MODIFIED'], sub_2.response_header['LAST_MODIFIED'].to_s, "Wrong header")
assert_equal(sub_1.response_header['ETAG'], sub_2.response_header['ETAG'].to_s, "Wrong header")
......@@ -405,6 +415,7 @@ class TestSubscriberPolling < Test::Unit::TestCase
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers, :timeout => 30
sub_2.callback {
assert_equal(304, sub_2.response_header.status, "Wrong status")
assert_equal(0, sub_2.response_header.content_length, "Wrong response")
assert_equal(sub_1.response_header['LAST_MODIFIED'], sub_2.response_header['LAST_MODIFIED'].to_s, "Wrong header")
assert_equal(sub_1.response_header['ETAG'], sub_2.response_header['ETAG'].to_s, "Wrong header")
......@@ -454,6 +465,7 @@ class TestSubscriberPolling < Test::Unit::TestCase
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers, :timeout => 30
sub_2.callback {
assert_equal(304, sub_2.response_header.status, "Wrong status")
assert_equal(0, sub_2.response_header.content_length, "Wrong response")
assert_equal(sub_1.response_header['LAST_MODIFIED'], sub_2.response_header['LAST_MODIFIED'].to_s, "Wrong header")
assert_equal(sub_1.response_header['ETAG'], sub_2.response_header['ETAG'].to_s, "Wrong header")
......@@ -502,6 +514,7 @@ class TestSubscriberPolling < Test::Unit::TestCase
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_2.to_s + '/' + channel_1.to_s).get :head => headers, :timeout => 30
sub_2.callback {
assert_equal(304, sub_2.response_header.status, "Wrong status")
assert_equal(0, sub_2.response_header.content_length, "Wrong response")
assert_equal(sub_1.response_header['LAST_MODIFIED'], sub_2.response_header['LAST_MODIFIED'].to_s, "Wrong header")
assert_equal(sub_1.response_header['ETAG'], sub_2.response_header['ETAG'].to_s, "Wrong header")
......@@ -520,6 +533,7 @@ class TestSubscriberPolling < Test::Unit::TestCase
sub_4 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_2.to_s + '/' + channel_1.to_s).get :head => headers, :timeout => 30
sub_4.callback {
assert_equal(304, sub_4.response_header.status, "Wrong status")
assert_equal(0, sub_4.response_header.content_length, "Wrong response")
assert_equal(sub_3.response_header['LAST_MODIFIED'], sub_4.response_header['LAST_MODIFIED'].to_s, "Wrong header")
assert_equal(sub_3.response_header['ETAG'], sub_4.response_header['ETAG'].to_s, "Wrong header")
......
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