[FFmpeg-devel] [PATCH] mmsh:// "400 bad request" fix

Kirill Zorin cyril.zorin at gmail.com
Thu Jun 16 17:29:28 CEST 2011

There is no need to write two HTTP newlines (\r\n) into "headers",
because http_connect (in http.c) already appends one HTTP newline at
the end of the given headers chunk, which would result in sending
three HTTP newlines after the headers. Most of the time it's okay
(although not RFC-conforming), but many proxy servers and the
occasional strict httpd will puke with a "400 bad request".

 ffmpeg/libavformat/mmsh.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ffmpeg/libavformat/mmsh.c b/ffmpeg/libavformat/mmsh.c
index 8cfceee..5344967 100644
--- a/ffmpeg/libavformat/mmsh.c
+++ b/ffmpeg/libavformat/mmsh.c
@@ -245,13 +245,13 @@ static int mmsh_open(URLContext *h, const char
*uri, int flags)

     snprintf(headers, sizeof(headers),
              "Accept: */*\r\n"
              "Host: %s:%d\r\n"
              "Pragma: no-cache,rate=1.000000,stream-time=0,"
-             "Connection: Close\r\n\r\n",
+             "Connection: Close\r\n",
              host, port, mmsh->request_seq++);
     ff_http_set_headers(mms->mms_hd, headers);

@@ -286,15 +286,15 @@ static int mmsh_open(URLContext *h, const char
*uri, int flags)
     // ------------------------------------------
     // send play request
     err = snprintf(headers, sizeof(headers),
                    "Accept: */*\r\n"
                    "Host: %s:%d\r\n"
                    "Pragma: no-cache,rate=1.000000,request-context=%u\r\n"
                    "Pragma: xPlayStrm=1\r\n"
                    "Pragma: stream-switch-count=%d\r\n"
                    "Pragma: stream-switch-entry=%s\r\n"
-                   "Connection: Close\r\n\r\n",
+                   "Connection: Close\r\n",
                    host, port, mmsh->request_seq++, mms->stream_num,
     if (err < 0) {

More information about the ffmpeg-devel mailing list