comparison http.c @ 6106:44ee60d0c688 libavformat

Fix bugs in the http custom header handling Initialize the buffer av_strlcatf writes into. Add the dash at the end of the Range header. 10l to me for not spotting it earlier
author mstorsjo
date Tue, 08 Jun 2010 11:06:36 +0000
parents a5eaf91edd4a
children 5ad38b8596b2
comparison
equal deleted inserted replaced
6105:c0336d3528e9 6106:44ee60d0c688
268 const char *auth, int *new_location) 268 const char *auth, int *new_location)
269 { 269 {
270 HTTPContext *s = h->priv_data; 270 HTTPContext *s = h->priv_data;
271 int post, err; 271 int post, err;
272 char line[1024]; 272 char line[1024];
273 char headers[1024]; 273 char headers[1024] = "";
274 char *authstr = NULL; 274 char *authstr = NULL;
275 int64_t off = s->off; 275 int64_t off = s->off;
276 int len = 0; 276 int len = 0;
277 277
278 278
288 if (!has_header(s->headers, "\r\nAccept: ")) 288 if (!has_header(s->headers, "\r\nAccept: "))
289 len += av_strlcpy(headers + len, "Accept: */*\r\n", 289 len += av_strlcpy(headers + len, "Accept: */*\r\n",
290 sizeof(headers) - len); 290 sizeof(headers) - len);
291 if (!has_header(s->headers, "\r\nRange: ")) 291 if (!has_header(s->headers, "\r\nRange: "))
292 len += av_strlcatf(headers + len, sizeof(headers) - len, 292 len += av_strlcatf(headers + len, sizeof(headers) - len,
293 "Range: bytes=%"PRId64"\r\n", s->off); 293 "Range: bytes=%"PRId64"-\r\n", s->off);
294 if (!has_header(s->headers, "\r\nConnection: ")) 294 if (!has_header(s->headers, "\r\nConnection: "))
295 len += av_strlcpy(headers + len, "Connection: close\r\n", 295 len += av_strlcpy(headers + len, "Connection: close\r\n",
296 sizeof(headers)-len); 296 sizeof(headers)-len);
297 if (!has_header(s->headers, "\r\nHost: ")) 297 if (!has_header(s->headers, "\r\nHost: "))
298 len += av_strlcatf(headers + len, sizeof(headers) - len, 298 len += av_strlcatf(headers + len, sizeof(headers) - len,