Skip to content

Commit abb0172

Browse files
committed
fixed errors in control output; now returning http 206 instead of empty recorded file path
1 parent 96855b1 commit abb0172

File tree

1 file changed

+11
-38
lines changed

1 file changed

+11
-38
lines changed

ngx_rtmp_control_module.c

+11-38
Original file line numberDiff line numberDiff line change
@@ -102,37 +102,6 @@ ngx_module_t ngx_rtmp_control_module = {
102102
};
103103

104104

105-
static ngx_int_t
106-
ngx_rtmp_control_output_error(ngx_http_request_t *r, const char *msg)
107-
{
108-
size_t len;
109-
ngx_buf_t *b;
110-
ngx_chain_t cl;
111-
112-
len = ngx_strlen(msg);
113-
114-
r->headers_out.status = NGX_HTTP_BAD_REQUEST;
115-
r->headers_out.content_length_n = len;
116-
117-
b = ngx_calloc_buf(r->pool);
118-
if (b == NULL) {
119-
return NGX_ERROR;
120-
}
121-
122-
ngx_memzero(&cl, sizeof(cl));
123-
cl.buf = b;
124-
125-
b->start = b->pos = (u_char *) msg;
126-
b->end = b->last = (u_char *) msg + len;
127-
b->memory = 1;
128-
b->last_buf = 1;
129-
130-
ngx_http_send_header(r);
131-
132-
return ngx_http_output_filter(r, &cl);
133-
}
134-
135-
136105
static const char *
137106
ngx_rtmp_control_record_handler(ngx_http_request_t *r, ngx_rtmp_session_t *s)
138107
{
@@ -475,14 +444,18 @@ ngx_rtmp_control_record(ngx_http_request_t *r, ngx_str_t *method)
475444
goto error;
476445
}
477446

447+
if (ctx->path.len == 0) {
448+
return NGX_HTTP_NO_CONTENT;
449+
}
450+
478451
/* output record path */
479452

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

483456
b = ngx_create_temp_buf(r->pool, ctx->path.len);
484457
if (b == NULL) {
485-
return NGX_ERROR;
458+
goto error;
486459
}
487460

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

498471
error:
499-
return ngx_rtmp_control_output_error(r, msg);
472+
return NGX_HTTP_INTERNAL_SERVER_ERROR;
500473
}
501474

502475

@@ -554,7 +527,7 @@ ngx_rtmp_control_drop(ngx_http_request_t *r, ngx_str_t *method)
554527

555528
b = ngx_calloc_buf(r->pool);
556529
if (b == NULL) {
557-
return NGX_ERROR;
530+
goto error;
558531
}
559532

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

572545
error:
573-
return ngx_rtmp_control_output_error(r, msg);
546+
return NGX_HTTP_INTERNAL_SERVER_ERROR;
574547
}
575548

576549

@@ -618,7 +591,7 @@ ngx_rtmp_control_redirect(ngx_http_request_t *r, ngx_str_t *method)
618591

619592
p = ngx_palloc(r->connection->pool, len);
620593
if (p == NULL) {
621-
return NGX_ERROR;
594+
goto error;
622595
}
623596

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

629602
b = ngx_calloc_buf(r->pool);
630603
if (b == NULL) {
631-
return NGX_ERROR;
604+
goto error;
632605
}
633606

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

646619
error:
647-
return ngx_rtmp_control_output_error(r, msg);
620+
return NGX_HTTP_INTERNAL_SERVER_ERROR;
648621
}
649622

650623

0 commit comments

Comments
 (0)