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
67935a78
Commit
67935a78
authored
Jan 06, 2013
by
Wandenberg Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
forcing content type as application/javascript on jsonp requests
parent
0a7610f2
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
5 deletions
+60
-5
ngx_http_push_stream_module_utils.h
include/ngx_http_push_stream_module_utils.h
+1
-0
ngx_http_push_stream_module_version.h
include/ngx_http_push_stream_module_version.h
+1
-1
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
+6
-0
test_subscriber_long_polling.rb
test/test_subscriber_long_polling.rb
+27
-2
test_subscriber_polling.rb
test/test_subscriber_polling.rb
+25
-1
No files found.
include/ngx_http_push_stream_module_utils.h
View file @
67935a78
...
@@ -212,6 +212,7 @@ static const ngx_str_t NGX_HTTP_PUSH_STREAM_LAST_CHUNK = ngx_string("0" CRLF CR
...
@@ -212,6 +212,7 @@ static const ngx_str_t NGX_HTTP_PUSH_STREAM_LAST_CHUNK = ngx_string("0" CRLF CR
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_CALLBACK_INIT_CHUNK
=
ngx_string
(
"2"
CRLF
"(["
CRLF
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_CALLBACK_INIT_CHUNK
=
ngx_string
(
"2"
CRLF
"(["
CRLF
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_CALLBACK_MID_CHUNK
=
ngx_string
(
"1"
CRLF
","
CRLF
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_CALLBACK_MID_CHUNK
=
ngx_string
(
"1"
CRLF
","
CRLF
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_CALLBACK_END_CHUNK
=
ngx_string
(
"5"
CRLF
"]);"
CRLF
CRLF
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_CALLBACK_END_CHUNK
=
ngx_string
(
"5"
CRLF
"]);"
CRLF
CRLF
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_CALLBACK_CONTENT_TYPE
=
ngx_string
(
"application/javascript"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_PADDING_BY_USER_AGENT_PATTERN
=
ngx_string
(
"([^:]+),(
\\
d+),(
\\
d+)"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_PADDING_BY_USER_AGENT_PATTERN
=
ngx_string
(
"([^:]+),(
\\
d+),(
\\
d+)"
);
...
...
include/ngx_http_push_stream_module_version.h
View file @
67935a78
...
@@ -27,6 +27,6 @@
...
@@ -27,6 +27,6 @@
#define NGX_HTTP_PUSH_STREAM_MODULE_VERSION_H_
#define NGX_HTTP_PUSH_STREAM_MODULE_VERSION_H_
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_TAG
=
ngx_string
(
"0.3.4"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_TAG
=
ngx_string
(
"0.3.4"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_COMMIT
=
ngx_string
(
"
79eb641fa567a24cd87603256cd7d03a19e45aeb
"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_COMMIT
=
ngx_string
(
"
0a7610f2b25dadad803cecf740d542e2ac781762
"
);
#endif
/* NGX_HTTP_PUSH_STREAM_MODULE_VERSION_H_ */
#endif
/* NGX_HTTP_PUSH_STREAM_MODULE_VERSION_H_ */
src/ngx_http_push_stream_module_subscriber.c
View file @
67935a78
...
@@ -257,7 +257,6 @@ ngx_http_push_stream_subscriber_polling_handler(ngx_http_request_t *r, ngx_http_
...
@@ -257,7 +257,6 @@ ngx_http_push_stream_subscriber_polling_handler(ngx_http_request_t *r, ngx_http_
}
}
// polling with messages or long polling without messages to send
// polling with messages or long polling without messages to send
r
->
headers_out
.
content_type
=
cf
->
content_type
;
r
->
headers_out
.
status
=
NGX_HTTP_OK
;
r
->
headers_out
.
status
=
NGX_HTTP_OK
;
r
->
headers_out
.
content_length_n
=
-
1
;
r
->
headers_out
.
content_length_n
=
-
1
;
...
...
src/ngx_http_push_stream_module_utils.c
View file @
67935a78
...
@@ -1427,6 +1427,12 @@ ngx_http_push_stream_apply_template_to_each_line(ngx_str_t *text, const ngx_str_
...
@@ -1427,6 +1427,12 @@ ngx_http_push_stream_apply_template_to_each_line(ngx_str_t *text, const ngx_str_
static
void
static
void
ngx_http_push_stream_add_polling_headers
(
ngx_http_request_t
*
r
,
time_t
last_modified_time
,
ngx_int_t
tag
,
ngx_pool_t
*
temp_pool
)
ngx_http_push_stream_add_polling_headers
(
ngx_http_request_t
*
r
,
time_t
last_modified_time
,
ngx_int_t
tag
,
ngx_pool_t
*
temp_pool
)
{
{
ngx_http_push_stream_loc_conf_t
*
cf
=
ngx_http_get_module_loc_conf
(
r
,
ngx_http_push_stream_module
);
ngx_http_push_stream_subscriber_ctx_t
*
ctx
=
ngx_http_get_module_ctx
(
r
,
ngx_http_push_stream_module
);
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
;
if
(
last_modified_time
>
0
)
{
if
(
last_modified_time
>
0
)
{
r
->
headers_out
.
last_modified_time
=
last_modified_time
;
r
->
headers_out
.
last_modified_time
=
last_modified_time
;
}
}
...
...
test/test_subscriber_long_polling.rb
View file @
67935a78
...
@@ -575,7 +575,7 @@ class TestSubscriberLongPolling < Test::Unit::TestCase
...
@@ -575,7 +575,7 @@ class TestSubscriberLongPolling < Test::Unit::TestCase
end
end
def
test_return_message_using_function_name_specified_in_callback_parameter
def
test_return_message_using_function_name_specified_in_callback_parameter
headers
=
{
'accept'
=>
'application/j
son
'
}
headers
=
{
'accept'
=>
'application/j
avascript
'
}
channel
=
'ch_test_return_message_using_function_name_specified_in_callback_parameter'
channel
=
'ch_test_return_message_using_function_name_specified_in_callback_parameter'
body
=
'body'
body
=
'body'
response
=
""
response
=
""
...
@@ -596,7 +596,7 @@ class TestSubscriberLongPolling < Test::Unit::TestCase
...
@@ -596,7 +596,7 @@ class TestSubscriberLongPolling < Test::Unit::TestCase
end
end
def
test_return_old_messages_using_function_name_specified_in_callback_parameter_grouping_in_one_answer
def
test_return_old_messages_using_function_name_specified_in_callback_parameter_grouping_in_one_answer
headers
=
{
'accept'
=>
'application/j
son
'
}
headers
=
{
'accept'
=>
'application/j
avascript
'
}
channel
=
'ch_test_return_old_messages_using_function_name_specified_in_callback_parameter_grouping_in_one_answer'
channel
=
'ch_test_return_old_messages_using_function_name_specified_in_callback_parameter_grouping_in_one_answer'
body
=
'body'
body
=
'body'
response
=
""
response
=
""
...
@@ -617,4 +617,29 @@ class TestSubscriberLongPolling < Test::Unit::TestCase
...
@@ -617,4 +617,29 @@ class TestSubscriberLongPolling < Test::Unit::TestCase
}
}
end
end
def
config_test_force_content_type_to_be_application_javascript_when_using_function_name_specified_in_callback_parameter
@content_type
=
"anything/value"
end
def
test_force_content_type_to_be_application_javascript_when_using_function_name_specified_in_callback_parameter
headers
=
{
'accept'
=>
'otherknown/value'
}
channel
=
'test_force_content_type_to_be_application_javascript_when_using_function_name_specified_in_callback_parameter'
body
=
'body'
response
=
""
callback_function_name
=
"callback_function"
EventMachine
.
run
{
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'?callback='
+
callback_function_name
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
.
callback
{
assert_equal
(
'application/javascript'
,
sub_1
.
response_header
[
'CONTENT_TYPE'
],
"Didn't receive the right content type"
)
EventMachine
.
stop
}
publish_message_inline
(
channel
,
{
'accept'
=>
'text/html'
},
body
)
add_test_timeout
}
end
end
end
test/test_subscriber_polling.rb
View file @
67935a78
...
@@ -596,7 +596,7 @@ class TestSubscriberPolling < Test::Unit::TestCase
...
@@ -596,7 +596,7 @@ class TestSubscriberPolling < Test::Unit::TestCase
end
end
def
test_return_message_using_function_name_specified_in_callback_parameter_when_polling
def
test_return_message_using_function_name_specified_in_callback_parameter_when_polling
headers
=
{
'accept'
=>
'application/j
son
'
}
headers
=
{
'accept'
=>
'application/j
avascript
'
}
channel
=
'ch_test_return_message_using_function_name_specified_in_callback_parameter_when_polling'
channel
=
'ch_test_return_message_using_function_name_specified_in_callback_parameter_when_polling'
body
=
'body'
body
=
'body'
response
=
""
response
=
""
...
@@ -615,4 +615,28 @@ class TestSubscriberPolling < Test::Unit::TestCase
...
@@ -615,4 +615,28 @@ class TestSubscriberPolling < Test::Unit::TestCase
}
}
end
end
def
config_test_force_content_type_to_be_application_javascript_when_using_function_name_specified_in_callback_parameter_when_polling
@content_type
=
"anything/value"
end
def
test_force_content_type_to_be_application_javascript_when_using_function_name_specified_in_callback_parameter_when_polling
headers
=
{
'accept'
=>
'otherknown/value'
}
channel
=
'test_force_content_type_to_be_application_javascript_when_using_function_name_specified_in_callback_parameter_when_polling'
body
=
'body'
response
=
""
callback_function_name
=
"callback_function"
EventMachine
.
run
{
publish_message_inline
(
channel
,
{
'accept'
=>
'text/html'
},
body
)
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'?callback='
+
callback_function_name
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
.
callback
{
assert_equal
(
'application/javascript'
,
sub_1
.
response_header
[
'CONTENT_TYPE'
],
"Didn't receive the right content type"
)
EventMachine
.
stop
}
add_test_timeout
}
end
end
end
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