[FFmpeg-devel] [PATCH]Add one CRLF to http headers if necessary

Carl Eugen Hoyos cehoyos at ag.or.at
Thu Feb 26 15:09:51 CET 2015


Hi!

I believe attached patch fixes ticket #3268 in some cases.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavformat/http.c b/libavformat/http.c
index 55dcb6e..b617800 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -312,9 +312,16 @@ static int http_open(URLContext *h, const char *uri, int flags,
 
     if (s->headers) {
         int len = strlen(s->headers);
-        if (len < 2 || strcmp("\r\n", s->headers + len - 2))
+        if (len < 2 || strcmp("\r\n", s->headers + len - 2)) {
+            char *header = av_malloc(len + 3);
+            if (!header)
+                return AVERROR(ENOMEM);
+            snprintf(header, len + 3, "%s\r\n", s->headers);
+            av_free(s->headers);
+            s->headers = header;
             av_log(h, AV_LOG_WARNING,
-                   "No trailing CRLF found in HTTP header.\n");
+                   "No trailing CRLF found in HTTP header, added \\r\\n at the end.\n");
+        }
     }
 
     ret = http_open_cnx(h, options);


More information about the ffmpeg-devel mailing list