[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"
              USERAGENT
              "Host: %s:%d\r\n"
              "Pragma: no-cache,rate=1.000000,stream-time=0,"
              "stream-offset=0:0,request-context=%u,max-duration=0\r\n"
              CLIENTGUID
-             "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"
                    USERAGENT
                    "Host: %s:%d\r\n"
                    "Pragma: no-cache,rate=1.000000,request-context=%u\r\n"
                    "Pragma: xPlayStrm=1\r\n"
                    CLIENTGUID
                    "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,
stream_selection);
     av_freep(&stream_selection);
     if (err < 0) {
--
1.7.3.4


More information about the ffmpeg-devel mailing list