Skip to content

Commit

Permalink
fixed errors in control output; now returning http 206 instead of emp…
Browse files Browse the repository at this point in the history
…ty recorded file path
  • Loading branch information
arut committed Mar 4, 2014
1 parent 96855b1 commit abb0172
Showing 1 changed file with 11 additions and 38 deletions.
49 changes: 11 additions & 38 deletions ngx_rtmp_control_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,37 +102,6 @@ ngx_module_t ngx_rtmp_control_module = {
};


static ngx_int_t
ngx_rtmp_control_output_error(ngx_http_request_t *r, const char *msg)
{
size_t len;
ngx_buf_t *b;
ngx_chain_t cl;

len = ngx_strlen(msg);

r->headers_out.status = NGX_HTTP_BAD_REQUEST;
r->headers_out.content_length_n = len;

b = ngx_calloc_buf(r->pool);
if (b == NULL) {
return NGX_ERROR;
}

ngx_memzero(&cl, sizeof(cl));
cl.buf = b;

b->start = b->pos = (u_char *) msg;
b->end = b->last = (u_char *) msg + len;
b->memory = 1;
b->last_buf = 1;

ngx_http_send_header(r);

return ngx_http_output_filter(r, &cl);
}


static const char *
ngx_rtmp_control_record_handler(ngx_http_request_t *r, ngx_rtmp_session_t *s)
{
Expand Down Expand Up @@ -475,14 +444,18 @@ ngx_rtmp_control_record(ngx_http_request_t *r, ngx_str_t *method)
goto error;
}

if (ctx->path.len == 0) {
return NGX_HTTP_NO_CONTENT;
}

/* output record path */

r->headers_out.status = NGX_HTTP_OK;
r->headers_out.content_length_n = ctx->path.len;

b = ngx_create_temp_buf(r->pool, ctx->path.len);
if (b == NULL) {
return NGX_ERROR;
goto error;
}

ngx_memzero(&cl, sizeof(cl));
Expand All @@ -496,7 +469,7 @@ ngx_rtmp_control_record(ngx_http_request_t *r, ngx_str_t *method)
return ngx_http_output_filter(r, &cl);

error:
return ngx_rtmp_control_output_error(r, msg);
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}


Expand Down Expand Up @@ -554,7 +527,7 @@ ngx_rtmp_control_drop(ngx_http_request_t *r, ngx_str_t *method)

b = ngx_calloc_buf(r->pool);
if (b == NULL) {
return NGX_ERROR;
goto error;
}

b->start = b->pos = p;
Expand All @@ -570,7 +543,7 @@ ngx_rtmp_control_drop(ngx_http_request_t *r, ngx_str_t *method)
return ngx_http_output_filter(r, &cl);

error:
return ngx_rtmp_control_output_error(r, msg);
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}


Expand Down Expand Up @@ -618,7 +591,7 @@ ngx_rtmp_control_redirect(ngx_http_request_t *r, ngx_str_t *method)

p = ngx_palloc(r->connection->pool, len);
if (p == NULL) {
return NGX_ERROR;
goto error;
}

len = (size_t) (ngx_snprintf(p, len, "%ui", ctx->count) - p);
Expand All @@ -628,7 +601,7 @@ ngx_rtmp_control_redirect(ngx_http_request_t *r, ngx_str_t *method)

b = ngx_calloc_buf(r->pool);
if (b == NULL) {
return NGX_ERROR;
goto error;
}

b->start = b->pos = p;
Expand All @@ -644,7 +617,7 @@ ngx_rtmp_control_redirect(ngx_http_request_t *r, ngx_str_t *method)
return ngx_http_output_filter(r, &cl);

error:
return ngx_rtmp_control_output_error(r, msg);
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}


Expand Down

0 comments on commit abb0172

Please sign in to comment.