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
f027561e
Commit
f027561e
authored
Sep 07, 2013
by
Wandenberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix some publisher tests
parent
9d1e6226
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
19 deletions
+53
-19
properties_spec.rb
misc/spec/publisher/properties_spec.rb
+51
-18
ngx_http_push_stream_module_publisher.c
src/ngx_http_push_stream_module_publisher.c
+2
-1
No files found.
misc/spec/publisher/properties_spec.rb
View file @
f027561e
...
...
@@ -372,7 +372,7 @@ describe "Publisher Properties" do
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
).
get
:head
=>
headers
pub
.
callback
do
pub
.
response_header
[
'ACCESS_CONTROL_ALLOW_ORIGIN'
].
should
eql
(
"custom.domain.com"
)
pub
.
response_header
[
'ACCESS_CONTROL_ALLOW_METHODS'
].
should
eql
(
"GET, POST, PUT, DELETE"
)
pub
.
response_header
[
'ACCESS_CONTROL_ALLOW_METHODS'
].
should
eql
(
accepted_methods
)
EventMachine
.
stop
end
...
...
@@ -495,23 +495,6 @@ describe "Publisher Properties" do
end
end
context
"when allow origin directive is set"
do
it
"should receive acess control allow headers"
do
channel
=
'test_access_control_allow_headers'
nginx_run_server
(
config
.
merge
(
:allowed_origins
=>
"custom.domain.com"
))
do
|
conf
|
EventMachine
.
run
do
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
).
get
:head
=>
headers
pub
.
callback
do
pub
.
response_header
[
'ACCESS_CONTROL_ALLOW_ORIGIN'
].
should
eql
(
"custom.domain.com"
)
EventMachine
.
stop
end
end
end
end
end
it
"should not cache the response"
do
channel
=
'ch_test_not_cache_the_response'
...
...
@@ -610,6 +593,56 @@ describe "Publisher Properties" do
it_should_behave_like
"publisher location"
it
"should return error when channel does not exists"
do
channel
=
'test_delete_channel_non_existent'
nginx_run_server
(
config
)
do
|
conf
|
EventMachine
.
run
do
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
get
:head
=>
headers
pub
.
callback
do
pub
.
should
be_http_status
(
404
).
without_body
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
delete
:head
=>
headers
pub_1
.
callback
do
pub_1
.
should
be_http_status
(
404
).
without_body
pub_1
.
response_header
[
'X_NGINX_PUSHSTREAM_EXPLAIN'
].
should
be_nil
EventMachine
.
stop
end
end
end
end
end
it
"should return error when channel id is not specified"
do
channel
=
'test_delete_channel_whithout_send_id'
nginx_run_server
(
config
)
do
|
conf
|
EventMachine
.
run
do
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
).
delete
:head
=>
headers
pub
.
callback
do
pub
.
should
be_http_status
(
400
).
without_body
pub
.
response_header
[
'X_NGINX_PUSHSTREAM_EXPLAIN'
].
should
eql
(
"No channel id provided."
)
EventMachine
.
stop
end
end
end
end
it
"should return error when channel id is bigger than allowed"
do
channel
=
'test_delete_channel_whith_big_id'
nginx_run_server
(
config
.
merge
(
:max_channel_id_length
=>
5
))
do
|
conf
|
EventMachine
.
run
do
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
delete
:head
=>
headers
pub
.
callback
do
pub
.
should
be_http_status
(
400
).
without_body
pub
.
response_header
[
'X_NGINX_PUSHSTREAM_EXPLAIN'
].
should
eql
(
"Channel id is too large."
)
EventMachine
.
stop
end
end
end
end
it
"should delete a channel without subscribers"
do
channel
=
'test_delete_channel_whithout_subscribers'
body
=
'published message'
...
...
src/ngx_http_push_stream_module_publisher.c
View file @
f027561e
...
...
@@ -40,7 +40,8 @@ ngx_http_push_stream_publisher_handler(ngx_http_request_t *r)
if
(
cf
->
allowed_origins
.
len
>
0
)
{
ngx_http_push_stream_add_response_header
(
r
,
&
NGX_HTTP_PUSH_STREAM_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN
,
&
cf
->
allowed_origins
);
ngx_http_push_stream_add_response_header
(
r
,
&
NGX_HTTP_PUSH_STREAM_HEADER_ACCESS_CONTROL_ALLOW_METHODS
,
&
NGX_HTTP_PUSH_STREAM_ALLOW_GET_POST_PUT_DELETE_METHODS
);
const
ngx_str_t
*
header_value
=
(
cf
->
location_type
==
NGX_HTTP_PUSH_STREAM_PUBLISHER_MODE_ADMIN
)
?
&
NGX_HTTP_PUSH_STREAM_ALLOW_GET_POST_PUT_DELETE_METHODS
:
&
NGX_HTTP_PUSH_STREAM_ALLOW_GET_POST_PUT_METHODS
;
ngx_http_push_stream_add_response_header
(
r
,
&
NGX_HTTP_PUSH_STREAM_HEADER_ACCESS_CONTROL_ALLOW_METHODS
,
header_value
);
}
if
(
r
->
method
&
NGX_HTTP_OPTIONS
)
{
...
...
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