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
216cc09c
Commit
216cc09c
authored
Jan 06, 2013
by
Wandenberg Peixoto
Committed by
Wandenberg
Nov 08, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix to support gzip usage
parent
211edf51
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
239 additions
and
36 deletions
+239
-36
CHANGELOG.textile
CHANGELOG.textile
+1
-0
channel_statistics_spec.rb
misc/spec/mix/channel_statistics_spec.rb
+91
-33
nginx_configuration.rb
misc/spec/nginx_configuration.rb
+11
-1
properties_spec.rb
misc/spec/publisher/properties_spec.rb
+53
-0
spec_helper.rb
misc/spec/spec_helper.rb
+1
-2
long_polling_spec.rb
misc/spec/subscriber/long_polling_spec.rb
+26
-0
polling_spec.rb
misc/spec/subscriber/polling_spec.rb
+26
-0
properties_spec.rb
misc/spec/subscriber/properties_spec.rb
+26
-0
ngx_http_push_stream_module.c
src/ngx_http_push_stream_module.c
+1
-0
ngx_http_push_stream_module_subscriber.c
src/ngx_http_push_stream_module_subscriber.c
+1
-0
ngx_http_push_stream_module_utils.c
src/ngx_http_push_stream_module_utils.c
+2
-0
No files found.
CHANGELOG.textile
View file @
216cc09c
h1(#changelog). Changelog
* Fix to support gzip usage
* Added the feature to send a custom 'channel delete message' on the body of the DELETE request
* Changed push_stream_channel_id variable to directive, and make possible set it inside an if block
* Changed push_stream_channels_path variable to directive, and make possible set it inside an if block
...
...
misc/spec/mix/channel_statistics_spec.rb
View file @
216cc09c
This diff is collapsed.
Click to expand it.
misc/spec/nginx_configuration.rb
View file @
216cc09c
...
...
@@ -5,7 +5,9 @@ module NginxConfiguration
:master_process
=>
'on'
,
:daemon
=>
'on'
,
:content_type
=>
'text/html; charset=utf-8'
,
:gzip
=>
'off'
,
:content_type
=>
'text/html'
,
:keepalive
=>
'off'
,
:ping_message_interval
=>
'10s'
,
...
...
@@ -83,6 +85,14 @@ http {
access_log <%= access_log %>;
gzip <%= gzip %>;
gzip_buffers 16 4k;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/json;
gzip_comp_level 9;
gzip_http_version 1.0;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 100;
...
...
misc/spec/publisher/properties_spec.rb
View file @
216cc09c
...
...
@@ -454,6 +454,59 @@ describe "Publisher Properties" do
end
end
end
it
"should accept respond get requests with gzip"
do
channel
=
'test_receive_get_response_with_gzip'
body
=
'body'
actual_response
=
''
nginx_run_server
(
config
.
merge
(
:gzip
=>
"on"
),
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
#create channel
publish_message_inline
(
channel
,
{},
body
)
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
).
get
:head
=>
headers
.
merge
({
'accept'
=>
'application/json'
,
'accept-encoding'
=>
'gzip, compressed'
}),
:decoding
=>
false
pub
.
stream
do
|
chunk
|
actual_response
<<
chunk
end
pub
.
callback
do
pub
.
response_header
.
status
.
should
eql
(
200
)
pub
.
response_header
.
content_length
.
should_not
eql
(
0
)
pub
.
response_header
[
"CONTENT_ENCODING"
].
should
eql
(
"gzip"
)
actual_response
=
Zlib
::
GzipReader
.
new
(
StringIO
.
new
(
actual_response
)).
read
response
=
JSON
.
parse
(
actual_response
)
response
[
"channel"
].
to_s
.
should
eql
(
channel
)
EventMachine
.
stop
end
end
end
end
it
"should accept respond post requests with gzip"
do
channel
=
'test_receive_post_response_with_gzip'
body
=
'body'
actual_response
=
''
nginx_run_server
(
config
.
merge
(
:gzip
=>
"on"
),
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
).
post
:body
=>
body
,
:head
=>
headers
.
merge
({
'accept'
=>
'application/json'
,
'accept-encoding'
=>
'gzip, compressed'
}),
:decoding
=>
false
pub
.
stream
do
|
chunk
|
actual_response
<<
chunk
end
pub
.
callback
do
pub
.
response_header
.
status
.
should
eql
(
200
)
pub
.
response_header
.
content_length
.
should_not
eql
(
0
)
pub
.
response_header
[
"CONTENT_ENCODING"
].
should
eql
(
"gzip"
)
actual_response
=
Zlib
::
GzipReader
.
new
(
StringIO
.
new
(
actual_response
)).
read
response
=
JSON
.
parse
(
actual_response
)
response
[
"channel"
].
to_s
.
should
eql
(
channel
)
EventMachine
.
stop
end
end
end
end
end
context
"when is on normal mode"
do
...
...
misc/spec/spec_helper.rb
View file @
216cc09c
...
...
@@ -41,7 +41,6 @@ end
def
publish_message
(
channel
,
headers
,
body
)
EventMachine
.
run
do
pub
=
publish_message_inline
(
channel
,
headers
,
body
)
do
pub
.
should
be_http_status
(
200
).
with_body
response
=
JSON
.
parse
(
pub
.
response
)
response
[
"channel"
].
to_s
.
should
eql
(
channel
)
EventMachine
.
stop
...
...
@@ -51,7 +50,7 @@ end
def
create_channel_by_subscribe
(
channel
,
headers
,
timeout
=
60
,
&
block
)
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
timeout
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
,
:connect_timeout
=>
timeout
,
:inactivity_timeout
=>
timeout
).
get
:head
=>
headers
.
merge
({
"accept-encoding"
=>
""
})
sub_1
.
stream
do
|
chunk
|
block
.
call
end
...
...
misc/spec/subscriber/long_polling_spec.rb
View file @
216cc09c
...
...
@@ -422,6 +422,32 @@ describe "Subscriber Properties" do
end
end
end
it
"should accpet return content gzipped"
do
channel
=
'ch_test_get_content_gzipped'
body
=
'body'
actual_response
=
''
nginx_run_server
(
config
.
merge
({
:gzip
=>
"on"
}))
do
|
conf
|
EventMachine
.
run
do
sent_headers
=
headers
.
merge
({
'accept-encoding'
=>
'gzip, compressed'
})
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
sent_headers
,
:decoding
=>
false
sub_1
.
stream
do
|
chunk
|
actual_response
<<
chunk
end
sub_1
.
callback
do
sub_1
.
should
be_http_status
(
200
)
sub_1
.
response_header
[
"CONTENT_ENCODING"
].
should
eql
(
"gzip"
)
actual_response
=
Zlib
::
GzipReader
.
new
(
StringIO
.
new
(
actual_response
)).
read
actual_response
.
should
eql
(
"
#{
body
}
\r\n
"
)
EventMachine
.
stop
end
publish_message_inline
(
channel
,
{},
body
)
end
end
end
end
context
"when using subscriber push mode config"
do
...
...
misc/spec/subscriber/polling_spec.rb
View file @
216cc09c
...
...
@@ -339,6 +339,32 @@ describe "Subscriber Properties" do
end
end
it
"should accpet return content gzipped"
do
channel
=
'ch_test_get_content_gzipped'
body
=
'body'
actual_response
=
''
nginx_run_server
(
config
.
merge
({
:gzip
=>
"on"
}))
do
|
conf
|
EventMachine
.
run
do
publish_message_inline
(
channel
,
{},
body
)
sent_headers
=
headers
.
merge
({
'accept-encoding'
=>
'gzip, compressed'
})
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
sent_headers
,
:decoding
=>
false
sub_1
.
stream
do
|
chunk
|
actual_response
<<
chunk
end
sub_1
.
callback
do
sub_1
.
should
be_http_status
(
200
)
sub_1
.
response_header
[
"CONTENT_ENCODING"
].
should
eql
(
"gzip"
)
actual_response
=
Zlib
::
GzipReader
.
new
(
StringIO
.
new
(
actual_response
)).
read
actual_response
.
should
eql
(
"
#{
body
}
\r\n
"
)
EventMachine
.
stop
end
end
end
end
end
it
"should not cache the response"
do
...
...
misc/spec/subscriber/properties_spec.rb
View file @
216cc09c
...
...
@@ -973,4 +973,30 @@ describe "Subscriber Properties" do
end
end
end
it
"should accpet return content gzipped"
do
channel
=
'ch_test_get_content_gzipped'
body
=
'body'
actual_response
=
''
nginx_run_server
(
config
.
merge
({
:gzip
=>
"on"
,
:subscriber_connection_ttl
=>
'1s'
,
:content_type
=>
"text/html"
}))
do
|
conf
|
EventMachine
.
run
do
sent_headers
=
headers
.
merge
({
'accept-encoding'
=>
'gzip, compressed'
})
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
sent_headers
,
:decoding
=>
false
sub_1
.
stream
do
|
chunk
|
actual_response
<<
chunk
end
sub_1
.
callback
do
sub_1
.
should
be_http_status
(
200
)
sub_1
.
response_header
[
"CONTENT_ENCODING"
].
should
eql
(
"gzip"
)
actual_response
=
Zlib
::
GzipReader
.
new
(
StringIO
.
new
(
actual_response
)).
read
actual_response
.
should
eql
(
"HEADER
\r\n
TEMPLATE
\r\n
1234
\r\n\r\n
<script>p(1,'ch_test_get_content_gzipped','body');</script>
\r\n
</body></html>
\r\n
"
)
EventMachine
.
stop
end
publish_message_inline
(
channel
,
{},
body
)
end
end
end
end
src/ngx_http_push_stream_module.c
View file @
216cc09c
...
...
@@ -265,6 +265,7 @@ ngx_http_push_stream_send_response_all_channels_info_detailed(ngx_http_request_t
r
->
headers_out
.
content_type
.
len
=
subtype
->
content_type
->
len
;
r
->
headers_out
.
content_type
.
data
=
subtype
->
content_type
->
data
;
r
->
headers_out
.
content_type_len
=
subtype
->
content_type
->
len
;
r
->
headers_out
.
content_length_n
=
content_len
;
r
->
headers_out
.
status
=
NGX_HTTP_OK
;
...
...
src/ngx_http_push_stream_module_subscriber.c
View file @
216cc09c
...
...
@@ -489,6 +489,7 @@ ngx_http_push_stream_subscriber_prepare_request_to_keep_connected(ngx_http_reque
r
->
write_event_handler
=
ngx_http_request_empty_handler
;
r
->
headers_out
.
content_type
=
cf
->
content_type
;
r
->
headers_out
.
content_type_len
=
cf
->
content_type
.
len
;
r
->
headers_out
.
status
=
NGX_HTTP_OK
;
r
->
headers_out
.
content_length_n
=
-
1
;
...
...
src/ngx_http_push_stream_module_utils.c
View file @
216cc09c
...
...
@@ -535,6 +535,7 @@ ngx_http_push_stream_send_response(ngx_http_request_t *r, ngx_str_t *text, const
r
->
headers_out
.
content_type
.
len
=
content_type
->
len
;
r
->
headers_out
.
content_type
.
data
=
content_type
->
data
;
r
->
headers_out
.
content_type_len
=
content_type
->
len
;
r
->
headers_out
.
content_length_n
=
text
->
len
;
r
->
headers_out
.
status
=
status_code
;
...
...
@@ -1436,6 +1437,7 @@ ngx_http_push_stream_add_polling_headers(ngx_http_request_t *r, time_t last_modi
ngx_str_t
content_type
=
(
ctx
->
callback
!=
NULL
)
?
NGX_HTTP_PUSH_STREAM_CALLBACK_CONTENT_TYPE
:
cf
->
content_type
;
r
->
headers_out
.
content_type
=
content_type
;
r
->
headers_out
.
content_type_len
=
content_type
.
len
;
if
(
last_modified_time
>
0
)
{
r
->
headers_out
.
last_modified_time
=
last_modified_time
;
...
...
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