Commit 3b89b897 authored by Wandenberg Peixoto's avatar Wandenberg Peixoto

add push_stream_channel_info_on_publish directive to be possible disable publish feedback stats

parent 064d4a3a
......@@ -138,6 +138,7 @@ h1(#directives). Directives
| "push_stream_websocket_allow_publish":push_stream_websocket_allow_publish |   - |   - |   - |   - |   - |   x |
| "push_stream_store_messages":push_stream_store_messages |   - |   - |   - |   x |   - |   x |
| "push_stream_keepalive":push_stream_keepalive |   - |   - |   - |   x |   x |   - |
| "push_stream_channel_info_on_publish":push_stream_channel_info_on_publish |   - |   - |   - |   x |   - |   - |
h1(#installation). Installation <a name="installation" href="#">&nbsp;</a>
......@@ -247,4 +248,5 @@ h1(#contributors). Contributors
[push_stream_padding_by_user_agent]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_padding_by_user_agent
[push_stream_store_messages]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/publishers.textile#push_stream_store_messages
[push_stream_keepalive]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/publishers.textile#push_stream_keepalive
[push_stream_channel_info_on_publish]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/publishers.textile#push_stream_channel_info_on_publish
[push_stream_websocket_allow_publish]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_websocket_allow_publish
......@@ -56,3 +56,15 @@ h2(#push_stream_keepalive). push_stream_keepalive <a name="push_stream_keepalive
*release version:* _0.2.4_
Enable keepalive connections, on publisher or channels statistics locations.
h2(#push_stream_channel_info_on_publish). push_stream_channel_info_on_publish <a name="push_stream_channel_info_on_publish" href="#">&nbsp;</a>
*syntax:* _push_stream_channel_info_on_publish on | off_
*default:* _on_
*context:* _location (push_stream_publisher)_
*release version:* _0.3.5_
Enable send back channel information after publish a message.
......@@ -84,6 +84,7 @@ typedef struct {
ngx_msec_t subscriber_connection_ttl;
ngx_msec_t longpolling_connection_ttl;
ngx_flag_t websocket_allow_publish;
ngx_flag_t channel_info_on_publish;
ngx_http_complex_value_t *last_received_message_time;
ngx_http_complex_value_t *last_received_message_tag;
ngx_http_complex_value_t *user_agent;
......
......@@ -50,6 +50,8 @@ module NginxConfiguration
:client_max_body_size => '32k',
:client_body_buffer_size => '32k',
:channel_info_on_publish => "on",
:extra_location => ''
}
end
......@@ -152,6 +154,7 @@ http {
set $push_stream_channel_id $arg_id;
<%= write_directive("push_stream_store_messages", store_messages, "store messages") %>
<%= write_directive("push_stream_keepalive", keepalive, "keepalive") %>
<%= write_directive("push_stream_channel_info_on_publish", channel_info_on_publish, "channel_info_on_publish") %>
# client_max_body_size MUST be equal to client_body_buffer_size or
# you will be sorry.
......
......@@ -356,6 +356,22 @@ describe "Publisher Properties" do
end
end
it "should not receive channel info after publish a message when disabled" do
body = 'published message'
channel = 'ch_test_skip_channel_info'
nginx_run_server(config.merge(:channel_info_on_publish => "off")) do |conf|
EventMachine.run do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
pub_1.callback do
pub_1.should be_http_status(200).without_body
EventMachine.stop
end
end
end
end
context "when allow origin directive is set" do
it "should receive acess control allow headers" do
channel = 'test_access_control_allow_headers'
......
......@@ -198,7 +198,11 @@ ngx_http_push_stream_publisher_body_handler(ngx_http_request_t *r)
return;
}
ngx_http_push_stream_send_response_channel_info(r, channel);
if (cf->channel_info_on_publish) {
ngx_http_push_stream_send_response_channel_info(r, channel);
} else {
ngx_http_push_stream_send_only_header_response(r, NGX_HTTP_OK, NULL);
}
ngx_http_finalize_request(r, NGX_OK);
return;
}
......
......@@ -128,6 +128,12 @@ static ngx_command_t ngx_http_push_stream_commands[] = {
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_push_stream_loc_conf_t, store_messages),
NULL },
{ ngx_string("push_stream_channel_info_on_publish"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_flag_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_push_stream_loc_conf_t, channel_info_on_publish),
NULL },
{ ngx_string("push_stream_authorized_channels_only"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_flag_slot,
......@@ -537,6 +543,7 @@ ngx_http_push_stream_create_loc_conf(ngx_conf_t *cf)
lcf->subscriber_connection_ttl = NGX_CONF_UNSET_MSEC;
lcf->longpolling_connection_ttl = NGX_CONF_UNSET_MSEC;
lcf->websocket_allow_publish = NGX_CONF_UNSET_UINT;
lcf->channel_info_on_publish = NGX_CONF_UNSET_UINT;
lcf->last_received_message_time = NULL;
lcf->last_received_message_tag = NULL;
lcf->user_agent = NULL;
......@@ -566,6 +573,7 @@ ngx_http_push_stream_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_msec_value(conf->subscriber_connection_ttl, prev->subscriber_connection_ttl, NGX_CONF_UNSET_MSEC);
ngx_conf_merge_msec_value(conf->longpolling_connection_ttl, prev->longpolling_connection_ttl, conf->subscriber_connection_ttl);
ngx_conf_merge_value(conf->websocket_allow_publish, prev->websocket_allow_publish, 0);
ngx_conf_merge_value(conf->channel_info_on_publish, prev->channel_info_on_publish, 1);
ngx_conf_merge_str_value(conf->padding_by_user_agent, prev->padding_by_user_agent, NGX_HTTP_PUSH_STREAM_DEFAULT_PADDING_BY_USER_AGENT);
ngx_conf_merge_str_value(conf->allowed_origins, prev->allowed_origins, NGX_HTTP_PUSH_STREAM_DEFAULT_ALLOWED_ORIGINS);
......
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