diff --git a/lib/flv_tag.cpp b/lib/flv_tag.cpp index 096c362e..f7f04c79 100644 --- a/lib/flv_tag.cpp +++ b/lib/flv_tag.cpp @@ -587,11 +587,11 @@ bool FLV::Tag::DTSCAudioInit(DTSC::Stream & S){ /// Assumes metadata is available - so check before calling! bool FLV::Tag::DTSCMetaInit(DTSC::Stream & S){ //Unknown? Assume AAC. - if (S.metadata["audio"]["codec"].asString() == "?"){ + if (S.metadata.isMember("audio") && S.metadata["audio"]["codec"].asString() == "?"){ S.metadata["audio"]["codec"] = "AAC"; } //Unknown? Assume H264. - if (S.metadata["video"]["codec"].asString() == "?"){ + if (S.metadata.isMember("video") && S.metadata["video"]["codec"].asString() == "?"){ S.metadata["video"]["codec"] = "H264"; } diff --git a/lib/http_parser.cpp b/lib/http_parser.cpp index 1dea052f..460cb2b7 100644 --- a/lib/http_parser.cpp +++ b/lib/http_parser.cpp @@ -6,6 +6,7 @@ /// This constructor creates an empty HTTP::Parser, ready for use for either reading or writing. /// All this constructor does is call HTTP::Parser::Clean(). HTTP::Parser::Parser(){ + headerOnly = false; Clean(); } @@ -217,6 +218,9 @@ bool HTTP::Parser::parse(std::string & HTTPbuffer){ } if (seenHeaders){ if (length > 0){ + if (headerOnly){ + return true; + } unsigned int toappend = length - body.length(); if (toappend > 0){ body.append(HTTPbuffer, 0, toappend); diff --git a/lib/http_parser.h b/lib/http_parser.h index 300edf56..bf753190 100644 --- a/lib/http_parser.h +++ b/lib/http_parser.h @@ -33,6 +33,7 @@ namespace HTTP { std::string url; std::string protocol; unsigned int length; + bool headerOnly; ///< If true, do not parse body if the length is a known size. private: bool seenHeaders; bool seenReq;