Skip to content

Commit

Permalink
PR SmingHub#2123 broke the nultipart file and post sending resulting …
Browse files Browse the repository at this point in the history
…in wrong multipart boudary headers and endless loop.

This commit removes the introduced problems.
  • Loading branch information
slav-at-attachix committed Dec 2, 2020
1 parent 4188f5c commit aa86117
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Sming/Core/Data/Stream/MultipartStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

IDataSourceStream* MultipartStream::getNextStream()
{
if(finished) {
return nullptr;
}

// Return content, if available
if(bodyPart.stream != nullptr) {
auto stream = bodyPart.stream;
Expand All @@ -24,15 +28,18 @@ IDataSourceStream* MultipartStream::getNextStream()

// Fetch next part to send
bodyPart = producer();
if(bodyPart.headers == nullptr && bodyPart.stream == nullptr) {
// Nothing else to send...
finished = true;
}

// Generate header fragment
auto stream = new MemoryDataStream();
stream->ensureCapacity(4 + 16 + 4);
stream->print("\r\n");
stream->print("--");
stream->print(getBoundary());
if(bodyPart.headers == nullptr) {
// No more parts
if(finished) {
stream->print("--");
}
stream->print("\r\n");
Expand Down
1 change: 1 addition & 0 deletions Sming/Core/Data/Stream/MultipartStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class MultipartStream : public MultiStream
Producer producer;
BodyPart bodyPart;
char boundary[16] = {0};
bool finished = false;
};

/**
Expand Down

0 comments on commit aa86117

Please sign in to comment.