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
883aea05
Commit
883aea05
authored
Sep 22, 2013
by
Wandenberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add support to get old messages using time and tag to all wrappers on pushstream.js
parent
f98357ed
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
607 additions
and
94 deletions
+607
-94
ngx_http_push_stream_module.h
include/ngx_http_push_stream_module.h
+1
-2
pushstream.js
misc/js/pushstream.js
+88
-44
nginx.conf
misc/nginx.conf
+38
-33
PushStreamSpec.js
misc/spec/javascripts/PushStreamSpec.js
+473
-11
properties_spec.rb
misc/spec/publisher/properties_spec.rb
+2
-0
properties_spec.rb
misc/spec/subscriber/properties_spec.rb
+1
-1
ngx_http_push_stream_module_publisher.c
src/ngx_http_push_stream_module_publisher.c
+1
-0
ngx_http_push_stream_module_setup.c
src/ngx_http_push_stream_module_setup.c
+3
-3
No files found.
include/ngx_http_push_stream_module.h
View file @
883aea05
...
...
@@ -268,7 +268,6 @@ static const ngx_str_t NGX_HTTP_PUSH_STREAM_HEADER_TAG = ngx_string("X-Nginx-Pu
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_COMMIT
=
ngx_string
(
"X-Nginx-PushStream-Commit"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_ETAG
=
ngx_string
(
"Etag"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_IF_NONE_MATCH
=
ngx_string
(
"If-None-Match"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_VARY
=
ngx_string
(
"Vary"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_UPGRADE
=
ngx_string
(
"Upgrade"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_CONNECTION
=
ngx_string
(
"Connection"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_SEC_WEBSOCKET_KEY
=
ngx_string
(
"Sec-WebSocket-Key"
);
...
...
@@ -333,7 +332,7 @@ static const ngx_str_t NGX_HTTP_PUSH_STREAM_ALLOW_GET_POST_PUT_DELETE_METHODS =
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_ALLOW_GET_POST_PUT_METHODS
=
ngx_string
(
"GET, POST, PUT"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_ALLOW_GET
=
ngx_string
(
"GET"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_ALLOWED_HEADERS
=
ngx_string
(
"If-Modified-Since,If-None-Match"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_ALLOWED_HEADERS
=
ngx_string
(
"If-Modified-Since,If-None-Match
,Etag,Event-Id,Event-Type,Last-Event-Id
"
);
#define NGX_HTTP_PUSH_STREAM_CHECK_AND_FINALIZE_REQUEST_ON_ERROR(val, fail, r, errormessage) \
if (val == fail) { \
...
...
misc/js/pushstream.js
View file @
883aea05
This diff is collapsed.
Click to expand it.
misc/nginx.conf
View file @
883aea05
...
...
@@ -15,23 +15,7 @@ events {
}
http
{
default_type
application/octet-stream
;
access_log
logs/nginx-http
_access.log
;
error_log
logs/nginx-http
_error.log
debug
;
tcp_nopush
off
;
tcp_nodelay
on
;
keepalive_timeout
10
;
send_timeout
10
;
client_body_timeout
10
;
client_header_timeout
10
;
sendfile
on
;
client_header_buffer_size
1k
;
large_client_header_buffers
2
4k
;
client_max_body_size
1k
;
client_body_buffer_size
1k
;
ignore_invalid_headers
on
;
push_stream_shared_memory_size
100m
;
push_stream_max_channel_id_length
200
;
...
...
@@ -40,22 +24,21 @@ http {
# message ttl
push_stream_message_ttl
5m
;
# ping frequency
push_stream_ping_message_interval
10
s
;
push_stream_ping_message_interval
1
s
;
# connection ttl to enable recycle
push_stream_subscriber_connection_ttl
15m
;
# connection ttl for long polling
push_stream_longpolling_connection_ttl
30s
;
push_stream_timeout_with_body
off
;
# wildcard
push_stream_wildcard_channel_prefix
"broad_"
;
push_stream_wildcard_channel_max_qtd
3
;
#push_stream_message_template "{\"id\":~id~,\"channel\":\"~channel~\",\"text\":\"~text~\",\"eventid\":\"~event-id~\"}";
push_stream_message_template
"
{
\"id\":~id~,\"channel\":\"~channel~\",\"text\":\"~text~\"
}
"
;
push_stream_message_template
"
{
\"id\":~id~,\"channel\":\"~channel~\",\"text\":\"~text~\",
\
"tag
\
":
\
"~tag~
\
",
\
"time
\
":
\
"~time~
\
",
\
"eventid
\
":
\
"~event-id~
\
"
}
"
;
# subscriber may create channels on demand or only authorized
# (publisher) may do it?
# subscriber may create channels on demand or only authorized (publisher) may do it?
push_stream_authorized_channels_only
off
;
push_stream_wildcard_channel_max_qtd
3
;
push_stream_allowed_origins
"*"
;
...
...
@@ -82,7 +65,7 @@ http {
push_stream_channels_path
$arg_id
;
# store messages in memory
push_stream_store_messages
o
ff
;
push_stream_store_messages
o
n
;
# Message size limit
# client_max_body_size MUST be equal to client_body_buffer_size or
...
...
@@ -105,12 +88,17 @@ http {
push_stream_header_template
"<html><head><meta
http-equiv=
\
"Content-Type
\
"
content=
\
"text/html
;
charset=utf-8\">\r\n<meta
http-equiv=
\
"Cache-Control
\
"
content=
\
"no-store
\
">
\
r
\
n<meta
http-equiv=
\
"Cache-Control
\
"
content=
\
"no-cache
\
">
\
r
\
n<meta
http-equiv=
\
"Pragma
\
"
content=
\
"no-cache
\
">
\
r
\
n<meta
http-equiv=
\
"Expires
\
"
content=
\
"Thu,
1
Jan
1970
00
:
00
:
00
GMT
\
">
\
r
\
n<script
type=
\
"text/javascript
\
">
\
r
\
nwindow.onError
=
null
;
\r\ntry
{
document.domain
=
(window.location.hostname.match(/^(
\
d
{
1,3
}\
.)
{
3
}\
d
{
1,3
}
$
/
))
?
window.location.hostname
:
window.location.hostname.split('.').slice(-1
*
Math.max(window.location.hostname.split('.').length
-
1
,
(window.location.hostname.match(/(
\
w
{
4,
}\
.
\
w
{
2
}
|
\
.
\
w
{
3,
}
)
$
/
)
?
2
:
3
))).join('.')
;}
catch
(e)
{}
\r\nparent.PushStream.register
(this)
;
\r\n</script>\r\n</head>\r\n<body>"
;
# message template
#push_stream_message_template "<script>p(~id~,'~channel~','~text~','~event-id~');</script>";
push_stream_message_template
"<script>p(~id~,'~channel~','~text~')
;
</script>"
;
push_stream_message_template
"<script>p(~id~,'~channel~','~text~','~event-id~',
'~time~',
'~tag~')
;
</script>"
;
# footer to be sent when finishing subscriber connection
push_stream_footer_template
"</body></html>"
;
# content-type
default_type
"text/html
;
charset=utf-8"
;
if
(
$arg_qs
=
"on")
{
push_stream_last_received_message_time
"
$arg_time
"
;
push_stream_last_received_message_tag
"
$arg_tag
"
;
push_stream_last_event_id
"
$arg_eventid
"
;
}
}
location
~
/ev/(.*)
{
...
...
@@ -122,6 +110,12 @@ http {
if
(
$arg_tests
=
"on")
{
push_stream_channels_path
"test_
$1
"
;
}
if
(
$arg_qs
=
"on")
{
push_stream_last_received_message_time
"
$arg_time
"
;
push_stream_last_received_message_tag
"
$arg_tag
"
;
push_stream_last_event_id
"
$arg_eventid
"
;
}
}
location
~
/lp/(.*)
{
...
...
@@ -133,16 +127,21 @@ http {
if
(
$arg_tests
=
"on")
{
push_stream_channels_path
"test_
$1
"
;
}
if
(
$arg_qs
=
"on")
{
push_stream_last_received_message_time
"
$arg_time
"
;
push_stream_last_received_message_tag
"
$arg_tag
"
;
push_stream_last_event_id
"
$arg_eventid
"
;
}
}
location
~
/jsonp/(.*)
{
# activate long-polling mode for this location
push_stream_subscriber
long-polling
;
push_stream_message_template
"
{
\"id\":~id~,\"channel\":\"~channel~\",\"text\":\"~text~\",
\
"tag
\
":
\
"~tag~
\
",
\
"time
\
":
\
"~time~
\
"
}
"
;
push_stream_last_received_message_time
"
$arg_time
"
;
push_stream_last_received_message_tag
"
$arg_tag
"
;
push_stream_last_event_id
"
$arg_eventid
"
;
# positional channel path
push_stream_channels_path
$1
;
...
...
@@ -165,6 +164,12 @@ http {
push_stream_store_messages
on
;
push_stream_websocket_allow_publish
on
;
if
(
$arg_qs
=
"on")
{
push_stream_last_received_message_time
"
$arg_time
"
;
push_stream_last_received_message_tag
"
$arg_tag
"
;
push_stream_last_event_id
"
$arg_eventid
"
;
}
}
location
/
{
...
...
misc/spec/javascripts/PushStreamSpec.js
View file @
883aea05
This diff is collapsed.
Click to expand it.
misc/spec/publisher/properties_spec.rb
View file @
883aea05
...
...
@@ -356,6 +356,7 @@ describe "Publisher Properties" do
pub
.
callback
do
pub
.
response_header
[
'ACCESS_CONTROL_ALLOW_ORIGIN'
].
should
be_nil
pub
.
response_header
[
'ACCESS_CONTROL_ALLOW_METHODS'
].
should
be_nil
pub
.
response_header
[
'ACCESS_CONTROL_ALLOW_HEADERS'
].
should
be_nil
EventMachine
.
stop
end
...
...
@@ -373,6 +374,7 @@ describe "Publisher Properties" do
pub
.
callback
do
pub
.
response_header
[
'ACCESS_CONTROL_ALLOW_ORIGIN'
].
should
eql
(
"custom.domain.com"
)
pub
.
response_header
[
'ACCESS_CONTROL_ALLOW_METHODS'
].
should
eql
(
accepted_methods
)
pub
.
response_header
[
'ACCESS_CONTROL_ALLOW_HEADERS'
].
should
eql
(
"If-Modified-Since,If-None-Match,Etag,Event-Id,Event-Type,Last-Event-Id"
)
EventMachine
.
stop
end
...
...
misc/spec/subscriber/properties_spec.rb
View file @
883aea05
...
...
@@ -657,7 +657,7 @@ describe "Subscriber Properties" do
sub_1
.
stream
do
|
chunk
|
sub_1
.
response_header
[
'ACCESS_CONTROL_ALLOW_ORIGIN'
].
should
eql
(
"custom.domain.com"
)
sub_1
.
response_header
[
'ACCESS_CONTROL_ALLOW_METHODS'
].
should
eql
(
"GET"
)
sub_1
.
response_header
[
'ACCESS_CONTROL_ALLOW_HEADERS'
].
should
eql
(
"If-Modified-Since,If-None-Match"
)
sub_1
.
response_header
[
'ACCESS_CONTROL_ALLOW_HEADERS'
].
should
eql
(
"If-Modified-Since,If-None-Match
,Etag,Event-Id,Event-Type,Last-Event-Id
"
)
EventMachine
.
stop
end
...
...
src/ngx_http_push_stream_module_publisher.c
View file @
883aea05
...
...
@@ -43,6 +43,7 @@ ngx_http_push_stream_publisher_handler(ngx_http_request_t *r)
ngx_http_push_stream_add_response_header
(
r
,
&
NGX_HTTP_PUSH_STREAM_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN
,
&
cf
->
allowed_origins
);
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
);
ngx_http_push_stream_add_response_header
(
r
,
&
NGX_HTTP_PUSH_STREAM_HEADER_ACCESS_CONTROL_ALLOW_HEADERS
,
&
NGX_HTTP_PUSH_STREAM_ALLOWED_HEADERS
);
}
if
(
r
->
method
&
NGX_HTTP_OPTIONS
)
{
...
...
src/ngx_http_push_stream_module_setup.c
View file @
883aea05
...
...
@@ -195,19 +195,19 @@ static ngx_command_t ngx_http_push_stream_commands[] = {
offsetof
(
ngx_http_push_stream_loc_conf_t
,
websocket_allow_publish
),
NULL
},
{
ngx_string
(
"push_stream_last_received_message_time"
),
NGX_HTTP_MAIN_CONF
|
NGX_HTTP_SRV_CONF
|
NGX_HTTP_LOC_CONF
|
NGX_CONF_TAKE1
,
NGX_HTTP_MAIN_CONF
|
NGX_HTTP_SRV_CONF
|
NGX_HTTP_LOC_CONF
|
NGX_
HTTP_LIF_CONF
|
NGX_
CONF_TAKE1
,
ngx_http_set_complex_value_slot
,
NGX_HTTP_LOC_CONF_OFFSET
,
offsetof
(
ngx_http_push_stream_loc_conf_t
,
last_received_message_time
),
NULL
},
{
ngx_string
(
"push_stream_last_received_message_tag"
),
NGX_HTTP_MAIN_CONF
|
NGX_HTTP_SRV_CONF
|
NGX_HTTP_LOC_CONF
|
NGX_CONF_TAKE1
,
NGX_HTTP_MAIN_CONF
|
NGX_HTTP_SRV_CONF
|
NGX_HTTP_LOC_CONF
|
NGX_
HTTP_LIF_CONF
|
NGX_
CONF_TAKE1
,
ngx_http_set_complex_value_slot
,
NGX_HTTP_LOC_CONF_OFFSET
,
offsetof
(
ngx_http_push_stream_loc_conf_t
,
last_received_message_tag
),
NULL
},
{
ngx_string
(
"push_stream_last_event_id"
),
NGX_HTTP_MAIN_CONF
|
NGX_HTTP_SRV_CONF
|
NGX_HTTP_LOC_CONF
|
NGX_CONF_TAKE1
,
NGX_HTTP_MAIN_CONF
|
NGX_HTTP_SRV_CONF
|
NGX_HTTP_LOC_CONF
|
NGX_
HTTP_LIF_CONF
|
NGX_
CONF_TAKE1
,
ngx_http_set_complex_value_slot
,
NGX_HTTP_LOC_CONF_OFFSET
,
offsetof
(
ngx_http_push_stream_loc_conf_t
,
last_event_id
),
...
...
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