Skip to content

Multiple Fixes to MultipartParser and MultipartReader #1

Merged
merged 3 commits into from May 31, 2011
View
11 MultipartParser.h
@@ -122,12 +122,12 @@ class MultipartParser {
}
void processPartData(size_t &prevIndex, size_t &index, const char *buffer,
- size_t len, size_t boundaryEnd, size_t &i, char c, int &flags)
+ size_t len, size_t boundaryEnd, size_t &i, char c, State &state, int &flags)
{
prevIndex = index;
if (index == 0) {
- // boyer-moore derrived algorithm to safely skip non-boundary data
+ // boyer-moore derived algorithm to safely skip non-boundary data
while (i + boundarySize <= len) {
if (isBoundaryChar(buffer[i + boundaryEnd])) {
break;
@@ -171,7 +171,9 @@ class MultipartParser {
}
} else if (flags & LAST_BOUNDARY) {
if (c == HYPHEN) {
- index++;
+ callback(onPartEnd);
+ callback(onEnd);
+ state = END;
} else {
index = 0;
}
@@ -389,8 +391,7 @@ class MultipartParser {
state = PART_DATA;
partDataMark = i;
case PART_DATA:
- processPartData(prevIndex, index, buffer, len, boundaryEnd,
- i, c, flags);
+ processPartData(prevIndex, index, buffer, len, boundaryEnd, i, c, state, flags);
break;
default:
return i;
View
3 MultipartReader.h
@@ -30,13 +30,13 @@ class MultipartReader {
bool headersProcessed;
MultipartHeaders currentHeaders;
std::string currentHeaderName, currentHeaderValue;
- void *userData;
void resetReaderCallbacks() {
onPartBegin = NULL;
onPartData = NULL;
onPartEnd = NULL;
onEnd = NULL;
+ userData = NULL;
}
void setParserCallbacks() {
@@ -113,6 +113,7 @@ class MultipartReader {
PartDataCallback onPartData;
Callback onPartEnd;
Callback onEnd;
+ void *userData;
MultipartReader() {
resetReaderCallbacks();
Something went wrong with that request. Please try again.