|
|
|
@ -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.
|
|
|
|
|