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
ec18573c
Commit
ec18573c
authored
Jun 08, 2011
by
Wandenberg Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor of publisher to put post handler in a different function to be reusable
parent
7777234d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
35 deletions
+45
-35
ngx_http_push_stream_module.h
include/ngx_http_push_stream_module.h
+1
-1
ngx_http_push_stream_module_publisher.c
src/ngx_http_push_stream_module_publisher.c
+44
-34
No files found.
include/ngx_http_push_stream_module.h
View file @
ec18573c
...
@@ -206,7 +206,7 @@ static const ngx_str_t NGX_HTTP_PUSH_STREAM_HEADER_ALLOW = ngx_string("Allow");
...
@@ -206,7 +206,7 @@ static const ngx_str_t NGX_HTTP_PUSH_STREAM_HEADER_ALLOW = ngx_string("Allow");
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_EXPLAIN
=
ngx_string
(
"X-Nginx-PushStream-Explain"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_EXPLAIN
=
ngx_string
(
"X-Nginx-PushStream-Explain"
);
// other stuff
// other stuff
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_ALLOW
ED
_METHODS
=
ngx_string
(
"GET, POST"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_ALLOW
_GET_POST
_METHODS
=
ngx_string
(
"GET, POST"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_ALLOW_GET
=
ngx_string
(
"GET"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_ALLOW_GET
=
ngx_string
(
"GET"
);
#define NGX_HTTP_PUSH_STREAM_CHECK_AND_FINALIZE_REQUEST_ON_ERROR(val, fail, r, errormessage) \
#define NGX_HTTP_PUSH_STREAM_CHECK_AND_FINALIZE_REQUEST_ON_ERROR(val, fail, r, errormessage) \
...
...
src/ngx_http_push_stream_module_publisher.c
View file @
ec18573c
...
@@ -25,10 +25,11 @@
...
@@ -25,10 +25,11 @@
#include <ngx_http_push_stream_module_publisher.h>
#include <ngx_http_push_stream_module_publisher.h>
static
ngx_int_t
ngx_http_push_stream_publisher_handle_post
(
ngx_http_push_stream_loc_conf_t
*
cf
,
ngx_http_request_t
*
r
,
ngx_str_t
*
id
);
static
ngx_int_t
static
ngx_int_t
ngx_http_push_stream_publisher_handler
(
ngx_http_request_t
*
r
)
ngx_http_push_stream_publisher_handler
(
ngx_http_request_t
*
r
)
{
{
ngx_int_t
rc
;
ngx_str_t
*
id
=
NULL
;
ngx_str_t
*
id
=
NULL
;
ngx_http_push_stream_channel_t
*
channel
=
NULL
;
ngx_http_push_stream_channel_t
*
channel
=
NULL
;
ngx_http_push_stream_loc_conf_t
*
cf
=
ngx_http_get_module_loc_conf
(
r
,
ngx_http_push_stream_module
);
ngx_http_push_stream_loc_conf_t
*
cf
=
ngx_http_get_module_loc_conf
(
r
,
ngx_http_push_stream_module
);
...
@@ -38,7 +39,7 @@ ngx_http_push_stream_publisher_handler(ngx_http_request_t *r)
...
@@ -38,7 +39,7 @@ ngx_http_push_stream_publisher_handler(ngx_http_request_t *r)
// only accept GET and POST methods
// only accept GET and POST methods
if
(
!
(
r
->
method
&
(
NGX_HTTP_GET
|
NGX_HTTP_POST
)))
{
if
(
!
(
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
ED
_METHODS
);
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
);
return
ngx_http_push_stream_send_only_header_response
(
r
,
NGX_HTTP_NOT_ALLOWED
,
NULL
);
}
}
...
@@ -59,6 +60,23 @@ ngx_http_push_stream_publisher_handler(ngx_http_request_t *r)
...
@@ -59,6 +60,23 @@ ngx_http_push_stream_publisher_handler(ngx_http_request_t *r)
channel
=
ngx_http_push_stream_find_channel
(
id
,
r
->
connection
->
log
);
channel
=
ngx_http_push_stream_find_channel
(
id
,
r
->
connection
->
log
);
if
(
r
->
method
==
NGX_HTTP_POST
)
{
if
(
r
->
method
==
NGX_HTTP_POST
)
{
return
ngx_http_push_stream_publisher_handle_post
(
cf
,
r
,
id
);
}
// GET only make sense with a previous existing channel
if
(
channel
==
NULL
)
{
return
ngx_http_push_stream_send_only_header_response
(
r
,
NGX_HTTP_NOT_FOUND
,
NULL
);
}
return
ngx_http_push_stream_send_response_channel_info
(
r
,
channel
);
}
static
ngx_int_t
ngx_http_push_stream_publisher_handle_post
(
ngx_http_push_stream_loc_conf_t
*
cf
,
ngx_http_request_t
*
r
,
ngx_str_t
*
id
)
{
ngx_int_t
rc
;
ngx_http_push_stream_channel_t
*
channel
=
NULL
;
// check if channel id isn't equals to ALL
// check if channel id isn't equals to ALL
if
(
ngx_memn2cmp
(
id
->
data
,
NGX_HTTP_PUSH_STREAM_ALL_CHANNELS_INFO_ID
.
data
,
id
->
len
,
NGX_HTTP_PUSH_STREAM_ALL_CHANNELS_INFO_ID
.
len
)
==
0
)
{
if
(
ngx_memn2cmp
(
id
->
data
,
NGX_HTTP_PUSH_STREAM_ALL_CHANNELS_INFO_ID
.
data
,
id
->
len
,
NGX_HTTP_PUSH_STREAM_ALL_CHANNELS_INFO_ID
.
len
)
==
0
)
{
return
ngx_http_push_stream_send_only_header_response
(
r
,
NGX_HTTP_FORBIDDEN
,
&
NGX_HTTP_PUSH_STREAM_NO_CHANNEL_ID_NOT_AUTHORIZED_MESSAGE
);
return
ngx_http_push_stream_send_only_header_response
(
r
,
NGX_HTTP_FORBIDDEN
,
&
NGX_HTTP_PUSH_STREAM_NO_CHANNEL_ID_NOT_AUTHORIZED_MESSAGE
);
...
@@ -92,14 +110,6 @@ ngx_http_push_stream_publisher_handler(ngx_http_request_t *r)
...
@@ -92,14 +110,6 @@ ngx_http_push_stream_publisher_handler(ngx_http_request_t *r)
}
}
return
NGX_DONE
;
return
NGX_DONE
;
}
// GET only make sense with a previous existing channel
if
(
channel
==
NULL
)
{
return
ngx_http_push_stream_send_only_header_response
(
r
,
NGX_HTTP_NOT_FOUND
,
NULL
);
}
return
ngx_http_push_stream_send_response_channel_info
(
r
,
channel
);
}
}
static
void
static
void
...
...
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