winlin

Merge pull request #386 from neojiang/2.0release

fix #384
@@ -1401,7 +1401,7 @@ int SrsHttpParser::parse_message(SrsStSocket* skt, SrsHttpMessage** ppmsg) @@ -1401,7 +1401,7 @@ int SrsHttpParser::parse_message(SrsStSocket* skt, SrsHttpMessage** ppmsg)
1401 header = http_parser(); 1401 header = http_parser();
1402 url = ""; 1402 url = "";
1403 headers.clear(); 1403 headers.clear();
1404 - body_parsed = 0; 1404 + header_parsed = 0;
1405 1405
1406 // do parse 1406 // do parse
1407 if ((ret = parse_message_imp(skt)) != ERROR_SUCCESS) { 1407 if ((ret = parse_message_imp(skt)) != ERROR_SUCCESS) {
@@ -1437,12 +1437,12 @@ int SrsHttpParser::parse_message_imp(SrsStSocket* skt) @@ -1437,12 +1437,12 @@ int SrsHttpParser::parse_message_imp(SrsStSocket* skt)
1437 // when buffer not empty, parse it. 1437 // when buffer not empty, parse it.
1438 if (buffer->size() > 0) { 1438 if (buffer->size() > 0) {
1439 nparsed = http_parser_execute(&parser, &settings, buffer->bytes(), buffer->size()); 1439 nparsed = http_parser_execute(&parser, &settings, buffer->bytes(), buffer->size());
1440 - srs_info("buffer=%d, nparsed=%d, body=%d", buffer->size(), (int)nparsed, body_parsed); 1440 + srs_info("buffer=%d, nparsed=%d, header=%d", buffer->size(), (int)nparsed, header_parsed);
1441 } 1441 }
1442 1442
1443 // consume the parsed bytes. 1443 // consume the parsed bytes.
1444 - if (nparsed && nparsed - body_parsed > 0) {  
1445 - buffer->read_slice((int)nparsed - (int)body_parsed); 1444 + if (nparsed && nparsed - header_parsed > 0) {
  1445 + buffer->read_slice(header_parsed);
1446 } 1446 }
1447 1447
1448 // ok atleast header completed, 1448 // ok atleast header completed,
@@ -1491,6 +1491,7 @@ int SrsHttpParser::on_headers_complete(http_parser* parser) @@ -1491,6 +1491,7 @@ int SrsHttpParser::on_headers_complete(http_parser* parser)
1491 obj->header = *parser; 1491 obj->header = *parser;
1492 // save the parser when header parse completed. 1492 // save the parser when header parse completed.
1493 obj->state = SrsHttpParseStateHeaderComplete; 1493 obj->state = SrsHttpParseStateHeaderComplete;
  1494 + obj->header_parsed = (int)parser->nread;
1494 1495
1495 srs_info("***HEADERS COMPLETE***"); 1496 srs_info("***HEADERS COMPLETE***");
1496 1497
@@ -1567,8 +1568,6 @@ int SrsHttpParser::on_body(http_parser* parser, const char* at, size_t length) @@ -1567,8 +1568,6 @@ int SrsHttpParser::on_body(http_parser* parser, const char* at, size_t length)
1567 SrsHttpParser* obj = (SrsHttpParser*)parser->data; 1568 SrsHttpParser* obj = (SrsHttpParser*)parser->data;
1568 srs_assert(obj); 1569 srs_assert(obj);
1569 1570
1570 - obj->body_parsed += length;  
1571 -  
1572 srs_info("Body: %.*s", (int)length, at); 1571 srs_info("Body: %.*s", (int)length, at);
1573 1572
1574 return 0; 1573 return 0;
@@ -599,7 +599,7 @@ private: @@ -599,7 +599,7 @@ private:
599 http_parser header; 599 http_parser header;
600 std::string url; 600 std::string url;
601 std::vector<SrsHttpHeaderField> headers; 601 std::vector<SrsHttpHeaderField> headers;
602 - int body_parsed; 602 + int header_parsed;
603 public: 603 public:
604 SrsHttpParser(); 604 SrsHttpParser();
605 virtual ~SrsHttpParser(); 605 virtual ~SrsHttpParser();