Update uWS.getParts for dealing with empty parts

This commit is contained in:
Alex Hultman 2020-10-14 22:00:22 +02:00
parent eb7e21780c
commit d6caec2240
2 changed files with 5 additions and 3 deletions

View File

@ -91,11 +91,13 @@ void uWS_getParts(const FunctionCallbackInfo<Value> &args) {
Local<Array> parts = Array::New(args.GetIsolate(), 0);
while (true) {
std::string_view part = mp.getNextPart(headers);
if (!part.length()) {
std::optional<std::string_view> optionalPart = mp.getNextPart(headers);
if (!optionalPart.has_value()) {
break;
}
std::string_view part = optionalPart.value();
Local<ArrayBuffer> partArrayBuffer = ArrayBuffer::New(isolate, (void *) part.data(), part.length());
Local<Map> partMap = Map::New(isolate);
partMap->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "data", NewStringType::kNormal).ToLocalChecked(), partArrayBuffer);

@ -1 +1 @@
Subproject commit 70d060597ef45366c2e0d906e052b091fbb466a7
Subproject commit 59a38b3a1316eba2a0dd986f6ae6834f6260aa07