From 948d200ce156c6ad89710fb73c61686926a29d61 Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 22 May 2015 12:00:48 +0800 Subject: [PATCH] fix #400, parse when got entire http header, by feilong. 2.0.164. --- README.md | 1 + trunk/src/app/srs_app_http.cpp | 15 +++++++++++---- trunk/src/core/srs_core.hpp | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2f136b943..06fdde0a7 100755 --- a/README.md +++ b/README.md @@ -562,6 +562,7 @@ Supported operating systems and hardware: ### SRS 2.0 history +* v2.0, 2015-05-22, for [#400](https://github.com/simple-rtmp-server/srs/issues/400), parse when got entire http header, by feilong. 2.0.164. * v2.0, 2015-05-19, merge from bravo system, add the rtmfp to bms(commercial srs). 2.0.163. * v2.0, 2015-05-10, support push flv stream over HTTP POST to SRS. * v2.0, 2015-04-20, support ingest hls live stream to RTMP. diff --git a/trunk/src/app/srs_app_http.cpp b/trunk/src/app/srs_app_http.cpp index 4ed1453f2..d2d503008 100644 --- a/trunk/src/app/srs_app_http.cpp +++ b/trunk/src/app/srs_app_http.cpp @@ -1447,10 +1447,17 @@ int SrsHttpParser::parse_message_imp(SrsStSocket* skt) while (true) { ssize_t nparsed = 0; - // when buffer not empty, parse it. - if (buffer->size() > 0) { - nparsed = http_parser_execute(&parser, &settings, buffer->bytes(), buffer->size()); - srs_info("buffer=%d, nparsed=%d, header=%d", buffer->size(), (int)nparsed, header_parsed); + // when got entire http header, parse it. + // @see https://github.com/simple-rtmp-server/srs/issues/400 + char* start = buffer->bytes(); + char* end = start + buffer->size(); + for (char* p = start; p <= end - 4; p++) { + // SRS_HTTP_CRLFCRLF "\r\n\r\n" // 0x0D0A0D0A + if (p[0] == SRS_CONSTS_CR && p[1] == SRS_CONSTS_LF && p[2] == SRS_CONSTS_CR && p[3] == SRS_CONSTS_LF) { + nparsed = http_parser_execute(&parser, &settings, buffer->bytes(), buffer->size()); + srs_info("buffer=%d, nparsed=%d, header=%d", buffer->size(), (int)nparsed, header_parsed); + break; + } } // consume the parsed bytes. diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 6fae8ea45..775ca8f10 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR 2 #define VERSION_MINOR 0 -#define VERSION_REVISION 163 +#define VERSION_REVISION 164 // server info. #define RTMP_SIG_SRS_KEY "SRS"