comparison src/http/modules/ngx_http_flv_module.c @ 246:b52bd034c577 NGINX_0_4_8

nginx 0.4.8 *) Bugfix: if an "include" SSI command were before another "include" SSI command with an "wait" parameter, then the "wait" parameter might not work. *) Bugfix: the ngx_http_flv_module added the FLV header to the full responses. Thanks to Alexey Kovyrin.
author Igor Sysoev <http://sysoev.ru>
date Wed, 11 Oct 2006 00:00:00 +0400
parents 500a3242dff6
children acd2ec3541cb
comparison
equal deleted inserted replaced
245:d75dbd68f5b2 246:b52bd034c577
62 { 62 {
63 u_char *p; 63 u_char *p;
64 off_t start, len; 64 off_t start, len;
65 ngx_fd_t fd; 65 ngx_fd_t fd;
66 ngx_int_t rc; 66 ngx_int_t rc;
67 ngx_uint_t level; 67 ngx_uint_t level, i;
68 ngx_str_t path; 68 ngx_str_t path;
69 ngx_err_t err; 69 ngx_err_t err;
70 ngx_log_t *log; 70 ngx_log_t *log;
71 ngx_buf_t *b; 71 ngx_buf_t *b;
72 ngx_chain_t out[2]; 72 ngx_chain_t out[2];
161 return NGX_DECLINED; 161 return NGX_DECLINED;
162 } 162 }
163 163
164 start = 0; 164 start = 0;
165 len = ngx_file_size(&fi); 165 len = ngx_file_size(&fi);
166 i = 1;
166 167
167 if (r->args.len) { 168 if (r->args.len) {
168 p = (u_char *) ngx_strstr(r->args.data, "start="); 169 p = (u_char *) ngx_strstr(r->args.data, "start=");
169 170
170 if (p) { 171 if (p) {
174 175
175 if (start == NGX_ERROR || start >= len) { 176 if (start == NGX_ERROR || start >= len) {
176 start = 0; 177 start = 0;
177 } 178 }
178 179
179 len -= start; 180 if (start) {
181 len = sizeof(ngx_flv_header) - 1 + len - start;
182 i = 0;
183 }
180 } 184 }
181 } 185 }
182 186
183 log->action = "sending flv to client"; 187 log->action = "sending flv to client";
184 188
188 clnf->fd = fd; 192 clnf->fd = fd;
189 clnf->name = path.data; 193 clnf->name = path.data;
190 clnf->log = r->pool->log; 194 clnf->log = r->pool->log;
191 195
192 r->headers_out.status = NGX_HTTP_OK; 196 r->headers_out.status = NGX_HTTP_OK;
193 r->headers_out.content_length_n = sizeof(ngx_flv_header) - 1 + len; 197 r->headers_out.content_length_n = len;
194 r->headers_out.last_modified_time = ngx_file_mtime(&fi); 198 r->headers_out.last_modified_time = ngx_file_mtime(&fi);
195 199
196 if (ngx_http_set_content_type(r) != NGX_OK) { 200 if (ngx_http_set_content_type(r) != NGX_OK) {
197 return NGX_HTTP_INTERNAL_SERVER_ERROR; 201 return NGX_HTTP_INTERNAL_SERVER_ERROR;
198 } 202 }
199 203
200 b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t)); 204 if (i == 0) {
201 if (b == NULL) { 205 b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
202 return NGX_HTTP_INTERNAL_SERVER_ERROR; 206 if (b == NULL) {
203 } 207 return NGX_HTTP_INTERNAL_SERVER_ERROR;
204 208 }
205 b->pos = ngx_flv_header; 209
206 b->last = ngx_flv_header + sizeof(ngx_flv_header) - 1; 210 b->pos = ngx_flv_header;
207 b->memory = 1; 211 b->last = ngx_flv_header + sizeof(ngx_flv_header) - 1;
208 212 b->memory = 1;
209 out[0].buf = b; 213
210 out[0].next = &out[1]; 214 out[0].buf = b;
215 out[0].next = &out[1];
216 }
211 217
212 b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t)); 218 b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
213 if (b == NULL) { 219 if (b == NULL) {
214 return NGX_HTTP_INTERNAL_SERVER_ERROR; 220 return NGX_HTTP_INTERNAL_SERVER_ERROR;
215 } 221 }
237 b->file->log = log; 243 b->file->log = log;
238 244
239 out[1].buf = b; 245 out[1].buf = b;
240 out[1].next = NULL; 246 out[1].next = NULL;
241 247
242 return ngx_http_output_filter(r, out); 248 return ngx_http_output_filter(r, &out[i]);
243 } 249 }
244 250
245 251
246 static char * 252 static char *
247 ngx_http_flv(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 253 ngx_http_flv(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)