On 6 June 2010 13:44, Ronald S. Bultje <rsbultje@gmail.com> wrote:
Hi,
On Sat, Jun 5, 2010 at 6:05 PM, Josh Allmann <joshua.allmann@gmail.com> wrote:
+ HTTPContext *s = h->priv_data; + int len = strlen(headers); + + if (len && strcmp("\r\n", headers+len-2)) + av_log(NULL, AV_LOG_ERROR, "No trailing CRLF found in HTTP header.\n"); + + snprintf(s->headers, sizeof(s->headers), "%s", headers);
av_strlcpy().
Fixed. I also changed all of my other calls to use av_str* equivalents.
+ /* set default headers if needed */ + if(!strstr(s->headers, "\r\nUser-Agent:")) + len += snprintf(headers+len, sizeof(headers)-len, "User-Agent: %s\r\n", LIBAVFORMAT_IDENT); + if(!strstr(s->headers, "\r\nAccept:"))
if (strncmp(.., "Accept:", 7) && !strstr(.., "\r\nAccept:")) ..
Same for the others. Otherwise you'll miss the first header. A macro or utility function for this would of course be OK:
#define has_header(str, hdr, size) \ (strncmp(str, hdr, size) && !strstr(.., "\r\n" hdr))
Something like that should compile.
Good catch. Used av_stristart(...) || av_stristr(...) in an inlined function.
+ /* now add in custom headers */ + snprintf(headers+len, sizeof(headers)-len, "%s", s->headers);
Maybe use av_strlcat(). Also the "%s" is again not needed, and this might need an if (s->headers[0]).
Changed to av_strcpy since we know where we're starting from (avoids a call to strlen). Copying a null string should yield a null string without any problems.
#3 is OK.
Do you think a more generic ff_http_ignore_header function would be better at avoiding API sprawl? We can special-case "Transfer-Encoding" in there and set the flag then.
You have two #5 patches, which one is right?
Whoops, I attached #5 instead of #1.
Ronald _______________________________________________ FFmpeg-soc mailing list FFmpeg-soc@mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc