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
3da6cb0e
Commit
3da6cb0e
authored
Nov 29, 2015
by
Wandenberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert etag header on weak etag to work with the latests releases of nginx gzip filter
parent
b5db1acb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
12 deletions
+19
-12
long_polling_spec.rb
misc/spec/subscriber/long_polling_spec.rb
+6
-5
polling_spec.rb
misc/spec/subscriber/polling_spec.rb
+3
-2
receive_old_message_spec.rb
misc/spec/subscriber/receive_old_message_spec.rb
+3
-3
ngx_http_push_stream_module_utils.c
src/ngx_http_push_stream_module_utils.c
+7
-2
No files found.
misc/spec/subscriber/long_polling_spec.rb
View file @
3da6cb0e
...
@@ -72,7 +72,7 @@ describe "Subscriber Properties" do
...
@@ -72,7 +72,7 @@ describe "Subscriber Properties" do
expect
(
time_diff_sec
(
start
,
stop
)).
to
be_in_the_interval
(
10
,
10.5
)
expect
(
time_diff_sec
(
start
,
stop
)).
to
be_in_the_interval
(
10
,
10.5
)
expect
(
sub
).
to
be_http_status
(
304
).
without_body
expect
(
sub
).
to
be_http_status
(
304
).
without_body
expect
(
Time
.
parse
(
sub
.
response_header
[
'LAST_MODIFIED'
].
to_s
).
utc
.
to_i
).
to
be_in_the_interval
(
Time
.
now
.
utc
.
to_i
-
1
,
Time
.
now
.
utc
.
to_i
)
expect
(
Time
.
parse
(
sub
.
response_header
[
'LAST_MODIFIED'
].
to_s
).
utc
.
to_i
).
to
be_in_the_interval
(
Time
.
now
.
utc
.
to_i
-
1
,
Time
.
now
.
utc
.
to_i
)
expect
(
sub
.
response_header
[
'ETAG'
].
to_s
).
to
eql
(
"0"
)
expect
(
sub
.
response_header
[
'ETAG'
].
to_s
).
to
eql
(
"
W/
0"
)
EventMachine
.
stop
EventMachine
.
stop
end
end
end
end
...
@@ -91,7 +91,7 @@ describe "Subscriber Properties" do
...
@@ -91,7 +91,7 @@ describe "Subscriber Properties" do
expect
(
time_diff_sec
(
start
,
stop
)).
to
be_in_the_interval
(
5
,
5.5
)
expect
(
time_diff_sec
(
start
,
stop
)).
to
be_in_the_interval
(
5
,
5.5
)
expect
(
sub
).
to
be_http_status
(
304
).
without_body
expect
(
sub
).
to
be_http_status
(
304
).
without_body
expect
(
Time
.
parse
(
sub
.
response_header
[
'LAST_MODIFIED'
].
to_s
).
utc
.
to_i
).
to
be_in_the_interval
(
Time
.
now
.
utc
.
to_i
-
1
,
Time
.
now
.
utc
.
to_i
)
expect
(
Time
.
parse
(
sub
.
response_header
[
'LAST_MODIFIED'
].
to_s
).
utc
.
to_i
).
to
be_in_the_interval
(
Time
.
now
.
utc
.
to_i
-
1
,
Time
.
now
.
utc
.
to_i
)
expect
(
sub
.
response_header
[
'ETAG'
].
to_s
).
to
eql
(
"0"
)
expect
(
sub
.
response_header
[
'ETAG'
].
to_s
).
to
eql
(
"
W/
0"
)
EventMachine
.
stop
EventMachine
.
stop
end
end
end
end
...
@@ -110,7 +110,7 @@ describe "Subscriber Properties" do
...
@@ -110,7 +110,7 @@ describe "Subscriber Properties" do
expect
(
time_diff_sec
(
start
,
stop
)).
to
be_in_the_interval
(
3
,
3.5
)
expect
(
time_diff_sec
(
start
,
stop
)).
to
be_in_the_interval
(
3
,
3.5
)
expect
(
sub
).
to
be_http_status
(
304
).
without_body
expect
(
sub
).
to
be_http_status
(
304
).
without_body
expect
(
Time
.
parse
(
sub
.
response_header
[
'LAST_MODIFIED'
].
to_s
).
utc
.
to_i
).
to
be_in_the_interval
(
Time
.
now
.
utc
.
to_i
-
1
,
Time
.
now
.
utc
.
to_i
)
expect
(
Time
.
parse
(
sub
.
response_header
[
'LAST_MODIFIED'
].
to_s
).
utc
.
to_i
).
to
be_in_the_interval
(
Time
.
now
.
utc
.
to_i
-
1
,
Time
.
now
.
utc
.
to_i
)
expect
(
sub
.
response_header
[
'ETAG'
].
to_s
).
to
eql
(
"0"
)
expect
(
sub
.
response_header
[
'ETAG'
].
to_s
).
to
eql
(
"
W/
0"
)
EventMachine
.
stop
EventMachine
.
stop
end
end
end
end
...
@@ -153,7 +153,7 @@ describe "Subscriber Properties" do
...
@@ -153,7 +153,7 @@ describe "Subscriber Properties" do
expect
(
response
[
"tag"
]).
to
eql
(
"0"
)
expect
(
response
[
"tag"
]).
to
eql
(
"0"
)
expect
(
response
[
"time"
]).
to
eql
(
"Thu, 01 Jan 1970 00:00:00 GMT"
)
expect
(
response
[
"time"
]).
to
eql
(
"Thu, 01 Jan 1970 00:00:00 GMT"
)
expect
(
Time
.
parse
(
sub
.
response_header
[
'LAST_MODIFIED'
].
to_s
).
utc
.
to_i
).
to
be_in_the_interval
(
Time
.
now
.
utc
.
to_i
-
1
,
Time
.
now
.
utc
.
to_i
)
expect
(
Time
.
parse
(
sub
.
response_header
[
'LAST_MODIFIED'
].
to_s
).
utc
.
to_i
).
to
be_in_the_interval
(
Time
.
now
.
utc
.
to_i
-
1
,
Time
.
now
.
utc
.
to_i
)
expect
(
sub
.
response_header
[
'ETAG'
].
to_s
).
to
eql
(
"0"
)
expect
(
sub
.
response_header
[
'ETAG'
].
to_s
).
to
eql
(
"
W/
0"
)
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'?callback='
+
callback_function_name
).
get
:head
=>
headers
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'?callback='
+
callback_function_name
).
get
:head
=>
headers
sub_1
.
callback
do
sub_1
.
callback
do
...
@@ -183,7 +183,7 @@ describe "Subscriber Properties" do
...
@@ -183,7 +183,7 @@ describe "Subscriber Properties" do
expect
(
sub_2
).
to
be_http_status
(
200
)
expect
(
sub_2
).
to
be_http_status
(
200
)
response
=
JSON
.
parse
(
sub_2
.
response
)
response
=
JSON
.
parse
(
sub_2
.
response
)
expect
(
response
[
"channel"
]).
to
eql
(
channel_2
)
expect
(
response
[
"channel"
]).
to
eql
(
channel_2
)
expect
(
sub_2
.
response_header
[
'ETAG'
].
to_i
).
to
eql
(
sub_1
.
response_header
[
'ETAG'
]
.
to_i
+
1
)
expect
(
sub_2
.
response_header
[
'ETAG'
].
sub
(
"W/"
,
""
).
to_i
).
to
eql
(
sub_1
.
response_header
[
'ETAG'
].
sub
(
"W/"
,
""
)
.
to_i
+
1
)
EventMachine
.
stop
EventMachine
.
stop
end
end
...
@@ -357,6 +357,7 @@ describe "Subscriber Properties" do
...
@@ -357,6 +357,7 @@ describe "Subscriber Properties" do
sub_1
.
callback
do
sub_1
.
callback
do
expect
(
sub_1
).
to
be_http_status
(
200
)
expect
(
sub_1
).
to
be_http_status
(
200
)
expect
(
sub_1
.
response_header
[
"ETAG"
]).
to
match
(
/W\/\d+/
)
expect
(
sub_1
.
response_header
[
"CONTENT_ENCODING"
]).
to
eql
(
"gzip"
)
expect
(
sub_1
.
response_header
[
"CONTENT_ENCODING"
]).
to
eql
(
"gzip"
)
actual_response
=
Zlib
::
GzipReader
.
new
(
StringIO
.
new
(
actual_response
)).
read
actual_response
=
Zlib
::
GzipReader
.
new
(
StringIO
.
new
(
actual_response
)).
read
...
...
misc/spec/subscriber/polling_spec.rb
View file @
3da6cb0e
...
@@ -25,7 +25,7 @@ describe "Subscriber Properties" do
...
@@ -25,7 +25,7 @@ describe "Subscriber Properties" do
it
"should receive a 304 keeping sent headers"
do
it
"should receive a 304 keeping sent headers"
do
channel
=
'ch_test_receive_a_304_when_has_no_messages_keeping_headers'
channel
=
'ch_test_receive_a_304_when_has_no_messages_keeping_headers'
sent_headers
=
headers
.
merge
({
'If-Modified-Since'
=>
Time
.
now
.
utc
.
strftime
(
"%a, %d %b %Y %T %Z"
),
'If-None-Match'
=>
'3'
})
sent_headers
=
headers
.
merge
({
'If-Modified-Since'
=>
Time
.
now
.
utc
.
strftime
(
"%a, %d %b %Y %T %Z"
),
'If-None-Match'
=>
'
W/
3'
})
nginx_run_server
(
config
)
do
|
conf
|
nginx_run_server
(
config
)
do
|
conf
|
EventMachine
.
run
do
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
sent_headers
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
sent_headers
...
@@ -55,7 +55,7 @@ describe "Subscriber Properties" do
...
@@ -55,7 +55,7 @@ describe "Subscriber Properties" do
sub_1
.
callback
do
sub_1
.
callback
do
expect
(
sub_1
).
to
be_http_status
(
200
)
expect
(
sub_1
).
to
be_http_status
(
200
)
expect
(
sub_1
.
response_header
[
'LAST_MODIFIED'
].
to_s
).
not_to
eql
(
""
)
expect
(
sub_1
.
response_header
[
'LAST_MODIFIED'
].
to_s
).
not_to
eql
(
""
)
expect
(
sub_1
.
response_header
[
'ETAG'
].
to_s
).
to
eql
(
"1"
)
expect
(
sub_1
.
response_header
[
'ETAG'
].
to_s
).
to
eql
(
"
W/
1"
)
expect
(
sub_1
.
response
).
to
eql
(
"
#{
body
}
"
)
expect
(
sub_1
.
response
).
to
eql
(
"
#{
body
}
"
)
EventMachine
.
stop
EventMachine
.
stop
end
end
...
@@ -148,6 +148,7 @@ describe "Subscriber Properties" do
...
@@ -148,6 +148,7 @@ describe "Subscriber Properties" do
sub_1
.
callback
do
sub_1
.
callback
do
expect
(
sub_1
).
to
be_http_status
(
200
)
expect
(
sub_1
).
to
be_http_status
(
200
)
expect
(
sub_1
.
response_header
[
"ETAG"
]).
to
match
(
/W\/\d+/
)
expect
(
sub_1
.
response_header
[
"CONTENT_ENCODING"
]).
to
eql
(
"gzip"
)
expect
(
sub_1
.
response_header
[
"CONTENT_ENCODING"
]).
to
eql
(
"gzip"
)
actual_response
=
Zlib
::
GzipReader
.
new
(
StringIO
.
new
(
actual_response
)).
read
actual_response
=
Zlib
::
GzipReader
.
new
(
StringIO
.
new
(
actual_response
)).
read
...
...
misc/spec/subscriber/receive_old_message_spec.rb
View file @
3da6cb0e
...
@@ -223,7 +223,7 @@ describe "Receive old messages" do
...
@@ -223,7 +223,7 @@ describe "Receive old messages" do
get_content
(
nginx_address
+
'/sub/'
+
channel
.
to_s
,
4
,
sent_headers
)
do
|
response
,
response_headers
|
get_content
(
nginx_address
+
'/sub/'
+
channel
.
to_s
,
4
,
sent_headers
)
do
|
response
,
response_headers
|
if
[
"long-polling"
,
"polling"
].
include?
(
conf
.
subscriber_mode
)
if
[
"long-polling"
,
"polling"
].
include?
(
conf
.
subscriber_mode
)
expect
(
response_headers
[
'LAST_MODIFIED'
].
to_s
).
not_to
eql
(
""
)
expect
(
response_headers
[
'LAST_MODIFIED'
].
to_s
).
not_to
eql
(
""
)
expect
(
response_headers
[
'ETAG'
].
to_s
).
to
eql
(
"10"
)
expect
(
response_headers
[
'ETAG'
].
to_s
).
to
eql
(
"
W/
10"
)
end
end
expect
(
response
).
to
eql
(
"msg 6
\r\n
msg 7
\r\n
msg 8
\r\n
msg 9
\r\n
"
)
expect
(
response
).
to
eql
(
"msg 6
\r\n
msg 7
\r\n
msg 8
\r\n
msg 9
\r\n
"
)
...
@@ -243,7 +243,7 @@ describe "Receive old messages" do
...
@@ -243,7 +243,7 @@ describe "Receive old messages" do
get_content
(
nginx_address
+
'/sub/'
+
channel
.
to_s
,
1
,
sent_headers
)
do
|
response
,
response_headers
|
get_content
(
nginx_address
+
'/sub/'
+
channel
.
to_s
,
1
,
sent_headers
)
do
|
response
,
response_headers
|
if
[
"long-polling"
,
"polling"
].
include?
(
conf
.
subscriber_mode
)
if
[
"long-polling"
,
"polling"
].
include?
(
conf
.
subscriber_mode
)
expect
(
response_headers
[
'LAST_MODIFIED'
].
to_s
).
not_to
eql
(
""
)
expect
(
response_headers
[
'LAST_MODIFIED'
].
to_s
).
not_to
eql
(
""
)
expect
(
response_headers
[
'ETAG'
].
to_s
).
to
eql
(
"1"
)
expect
(
response_headers
[
'ETAG'
].
to_s
).
to
eql
(
"
W/
1"
)
end
end
expect
(
response
).
to
eql
(
"msg 1
#{
eol
}
"
)
expect
(
response
).
to
eql
(
"msg 1
#{
eol
}
"
)
...
@@ -267,7 +267,7 @@ describe "Receive old messages" do
...
@@ -267,7 +267,7 @@ describe "Receive old messages" do
get_content
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'?'
+
params
,
4
,
headers
)
do
|
response
,
response_headers
|
get_content
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'?'
+
params
,
4
,
headers
)
do
|
response
,
response_headers
|
if
[
"long-polling"
,
"polling"
].
include?
(
conf
.
subscriber_mode
)
if
[
"long-polling"
,
"polling"
].
include?
(
conf
.
subscriber_mode
)
expect
(
response_headers
[
'LAST_MODIFIED'
].
to_s
).
not_to
eql
(
""
)
expect
(
response_headers
[
'LAST_MODIFIED'
].
to_s
).
not_to
eql
(
""
)
expect
(
response_headers
[
'ETAG'
].
to_s
).
to
eql
(
"10"
)
expect
(
response_headers
[
'ETAG'
].
to_s
).
to
eql
(
"
W/
10"
)
end
end
expect
(
response
).
to
eql
(
"msg 6
\r\n
msg 7
\r\n
msg 8
\r\n
msg 9
\r\n
"
)
expect
(
response
).
to
eql
(
"msg 6
\r\n
msg 7
\r\n
msg 8
\r\n
msg 9
\r\n
"
)
...
...
src/ngx_http_push_stream_module_utils.c
View file @
3da6cb0e
...
@@ -1815,9 +1815,9 @@ ngx_http_push_stream_add_polling_headers(ngx_http_request_t *r, time_t last_modi
...
@@ -1815,9 +1815,9 @@ ngx_http_push_stream_add_polling_headers(ngx_http_request_t *r, time_t last_modi
}
}
if
(
tag
>=
0
)
{
if
(
tag
>=
0
)
{
ngx_str_t
*
etag
=
ngx_http_push_stream_create_str
(
temp_pool
,
NGX_INT_T_LEN
);
ngx_str_t
*
etag
=
ngx_http_push_stream_create_str
(
temp_pool
,
NGX_INT_T_LEN
+
3
);
if
(
etag
!=
NULL
)
{
if
(
etag
!=
NULL
)
{
ngx_sprintf
(
etag
->
data
,
"
%ui
"
,
tag
);
ngx_sprintf
(
etag
->
data
,
"
W/%ui%Z
"
,
tag
);
etag
->
len
=
ngx_strlen
(
etag
->
data
);
etag
->
len
=
ngx_strlen
(
etag
->
data
);
r
->
headers_out
.
etag
=
ngx_http_push_stream_add_response_header
(
r
,
&
NGX_HTTP_PUSH_STREAM_HEADER_ETAG
,
etag
);
r
->
headers_out
.
etag
=
ngx_http_push_stream_add_response_header
(
r
,
&
NGX_HTTP_PUSH_STREAM_HEADER_ETAG
,
etag
);
}
}
...
@@ -1846,6 +1846,11 @@ ngx_http_push_stream_get_last_received_message_values(ngx_http_request_t *r, tim
...
@@ -1846,6 +1846,11 @@ ngx_http_push_stream_get_last_received_message_values(ngx_http_request_t *r, tim
etag
=
ngx_http_push_stream_get_header
(
r
,
&
NGX_HTTP_PUSH_STREAM_HEADER_IF_NONE_MATCH
);
etag
=
ngx_http_push_stream_get_header
(
r
,
&
NGX_HTTP_PUSH_STREAM_HEADER_IF_NONE_MATCH
);
}
}
if
((
etag
!=
NULL
)
&&
(
etag
->
len
>
2
)
&&
(
etag
->
data
[
0
]
==
'W'
)
&&
(
etag
->
data
[
1
]
==
'/'
))
{
etag
->
len
-=
2
;
etag
->
data
=
etag
->
data
+
2
;
}
if
(
cf
->
last_event_id
!=
NULL
)
{
if
(
cf
->
last_event_id
!=
NULL
)
{
ngx_http_push_stream_complex_value
(
r
,
cf
->
last_event_id
,
&
vv_event_id
);
ngx_http_push_stream_complex_value
(
r
,
cf
->
last_event_id
,
&
vv_event_id
);
if
(
vv_event_id
.
len
)
{
if
(
vv_event_id
.
len
)
{
...
...
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