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
990acc30
Commit
990acc30
authored
Dec 31, 2014
by
Wandenberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change padding on eventsource mode to be a comment instead of a CRLF
parent
5c80c3f4
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
152 additions
and
86 deletions
+152
-86
ngx_http_push_stream_module.h
include/ngx_http_push_stream_module.h
+1
-0
padding_by_user_agent_spec.rb
misc/spec/subscriber/padding_by_user_agent_spec.rb
+115
-84
ngx_http_push_stream_module_setup.c
src/ngx_http_push_stream_module_setup.c
+32
-1
ngx_http_push_stream_module_utils.c
src/ngx_http_push_stream_module_utils.c
+4
-1
No files found.
include/ngx_http_push_stream_module.h
View file @
990acc30
...
...
@@ -242,6 +242,7 @@ struct ngx_http_push_stream_shm_data_s {
ngx_shm_zone_t
*
ngx_http_push_stream_global_shm_zone
=
NULL
;
ngx_str_t
**
ngx_http_push_stream_module_paddings_chunks
=
NULL
;
ngx_str_t
**
ngx_http_push_stream_module_paddings_chunks_for_eventsource
=
NULL
;
// channel
static
ngx_int_t
ngx_http_push_stream_send_response_all_channels_info_summarized
(
ngx_http_request_t
*
r
);
...
...
misc/spec/subscriber/padding_by_user_agent_spec.rb
View file @
990acc30
This diff is collapsed.
Click to expand it.
src/ngx_http_push_stream_module_setup.c
View file @
990acc30
...
...
@@ -380,7 +380,38 @@ ngx_http_push_stream_postconfig(ngx_conf_t *cf)
ngx_conf_log_error
(
NGX_LOG_ERR
,
cf
,
0
,
"push stream module: unable to allocate memory to create padding messages"
);
return
NGX_ERROR
;
}
padding
->
data
=
aux
->
data
;
padding
->
data
=
&
aux
->
data
[
aux
->
len
-
len
];
padding
->
len
=
len
;
len
=
i
*
100
;
}
}
if
((
ngx_http_push_stream_padding_max_len
>
0
)
&&
(
ngx_http_push_stream_module_paddings_chunks_for_eventsource
==
NULL
))
{
ngx_uint_t
steps
=
ngx_http_push_stream_padding_max_len
/
100
;
if
((
ngx_http_push_stream_module_paddings_chunks_for_eventsource
=
ngx_palloc
(
cf
->
pool
,
sizeof
(
ngx_str_t
)
*
(
steps
+
1
)))
==
NULL
)
{
ngx_conf_log_error
(
NGX_LOG_ERR
,
cf
,
0
,
"push stream module: unable to allocate memory to create padding messages for eventsource"
);
return
NGX_ERROR
;
}
u_int
padding_max_len
=
ngx_http_push_stream_padding_max_len
+
((
ngx_http_push_stream_padding_max_len
%
2
)
?
1
:
0
);
ngx_str_t
*
aux
=
ngx_http_push_stream_create_str
(
cf
->
pool
,
padding_max_len
);
if
(
aux
==
NULL
)
{
ngx_conf_log_error
(
NGX_LOG_ERR
,
cf
,
0
,
"push stream module: unable to allocate memory to create padding messages value"
);
return
NGX_ERROR
;
}
ngx_memset
(
aux
->
data
,
':'
,
padding_max_len
);
padding_max_len
-=
2
;
ngx_memcpy
(
aux
->
data
+
padding_max_len
,
CRLF
,
2
);
ngx_int_t
i
,
len
=
ngx_http_push_stream_padding_max_len
;
for
(
i
=
steps
;
i
>=
0
;
i
--
)
{
ngx_str_t
*
padding
=
ngx_pcalloc
(
cf
->
pool
,
sizeof
(
ngx_str_t
));
if
((
*
(
ngx_http_push_stream_module_paddings_chunks_for_eventsource
+
i
)
=
padding
)
==
NULL
)
{
ngx_conf_log_error
(
NGX_LOG_ERR
,
cf
,
0
,
"push stream module: unable to allocate memory to create padding messages"
);
return
NGX_ERROR
;
}
padding
->
data
=
&
aux
->
data
[
aux
->
len
-
len
];
padding
->
len
=
len
;
len
=
i
*
100
;
}
...
...
src/ngx_http_push_stream_module_utils.c
View file @
990acc30
...
...
@@ -648,11 +648,14 @@ static ngx_int_t
ngx_http_push_stream_send_response_padding
(
ngx_http_request_t
*
r
,
size_t
len
,
ngx_flag_t
sending_header
)
{
ngx_http_push_stream_module_ctx_t
*
ctx
=
ngx_http_get_module_ctx
(
r
,
ngx_http_push_stream_module
);
ngx_http_push_stream_loc_conf_t
*
pslcf
=
ngx_http_get_module_loc_conf
(
r
,
ngx_http_push_stream_module
);
ngx_flag_t
eventsource
=
(
pslcf
->
location_type
==
NGX_HTTP_PUSH_STREAM_SUBSCRIBER_MODE_EVENTSOURCE
);
if
(
ctx
->
padding
!=
NULL
)
{
ngx_int_t
diff
=
((
sending_header
)
?
ctx
->
padding
->
header_min_len
:
ctx
->
padding
->
message_min_len
)
-
len
;
if
(
diff
>
0
)
{
ngx_str_t
*
padding
=
*
(
ngx_http_push_stream_module_paddings_chunks
+
diff
/
100
);
ngx_int_t
padding_index
=
diff
/
100
;
ngx_str_t
*
padding
=
eventsource
?
ngx_http_push_stream_module_paddings_chunks_for_eventsource
[
padding_index
]
:
ngx_http_push_stream_module_paddings_chunks
[
padding_index
];
ngx_http_push_stream_send_response_text
(
r
,
padding
->
data
,
padding
->
len
,
0
);
}
}
...
...
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