mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix http parse bug
This commit is contained in:
parent
f247ac9daf
commit
1ad0c847ce
2 changed files with 11 additions and 11 deletions
Binary file not shown.
|
@ -1315,17 +1315,6 @@ int SrsHttpParser::parse_message_imp(SrsStSocket* skt)
|
||||||
srs_info("buffer=%d, nparsed=%d, body=%d", buffer->size(), (int)nparsed, body_parsed);
|
srs_info("buffer=%d, nparsed=%d, body=%d", buffer->size(), (int)nparsed, body_parsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// when nothing parsed, read more to parse.
|
|
||||||
if (nparsed == 0) {
|
|
||||||
// when requires more, only grow 1bytes, but the buffer will cache more.
|
|
||||||
if ((ret = buffer->grow(skt, buffer->size() + 1)) != ERROR_SUCCESS) {
|
|
||||||
if (!srs_is_client_gracefully_close(ret)) {
|
|
||||||
srs_error("read body from server failed. ret=%d", ret);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// consume the parsed bytes.
|
// consume the parsed bytes.
|
||||||
if (nparsed && nparsed - body_parsed > 0) {
|
if (nparsed && nparsed - body_parsed > 0) {
|
||||||
buffer->read_slice(nparsed - body_parsed);
|
buffer->read_slice(nparsed - body_parsed);
|
||||||
|
@ -1336,6 +1325,17 @@ int SrsHttpParser::parse_message_imp(SrsStSocket* skt)
|
||||||
if (state == SrsHttpParseStateHeaderComplete || state == SrsHttpParseStateMessageComplete) {
|
if (state == SrsHttpParseStateHeaderComplete || state == SrsHttpParseStateMessageComplete) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// when nothing parsed, read more to parse.
|
||||||
|
if (nparsed == 0) {
|
||||||
|
// when requires more, only grow 1bytes, but the buffer will cache more.
|
||||||
|
if ((ret = buffer->grow(skt, buffer->size() + 1)) != ERROR_SUCCESS) {
|
||||||
|
if (!srs_is_client_gracefully_close(ret)) {
|
||||||
|
srs_error("read body from server failed. ret=%d", ret);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse last header.
|
// parse last header.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue