Fix chunked body handling in fallback routine (#1585)
This commit is contained in:
committed by
GitHub
parent
6243be0e9e
commit
8410f7ee6b
+26
-13
@@ -580,21 +580,34 @@ public:
|
|||||||
length -= consumed.first - had;
|
length -= consumed.first - had;
|
||||||
|
|
||||||
if (remainingStreamingBytes) {
|
if (remainingStreamingBytes) {
|
||||||
// this is exactly the same as above!
|
/* It's either chunked or with a content-length */
|
||||||
if (remainingStreamingBytes >= (unsigned int) length) {
|
if (isParsingChunkedEncoding(remainingStreamingBytes)) {
|
||||||
void *returnedUser = dataHandler(user, std::string_view(data, length), remainingStreamingBytes == (unsigned int) length);
|
std::string_view dataToConsume(data, length);
|
||||||
remainingStreamingBytes -= length;
|
for (auto chunk : uWS::ChunkIterator(&dataToConsume, &remainingStreamingBytes)) {
|
||||||
return returnedUser;
|
dataHandler(user, chunk, chunk.length() == 0);
|
||||||
|
}
|
||||||
|
if (isParsingInvalidChunkedEncoding(remainingStreamingBytes)) {
|
||||||
|
return FULLPTR;
|
||||||
|
}
|
||||||
|
data = (char *) dataToConsume.data();
|
||||||
|
length = (unsigned int) dataToConsume.length();
|
||||||
} else {
|
} else {
|
||||||
void *returnedUser = dataHandler(user, std::string_view(data, remainingStreamingBytes), true);
|
// this is exactly the same as above!
|
||||||
|
if (remainingStreamingBytes >= (unsigned int) length) {
|
||||||
data += remainingStreamingBytes;
|
void *returnedUser = dataHandler(user, std::string_view(data, length), remainingStreamingBytes == (unsigned int) length);
|
||||||
length -= remainingStreamingBytes;
|
remainingStreamingBytes -= length;
|
||||||
|
|
||||||
remainingStreamingBytes = 0;
|
|
||||||
|
|
||||||
if (returnedUser != user) {
|
|
||||||
return returnedUser;
|
return returnedUser;
|
||||||
|
} else {
|
||||||
|
void *returnedUser = dataHandler(user, std::string_view(data, remainingStreamingBytes), true);
|
||||||
|
|
||||||
|
data += remainingStreamingBytes;
|
||||||
|
length -= remainingStreamingBytes;
|
||||||
|
|
||||||
|
remainingStreamingBytes = 0;
|
||||||
|
|
||||||
|
if (returnedUser != user) {
|
||||||
|
return returnedUser;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user