Commit 2391ddbc authored by Wandenberg's avatar Wandenberg

removed push_stream_content_type directive, use default_type Nginx directive...

removed push_stream_content_type directive, use default_type Nginx directive to set the value, except on JSONP and Event Source modes
parent 84b87d59
h1(#changelog). Changelog h1(#changelog). Changelog
* Removed push_stream_content_type directive, use default_type Nginx directive to set the value, except on JSONP and Event Source modes
* Removed push_stream_keepalive directive, let Nginx decide when to use keepalive and how many requests accept using keepalive_* directives * Removed push_stream_keepalive directive, let Nginx decide when to use keepalive and how many requests accept using keepalive_* directives
* Removed push_stream_shared_memory_cleanup_objects_ttl directive * Removed push_stream_shared_memory_cleanup_objects_ttl directive
* Changed push_stream_websocket directive to be a subtype of push_stream_subscriber directive * Changed push_stream_websocket directive to be a subtype of push_stream_subscriber directive
......
...@@ -122,7 +122,6 @@ h1(#directives). Directives ...@@ -122,7 +122,6 @@ h1(#directives). Directives
| "push_stream_header_template":push_stream_header_template |   - |   - |   x |   - |   - |   x | | "push_stream_header_template":push_stream_header_template |   - |   - |   x |   - |   - |   x |
| "push_stream_message_template":push_stream_message_template |   - |   - |   x |   - |   - |   x | | "push_stream_message_template":push_stream_message_template |   - |   - |   x |   - |   - |   x |
| "push_stream_footer_template":push_stream_footer_template |   - |   - |   x |   - |   - |   x | | "push_stream_footer_template":push_stream_footer_template |   - |   - |   x |   - |   - |   x |
| "push_stream_content_type":push_stream_content_type |   - |   - |   x |   - |   - |   - |
| "push_stream_broadcast_channel_max_qtd":push_stream_broadcast_channel_max_qtd |   - |   - |   x |   - |   - |   x | | "push_stream_broadcast_channel_max_qtd":push_stream_broadcast_channel_max_qtd |   - |   - |   x |   - |   - |   x |
| "push_stream_ping_message_interval":push_stream_ping_message_interval |   - |   - |   x |   - |   - |   x | | "push_stream_ping_message_interval":push_stream_ping_message_interval |   - |   - |   x |   - |   - |   x |
| "push_stream_subscriber_connection_ttl":push_stream_subscriber_connection_ttl |   - |   - |   x |   - |   - |   x | | "push_stream_subscriber_connection_ttl":push_stream_subscriber_connection_ttl |   - |   - |   x |   - |   - |   x |
...@@ -226,7 +225,6 @@ h1(#contributors). Contributors ...@@ -226,7 +225,6 @@ h1(#contributors). Contributors
[push_stream_header_template]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_header_template [push_stream_header_template]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_header_template
[push_stream_message_template]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_message_template [push_stream_message_template]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_message_template
[push_stream_footer_template]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_footer_template [push_stream_footer_template]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_footer_template
[push_stream_content_type]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_content_type
[push_stream_broadcast_channel_max_qtd]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_broadcast_channel_max_qtd [push_stream_broadcast_channel_max_qtd]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_broadcast_channel_max_qtd
[push_stream_ping_message_interval]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_ping_message_interval [push_stream_ping_message_interval]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_ping_message_interval
[push_stream_subscriber_connection_ttl]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_subscriber_connection_ttl [push_stream_subscriber_connection_ttl]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_subscriber_connection_ttl
......
...@@ -133,17 +133,6 @@ h2(#push_stream_footer_template). push_stream_footer_template <a name="push_stre ...@@ -133,17 +133,6 @@ h2(#push_stream_footer_template). push_stream_footer_template <a name="push_stre
The text that will be sent to subscribers before connection is closed (channel deleted or subscriber timeout), except when long polling connections timed out. The text that will be sent to subscribers before connection is closed (channel deleted or subscriber timeout), except when long polling connections timed out.
h2(#push_stream_content_type). push_stream_content_type <a name="push_stream_content_type" href="#">&nbsp;</a>
*syntax:* _push_stream_content_type string_
*default:* _text/plain_
*context:* _location (push_stream_subscriber)_
The content type used on responses to subscribers. Must be complient with push_stream_header_template, push_stream_message_template and push_stream_footer_template.
h2(#push_stream_broadcast_channel_max_qtd). push_stream_broadcast_channel_max_qtd <a name="push_stream_broadcast_channel_max_qtd" href="#">&nbsp;</a> h2(#push_stream_broadcast_channel_max_qtd). push_stream_broadcast_channel_max_qtd <a name="push_stream_broadcast_channel_max_qtd" href="#">&nbsp;</a>
*syntax:* _push_stream_broadcast_channel_max_qtd number_ *syntax:* _push_stream_broadcast_channel_max_qtd number_
......
...@@ -31,7 +31,7 @@ Create a html page with the content on **Client** part, access it from browser a ...@@ -31,7 +31,7 @@ Create a html page with the content on **Client** part, access it from browser a
# footer to be sent when finishing subscriber connection # footer to be sent when finishing subscriber connection
push_stream_footer_template "</body></html>"; push_stream_footer_template "</body></html>";
# content-type # content-type
push_stream_content_type "text/html; charset=utf-8"; default_type "text/html; charset=utf-8";
# ping frequency # ping frequency
push_stream_ping_message_interval 10s; push_stream_ping_message_interval 10s;
} }
...@@ -103,7 +103,7 @@ If needed you can change this behavior changing the javascript usage, like the e ...@@ -103,7 +103,7 @@ If needed you can change this behavior changing the javascript usage, like the e
# footer to be sent when finishing subscriber connection # footer to be sent when finishing subscriber connection
push_stream_footer_template "</body></html>"; push_stream_footer_template "</body></html>";
# content-type # content-type
push_stream_content_type "text/html; charset=utf-8"; default_type "text/html; charset=utf-8";
# ping frequency # ping frequency
push_stream_ping_message_interval 10s; push_stream_ping_message_interval 10s;
} }
......
...@@ -74,7 +74,6 @@ typedef struct { ...@@ -74,7 +74,6 @@ typedef struct {
ngx_str_t message_template; ngx_str_t message_template;
ngx_int_t message_template_index; ngx_int_t message_template_index;
ngx_str_t footer_template; ngx_str_t footer_template;
ngx_str_t content_type;
ngx_uint_t broadcast_channel_max_qtd; ngx_uint_t broadcast_channel_max_qtd;
ngx_uint_t location_type; ngx_uint_t location_type;
ngx_msec_t ping_message_interval; ngx_msec_t ping_message_interval;
......
...@@ -49,8 +49,6 @@ static time_t NGX_HTTP_PUSH_STREAM_DEFAULT_CHANNEL_INACTIVITY_TIME = 30; ...@@ -49,8 +49,6 @@ static time_t NGX_HTTP_PUSH_STREAM_DEFAULT_CHANNEL_INACTIVITY_TIME = 30;
#define NGX_HTTP_PUSH_STREAM_DEFAULT_PADDING_BY_USER_AGENT "[A|a]ndroid 2,4097,4097:[S|s]afari,1025,0" #define NGX_HTTP_PUSH_STREAM_DEFAULT_PADDING_BY_USER_AGENT "[A|a]ndroid 2,4097,4097:[S|s]afari,1025,0"
#define NGX_HTTP_PUSH_STREAM_DEFAULT_CONTENT_TYPE "text/plain"
#define NGX_HTTP_PUSH_STREAM_DEFAULT_BROADCAST_CHANNEL_PREFIX "" #define NGX_HTTP_PUSH_STREAM_DEFAULT_BROADCAST_CHANNEL_PREFIX ""
static char * ngx_http_push_stream_channels_statistics(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static char * ngx_http_push_stream_channels_statistics(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
......
...@@ -5,7 +5,7 @@ error_log logs/nginx-main_error.log debug; ...@@ -5,7 +5,7 @@ error_log logs/nginx-main_error.log debug;
master_process off; master_process off;
daemon off; daemon off;
worker_rlimit_core 500M; worker_rlimit_core 500M;
working_directory /tmp/nginx; working_directory /tmp;
worker_processes 2; worker_processes 2;
...@@ -106,7 +106,7 @@ http { ...@@ -106,7 +106,7 @@ http {
# footer to be sent when finishing subscriber connection # footer to be sent when finishing subscriber connection
push_stream_footer_template "</body></html>"; push_stream_footer_template "</body></html>";
# content-type # content-type
push_stream_content_type "text/html; charset=utf-8"; default_type "text/html; charset=utf-8";
} }
location ~ /ev/(.*) { location ~ /ev/(.*) {
......
...@@ -175,7 +175,7 @@ http { ...@@ -175,7 +175,7 @@ http {
# positional channel path # positional channel path
<%= write_directive("push_stream_channels_path", channels_path) %> <%= write_directive("push_stream_channels_path", channels_path) %>
<%= write_directive("push_stream_content_type", content_type, "content-type") %> <%= write_directive("default_type", content_type, "content-type") %>
} }
<%= extra_location %> <%= extra_location %>
......
...@@ -263,9 +263,8 @@ ngx_http_push_stream_send_response_all_channels_info_detailed(ngx_http_request_t ...@@ -263,9 +263,8 @@ ngx_http_push_stream_send_response_all_channels_info_detailed(ngx_http_request_t
content_len += header_response->len + tail->len; content_len += header_response->len + tail->len;
r->headers_out.content_type.len = subtype->content_type->len;
r->headers_out.content_type.data = subtype->content_type->data;
r->headers_out.content_type_len = subtype->content_type->len; r->headers_out.content_type_len = subtype->content_type->len;
r->headers_out.content_type = *subtype->content_type;
r->headers_out.content_length_n = content_len; r->headers_out.content_length_n = content_len;
r->headers_out.status = NGX_HTTP_OK; r->headers_out.status = NGX_HTTP_OK;
......
...@@ -164,12 +164,6 @@ static ngx_command_t ngx_http_push_stream_commands[] = { ...@@ -164,12 +164,6 @@ static ngx_command_t ngx_http_push_stream_commands[] = {
NGX_HTTP_LOC_CONF_OFFSET, NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_push_stream_loc_conf_t, footer_template), offsetof(ngx_http_push_stream_loc_conf_t, footer_template),
NULL }, NULL },
{ ngx_string("push_stream_content_type"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_str_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_push_stream_loc_conf_t, content_type),
NULL },
{ ngx_string("push_stream_broadcast_channel_max_qtd"), { ngx_string("push_stream_broadcast_channel_max_qtd"),
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_CONF_TAKE1,
ngx_conf_set_num_slot, ngx_conf_set_num_slot,
...@@ -519,7 +513,6 @@ ngx_http_push_stream_create_loc_conf(ngx_conf_t *cf) ...@@ -519,7 +513,6 @@ ngx_http_push_stream_create_loc_conf(ngx_conf_t *cf)
lcf->message_template.data = NULL; lcf->message_template.data = NULL;
lcf->header_template.data = NULL; lcf->header_template.data = NULL;
lcf->footer_template.data = NULL; lcf->footer_template.data = NULL;
lcf->content_type.data = NULL;
lcf->broadcast_channel_max_qtd = NGX_CONF_UNSET_UINT; lcf->broadcast_channel_max_qtd = NGX_CONF_UNSET_UINT;
lcf->location_type = NGX_CONF_UNSET_UINT; lcf->location_type = NGX_CONF_UNSET_UINT;
lcf->ping_message_interval = NGX_CONF_UNSET_MSEC; lcf->ping_message_interval = NGX_CONF_UNSET_MSEC;
...@@ -548,7 +541,6 @@ ngx_http_push_stream_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) ...@@ -548,7 +541,6 @@ ngx_http_push_stream_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_str_value(conf->header_template, prev->header_template, NGX_HTTP_PUSH_STREAM_DEFAULT_HEADER_TEMPLATE); ngx_conf_merge_str_value(conf->header_template, prev->header_template, NGX_HTTP_PUSH_STREAM_DEFAULT_HEADER_TEMPLATE);
ngx_conf_merge_str_value(conf->message_template, prev->message_template, NGX_HTTP_PUSH_STREAM_DEFAULT_MESSAGE_TEMPLATE); ngx_conf_merge_str_value(conf->message_template, prev->message_template, NGX_HTTP_PUSH_STREAM_DEFAULT_MESSAGE_TEMPLATE);
ngx_conf_merge_str_value(conf->footer_template, prev->footer_template, NGX_HTTP_PUSH_STREAM_DEFAULT_FOOTER_TEMPLATE); ngx_conf_merge_str_value(conf->footer_template, prev->footer_template, NGX_HTTP_PUSH_STREAM_DEFAULT_FOOTER_TEMPLATE);
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->broadcast_channel_max_qtd, prev->broadcast_channel_max_qtd, ngx_http_push_stream_module_main_conf->max_number_of_broadcast_channels);
ngx_conf_merge_msec_value(conf->ping_message_interval, prev->ping_message_interval, NGX_CONF_UNSET_MSEC); 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); ngx_conf_merge_msec_value(conf->subscriber_connection_ttl, prev->subscriber_connection_ttl, NGX_CONF_UNSET_MSEC);
...@@ -600,9 +592,6 @@ ngx_http_push_stream_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) ...@@ -600,9 +592,6 @@ ngx_http_push_stream_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
// changing properties for event source support // changing properties for event source support
if (conf->location_type == NGX_HTTP_PUSH_STREAM_SUBSCRIBER_MODE_EVENTSOURCE) { if (conf->location_type == NGX_HTTP_PUSH_STREAM_SUBSCRIBER_MODE_EVENTSOURCE) {
conf->content_type.data = NGX_HTTP_PUSH_STREAM_EVENTSOURCE_CONTENT_TYPE.data;
conf->content_type.len = NGX_HTTP_PUSH_STREAM_EVENTSOURCE_CONTENT_TYPE.len;
// formatting header template // formatting header template
if (conf->header_template.len > 0) { if (conf->header_template.len > 0) {
ngx_str_t *aux = ngx_http_push_stream_apply_template_to_each_line(&conf->header_template, &NGX_HTTP_PUSH_STREAM_EVENTSOURCE_COMMENT_TEMPLATE, cf->pool); ngx_str_t *aux = ngx_http_push_stream_apply_template_to_each_line(&conf->header_template, &NGX_HTTP_PUSH_STREAM_EVENTSOURCE_COMMENT_TEMPLATE, cf->pool);
......
...@@ -486,8 +486,13 @@ ngx_http_push_stream_subscriber_prepare_request_to_keep_connected(ngx_http_reque ...@@ -486,8 +486,13 @@ ngx_http_push_stream_subscriber_prepare_request_to_keep_connected(ngx_http_reque
r->read_event_handler = ngx_http_test_reading; r->read_event_handler = ngx_http_test_reading;
r->write_event_handler = ngx_http_request_empty_handler; r->write_event_handler = ngx_http_request_empty_handler;
r->headers_out.content_type = cf->content_type; if (cf->location_type == NGX_HTTP_PUSH_STREAM_SUBSCRIBER_MODE_EVENTSOURCE) {
r->headers_out.content_type_len = cf->content_type.len; r->headers_out.content_type_len = NGX_HTTP_PUSH_STREAM_EVENTSOURCE_CONTENT_TYPE.len;
r->headers_out.content_type = NGX_HTTP_PUSH_STREAM_EVENTSOURCE_CONTENT_TYPE;
} else {
ngx_http_set_content_type(r);
}
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;
......
...@@ -533,9 +533,8 @@ ngx_http_push_stream_send_response(ngx_http_request_t *r, ngx_str_t *text, const ...@@ -533,9 +533,8 @@ ngx_http_push_stream_send_response(ngx_http_request_t *r, ngx_str_t *text, const
return NGX_HTTP_INTERNAL_SERVER_ERROR; return NGX_HTTP_INTERNAL_SERVER_ERROR;
} }
r->headers_out.content_type.len = content_type->len;
r->headers_out.content_type.data = content_type->data;
r->headers_out.content_type_len = content_type->len; r->headers_out.content_type_len = content_type->len;
r->headers_out.content_type = *content_type;
r->headers_out.content_length_n = text->len; r->headers_out.content_length_n = text->len;
r->headers_out.status = status_code; r->headers_out.status = status_code;
...@@ -1432,12 +1431,14 @@ ngx_http_push_stream_apply_template_to_each_line(ngx_str_t *text, const ngx_str_ ...@@ -1432,12 +1431,14 @@ 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_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 (ctx->callback != NULL) {
r->headers_out.content_type_len = content_type.len; r->headers_out.content_type_len = NGX_HTTP_PUSH_STREAM_CALLBACK_CONTENT_TYPE.len;
r->headers_out.content_type = NGX_HTTP_PUSH_STREAM_CALLBACK_CONTENT_TYPE;
} else {
ngx_http_set_content_type(r);
}
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment