Barely make it parse trailers
This commit is contained in:
@@ -81,9 +81,29 @@ namespace uWS {
|
|||||||
|
|
||||||
while (data.length()) {
|
while (data.length()) {
|
||||||
|
|
||||||
|
// if in "drop trailer mode", just drop up to what we have as size
|
||||||
|
if ((state & STATE_IS_CHUNKED) && hasChunkSize(state) && chunkSize(state)) {
|
||||||
|
|
||||||
|
while(data.length() && chunkSize(state)) {
|
||||||
|
//printf("dropping 1 byte of trailer\n");
|
||||||
|
data.remove_prefix(1);
|
||||||
|
decChunkSize(state, 1);
|
||||||
|
|
||||||
|
if (chunkSize(state) == 0) {
|
||||||
|
//printf("dropped the whole trailer\n");
|
||||||
|
state = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!hasChunkSize(state)) {
|
if (!hasChunkSize(state)) {
|
||||||
consumeHexNumber(data, state);
|
consumeHexNumber(data, state);
|
||||||
if (hasChunkSize(state) && chunkSize(state) == 2) {
|
if (hasChunkSize(state) && chunkSize(state) == 2) {
|
||||||
|
|
||||||
|
// set trailer state and increase size to 4
|
||||||
|
state = 4 | STATE_IS_CHUNKED | STATE_HAS_SIZE;
|
||||||
|
|
||||||
cb(std::string_view(nullptr, 0));
|
cb(std::string_view(nullptr, 0));
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ void runTest(unsigned int maxConsume) {
|
|||||||
|
|
||||||
// every null chunk is followed by an empty trailer
|
// every null chunk is followed by an empty trailer
|
||||||
if (chunk.length() == 0) {
|
if (chunk.length() == 0) {
|
||||||
//ss << "\r\n";
|
ss << "\r\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user