Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nginx-push-stream-module
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
nginx-push-stream-module
Commits
b98f25ef
Commit
b98f25ef
authored
Apr 28, 2012
by
Wandenberg Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rertuning only header when sending response 304 for long polling connections
parent
19398213
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
10 deletions
+22
-10
ngx_http_push_stream_module_version.h
include/ngx_http_push_stream_module_version.h
+1
-1
ngx_http_push_stream_module_ipc.c
src/ngx_http_push_stream_module_ipc.c
+1
-0
ngx_http_push_stream_module_subscriber.c
src/ngx_http_push_stream_module_subscriber.c
+0
-1
ngx_http_push_stream_module_utils.c
src/ngx_http_push_stream_module_utils.c
+2
-4
test_subscriber_long_polling.rb
test/test_subscriber_long_polling.rb
+4
-4
test_subscriber_polling.rb
test/test_subscriber_polling.rb
+14
-0
No files found.
include/ngx_http_push_stream_module_version.h
View file @
b98f25ef
...
...
@@ -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_ */
src/ngx_http_push_stream_module_ipc.c
View file @
b98f25ef
...
...
@@ -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
);
...
...
src/ngx_http_push_stream_module_subscriber.c
View file @
b98f25ef
...
...
@@ -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
);
...
...
src/ngx_http_push_stream_module_utils.c
View file @
b98f25ef
...
...
@@ -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
);
}
...
...
test/test_subscriber_long_polling.rb
View file @
b98f25ef
...
...
@@ -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
}
...
...
test/test_subscriber_polling.rb
View file @
b98f25ef
...
...
@@ -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"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment