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
57c6ff7d
Commit
57c6ff7d
authored
Oct 23, 2011
by
Wandenberg Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace push_mode and publisher_admin for location_type to be generic
parent
7614c1bd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
20 deletions
+21
-20
ngx_http_push_stream_module.h
include/ngx_http_push_stream_module.h
+6
-4
ngx_http_push_stream_module_publisher.c
src/ngx_http_push_stream_module_publisher.c
+3
-3
ngx_http_push_stream_module_setup.c
src/ngx_http_push_stream_module_setup.c
+10
-11
ngx_http_push_stream_module_subscriber.c
src/ngx_http_push_stream_module_subscriber.c
+2
-2
No files found.
include/ngx_http_push_stream_module.h
View file @
57c6ff7d
...
...
@@ -74,9 +74,8 @@ typedef struct {
ngx_str_t
content_type
;
ngx_uint_t
broadcast_channel_max_qtd
;
ngx_uint_t
keepalive
;
ngx_uint_t
publisher_admin
;
ngx_flag_t
eventsource_support
;
ngx_uint_t
subscriber_mod
e
;
ngx_uint_t
location_typ
e
;
ngx_msec_t
ping_message_interval
;
ngx_msec_t
subscriber_connection_ttl
;
ngx_msec_t
longpolling_connection_ttl
;
...
...
@@ -239,8 +238,8 @@ 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_
PUBLISHER_
MODE_NORMAL
=
ngx_string
(
"normal"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_
PUBLISHER_
MODE_ADMIN
=
ngx_string
(
"admin"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_MODE_NORMAL
=
ngx_string
(
"normal"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_MODE_ADMIN
=
ngx_string
(
"admin"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_MODE_STREAMING
=
ngx_string
(
"streaming"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_MODE_POLLING
=
ngx_string
(
"polling"
);
...
...
@@ -249,6 +248,9 @@ static const ngx_str_t NGX_HTTP_PUSH_STREAM_MODE_LONGPOLLING = ngx_string("long
#define NGX_HTTP_PUSH_STREAM_SUBSCRIBER_MODE_STREAMING 0
#define NGX_HTTP_PUSH_STREAM_SUBSCRIBER_MODE_POLLING 1
#define NGX_HTTP_PUSH_STREAM_SUBSCRIBER_MODE_LONGPOLLING 2
#define NGX_HTTP_PUSH_STREAM_PUBLISHER_MODE_NORMAL 3
#define NGX_HTTP_PUSH_STREAM_PUBLISHER_MODE_ADMIN 4
#define NGX_HTTP_PUSH_STREAM_STATISTICS_MODE 5
// other stuff
...
...
src/ngx_http_push_stream_module_publisher.c
View file @
57c6ff7d
...
...
@@ -37,13 +37,13 @@ ngx_http_push_stream_publisher_handler(ngx_http_request_t *r)
r
->
keepalive
=
cf
->
keepalive
;
// only accept GET, POST and DELETE methods if enable publisher administration
if
(
cf
->
publisher_admin
&&
!
(
r
->
method
&
(
NGX_HTTP_GET
|
NGX_HTTP_POST
|
NGX_HTTP_DELETE
)))
{
if
(
(
cf
->
location_type
==
NGX_HTTP_PUSH_STREAM_PUBLISHER_MODE_ADMIN
)
&&
!
(
r
->
method
&
(
NGX_HTTP_GET
|
NGX_HTTP_POST
|
NGX_HTTP_DELETE
)))
{
ngx_http_push_stream_add_response_header
(
r
,
&
NGX_HTTP_PUSH_STREAM_HEADER_ALLOW
,
&
NGX_HTTP_PUSH_STREAM_ALLOW_GET_POST_DELETE_METHODS
);
return
ngx_http_push_stream_send_only_header_response
(
r
,
NGX_HTTP_NOT_ALLOWED
,
NULL
);
}
// only accept GET and POST methods if NOT enable publisher administration
if
(
!
cf
->
publisher_admin
&&
!
(
r
->
method
&
(
NGX_HTTP_GET
|
NGX_HTTP_POST
)))
{
if
(
(
cf
->
location_type
!=
NGX_HTTP_PUSH_STREAM_PUBLISHER_MODE_ADMIN
)
&&
!
(
r
->
method
&
(
NGX_HTTP_GET
|
NGX_HTTP_POST
)))
{
ngx_http_push_stream_add_response_header
(
r
,
&
NGX_HTTP_PUSH_STREAM_HEADER_ALLOW
,
&
NGX_HTTP_PUSH_STREAM_ALLOW_GET_POST_METHODS
);
return
ngx_http_push_stream_send_only_header_response
(
r
,
NGX_HTTP_NOT_ALLOWED
,
NULL
);
}
...
...
@@ -73,7 +73,7 @@ ngx_http_push_stream_publisher_handler(ngx_http_request_t *r)
return
ngx_http_push_stream_send_only_header_response
(
r
,
NGX_HTTP_NOT_FOUND
,
NULL
);
}
if
(
cf
->
publisher_admin
&&
(
r
->
method
==
NGX_HTTP_DELETE
))
{
if
(
(
cf
->
location_type
==
NGX_HTTP_PUSH_STREAM_PUBLISHER_MODE_ADMIN
)
&&
(
r
->
method
==
NGX_HTTP_DELETE
))
{
ngx_http_push_stream_delete_channel
(
id
,
r
->
pool
);
return
ngx_http_push_stream_send_only_header_response
(
r
,
NGX_HTTP_OK
,
&
NGX_HTTP_PUSH_STREAM_CHANNEL_DELETED
);
}
...
...
src/ngx_http_push_stream_module_setup.c
View file @
57c6ff7d
...
...
@@ -36,13 +36,13 @@ static ngx_command_t ngx_http_push_stream_commands[] = {
NGX_HTTP_LOC_CONF
|
NGX_CONF_NOARGS
|
NGX_CONF_TAKE1
,
ngx_http_push_stream_publisher
,
NGX_HTTP_LOC_CONF_OFFSET
,
offsetof
(
ngx_http_push_stream_loc_conf_t
,
publisher_admin
),
offsetof
(
ngx_http_push_stream_loc_conf_t
,
location_type
),
NULL
},
{
ngx_string
(
"push_stream_subscriber"
),
NGX_HTTP_LOC_CONF
|
NGX_CONF_NOARGS
|
NGX_CONF_TAKE1
,
ngx_http_push_stream_subscriber
,
NGX_HTTP_LOC_CONF_OFFSET
,
offsetof
(
ngx_http_push_stream_loc_conf_t
,
subscriber_mod
e
),
offsetof
(
ngx_http_push_stream_loc_conf_t
,
location_typ
e
),
NULL
},
/* Main directives*/
...
...
@@ -442,9 +442,8 @@ ngx_http_push_stream_create_loc_conf(ngx_conf_t *cf)
lcf
->
content_type
.
data
=
NULL
;
lcf
->
broadcast_channel_max_qtd
=
NGX_CONF_UNSET_UINT
;
lcf
->
keepalive
=
NGX_CONF_UNSET_UINT
;
lcf
->
publisher_admin
=
NGX_CONF_UNSET_UINT
;
lcf
->
location_type
=
NGX_CONF_UNSET_UINT
;
lcf
->
eventsource_support
=
NGX_CONF_UNSET_UINT
;
lcf
->
subscriber_mode
=
NGX_CONF_UNSET_UINT
;
lcf
->
ping_message_interval
=
NGX_CONF_UNSET_MSEC
;
lcf
->
subscriber_connection_ttl
=
NGX_CONF_UNSET_MSEC
;
lcf
->
longpolling_connection_ttl
=
NGX_CONF_UNSET_MSEC
;
...
...
@@ -466,7 +465,6 @@ ngx_http_push_stream_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_str_value
(
conf
->
content_type
,
prev
->
content_type
,
NGX_HTTP_PUSH_STREAM_DEFAULT_CONTENT_TYPE
);
ngx_conf_merge_uint_value
(
conf
->
broadcast_channel_max_qtd
,
prev
->
broadcast_channel_max_qtd
,
ngx_http_push_stream_module_main_conf
->
max_number_of_broadcast_channels
);
ngx_conf_merge_uint_value
(
conf
->
keepalive
,
prev
->
keepalive
,
0
);
ngx_conf_merge_uint_value
(
conf
->
publisher_admin
,
prev
->
publisher_admin
,
0
);
ngx_conf_merge_value
(
conf
->
eventsource_support
,
prev
->
eventsource_support
,
0
);
ngx_conf_merge_msec_value
(
conf
->
ping_message_interval
,
prev
->
ping_message_interval
,
NGX_CONF_UNSET_MSEC
);
ngx_conf_merge_msec_value
(
conf
->
subscriber_connection_ttl
,
prev
->
subscriber_connection_ttl
,
NGX_CONF_UNSET_MSEC
);
...
...
@@ -613,6 +611,7 @@ ngx_http_push_stream_channels_statistics(ngx_conf_t *cf, ngx_command_t *cmd, voi
if
(
rc
==
NGX_CONF_OK
)
{
ngx_http_push_stream_loc_conf_t
*
pslcf
=
conf
;
pslcf
->
location_type
=
NGX_HTTP_PUSH_STREAM_STATISTICS_MODE
;
pslcf
->
index_channel_id
=
ngx_http_get_variable_index
(
cf
,
&
ngx_http_push_stream_channel_id
);
if
(
pslcf
->
index_channel_id
==
NGX_ERROR
)
{
rc
=
NGX_CONF_ERROR
;
...
...
@@ -631,15 +630,15 @@ ngx_http_push_stream_publisher(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return
"is duplicate"
;
}
*
field
=
0
;
//default
*
field
=
NGX_HTTP_PUSH_STREAM_PUBLISHER_MODE_NORMAL
;
//default
if
(
cf
->
args
->
nelts
>
1
)
{
ngx_str_t
value
=
(((
ngx_str_t
*
)
cf
->
args
->
elts
)[
1
]);
if
((
value
.
len
==
NGX_HTTP_PUSH_STREAM_
PUBLISHER_MODE_NORMAL
.
len
)
&&
(
ngx_strncasecmp
(
value
.
data
,
NGX_HTTP_PUSH_STREAM_PUBLISHER_MODE_NORMAL
.
data
,
NGX_HTTP_PUSH_STREAM_PUBLISHER
_MODE_NORMAL
.
len
)
==
0
))
{
*
field
=
0
;
}
else
if
((
value
.
len
==
NGX_HTTP_PUSH_STREAM_
PUBLISHER_MODE_ADMIN
.
len
)
&&
(
ngx_strncasecmp
(
value
.
data
,
NGX_HTTP_PUSH_STREAM_PUBLISHER_MODE_ADMIN
.
data
,
NGX_HTTP_PUSH_STREAM_PUBLISHER
_MODE_ADMIN
.
len
)
==
0
))
{
*
field
=
1
;
if
((
value
.
len
==
NGX_HTTP_PUSH_STREAM_
MODE_NORMAL
.
len
)
&&
(
ngx_strncasecmp
(
value
.
data
,
NGX_HTTP_PUSH_STREAM_MODE_NORMAL
.
data
,
NGX_HTTP_PUSH_STREAM
_MODE_NORMAL
.
len
)
==
0
))
{
*
field
=
NGX_HTTP_PUSH_STREAM_PUBLISHER_MODE_NORMAL
;
}
else
if
((
value
.
len
==
NGX_HTTP_PUSH_STREAM_
MODE_ADMIN
.
len
)
&&
(
ngx_strncasecmp
(
value
.
data
,
NGX_HTTP_PUSH_STREAM_MODE_ADMIN
.
data
,
NGX_HTTP_PUSH_STREAM
_MODE_ADMIN
.
len
)
==
0
))
{
*
field
=
NGX_HTTP_PUSH_STREAM_PUBLISHER_MODE_ADMIN
;
}
else
{
ngx_conf_log_error
(
NGX_LOG_ERR
,
cf
,
0
,
"invalid push_stream_publisher mode value: %V, accepted values (%s, %s)"
,
&
value
,
NGX_HTTP_PUSH_STREAM_
PUBLISHER_MODE_NORMAL
.
data
,
NGX_HTTP_PUSH_STREAM_PUBLISHER
_MODE_ADMIN
.
data
);
ngx_conf_log_error
(
NGX_LOG_ERR
,
cf
,
0
,
"invalid push_stream_publisher mode value: %V, accepted values (%s, %s)"
,
&
value
,
NGX_HTTP_PUSH_STREAM_
MODE_NORMAL
.
data
,
NGX_HTTP_PUSH_STREAM
_MODE_ADMIN
.
data
);
return
NGX_CONF_ERROR
;
}
}
...
...
src/ngx_http_push_stream_module_subscriber.c
View file @
57c6ff7d
...
...
@@ -140,8 +140,8 @@ ngx_http_push_stream_subscriber_handler(ngx_http_request_t *r)
last_event_id
=
ngx_http_push_stream_get_header
(
r
,
&
NGX_HTTP_PUSH_STREAM_HEADER_LAST_EVENT_ID
);
push_mode
=
ngx_http_push_stream_get_header
(
r
,
&
NGX_HTTP_PUSH_STREAM_HEADER_MODE
);
polling
=
((
cf
->
subscriber_mod
e
==
NGX_HTTP_PUSH_STREAM_SUBSCRIBER_MODE_POLLING
)
||
((
push_mode
!=
NULL
)
&&
(
push_mode
->
len
==
NGX_HTTP_PUSH_STREAM_MODE_POLLING
.
len
)
&&
(
ngx_strncasecmp
(
push_mode
->
data
,
NGX_HTTP_PUSH_STREAM_MODE_POLLING
.
data
,
NGX_HTTP_PUSH_STREAM_MODE_POLLING
.
len
)
==
0
)));
longpolling
=
((
cf
->
subscriber_mod
e
==
NGX_HTTP_PUSH_STREAM_SUBSCRIBER_MODE_LONGPOLLING
)
||
((
push_mode
!=
NULL
)
&&
(
push_mode
->
len
==
NGX_HTTP_PUSH_STREAM_MODE_LONGPOLLING
.
len
)
&&
(
ngx_strncasecmp
(
push_mode
->
data
,
NGX_HTTP_PUSH_STREAM_MODE_LONGPOLLING
.
data
,
NGX_HTTP_PUSH_STREAM_MODE_LONGPOLLING
.
len
)
==
0
)));
polling
=
((
cf
->
location_typ
e
==
NGX_HTTP_PUSH_STREAM_SUBSCRIBER_MODE_POLLING
)
||
((
push_mode
!=
NULL
)
&&
(
push_mode
->
len
==
NGX_HTTP_PUSH_STREAM_MODE_POLLING
.
len
)
&&
(
ngx_strncasecmp
(
push_mode
->
data
,
NGX_HTTP_PUSH_STREAM_MODE_POLLING
.
data
,
NGX_HTTP_PUSH_STREAM_MODE_POLLING
.
len
)
==
0
)));
longpolling
=
((
cf
->
location_typ
e
==
NGX_HTTP_PUSH_STREAM_SUBSCRIBER_MODE_LONGPOLLING
)
||
((
push_mode
!=
NULL
)
&&
(
push_mode
->
len
==
NGX_HTTP_PUSH_STREAM_MODE_LONGPOLLING
.
len
)
&&
(
ngx_strncasecmp
(
push_mode
->
data
,
NGX_HTTP_PUSH_STREAM_MODE_LONGPOLLING
.
data
,
NGX_HTTP_PUSH_STREAM_MODE_LONGPOLLING
.
len
)
==
0
)));
if
(
polling
||
longpolling
)
{
ngx_int_t
result
=
ngx_http_push_stream_subscriber_polling_handler
(
r
,
channels_ids
,
if_modified_since
,
last_event_id
,
longpolling
,
temp_pool
);
...
...
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