Permalink
Browse files

Merge pull request #1 from johnyanarella/master

Multiple Fixes to MultipartParser and MultipartReader
  • Loading branch information...
2 parents 19484b8 + fa6f409 commit 90a98b44e5f8f97b42dd742cf22abd82b51205e9 Hongli Lai committed May 31, 2011
Showing with 8 additions and 6 deletions.
  1. +6 −5 MultipartParser.h
  2. +2 −1 MultipartReader.h
View
@@ -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
@@ -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();

0 comments on commit 90a98b4

Please sign in to comment.