Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Sync API with Formidable.

  • Loading branch information...
commit fd1676ec6152f21f1f60d4b33434ff096902a0d4 1 parent 5462760
@FooBarWidget authored
Showing with 16 additions and 13 deletions.
  1. +6 −6 MultipartParser.h
  2. +4 −4 MultipartReader.h
  3. +6 −3 multipart.cpp
View
12 MultipartParser.h
@@ -56,8 +56,8 @@ class MultipartParser {
onPartBegin = NULL;
onHeaderField = NULL;
onHeaderValue = NULL;
- onHeaderDone = NULL;
- onHeadersDone = NULL;
+ onHeaderEnd = NULL;
+ onHeadersEnd = NULL;
onPartData = NULL;
onPartEnd = NULL;
onEnd = NULL;
@@ -224,8 +224,8 @@ class MultipartParser {
Callback onPartBegin;
Callback onHeaderField;
Callback onHeaderValue;
- Callback onHeaderDone;
- Callback onHeadersDone;
+ Callback onHeaderEnd;
+ Callback onHeadersEnd;
Callback onPartData;
Callback onPartEnd;
Callback onEnd;
@@ -364,6 +364,7 @@ class MultipartParser {
case HEADER_VALUE:
if (c == CR) {
dataCallback(onHeaderValue, headerValueMark, buffer, i, len, true, true);
+ callback(onHeaderEnd);
state = HEADER_VALUE_ALMOST_DONE;
}
break;
@@ -373,7 +374,6 @@ class MultipartParser {
return i;
}
- callback(onHeaderDone);
state = HEADER_FIELD_START;
break;
case HEADERS_ALMOST_DONE:
@@ -382,7 +382,7 @@ class MultipartParser {
return i;
}
- callback(onHeadersDone);
+ callback(onHeadersEnd);
state = PART_DATA_START;
break;
case PART_DATA_START:
View
8 MultipartReader.h
@@ -36,8 +36,8 @@ class MultipartReader {
parser.onPartBegin = cbPartBegin;
parser.onHeaderField = cbHeaderField;
parser.onHeaderValue = cbHeaderValue;
- parser.onHeaderDone = cbHeaderDone;
- parser.onHeadersDone = cbHeadersDone;
+ parser.onHeaderEnd = cbHeaderEnd;
+ parser.onHeadersEnd = cbHeadersEnd;
parser.onPartData = cbPartData;
parser.onPartEnd = cbPartEnd;
parser.onEnd = cbEnd;
@@ -62,7 +62,7 @@ class MultipartReader {
self->currentHeaderValue.append(buffer + start, end - start);
}
- static void cbHeaderDone(const char *buffer, size_t start, size_t end, void *userData) {
+ static void cbHeaderEnd(const char *buffer, size_t start, size_t end, void *userData) {
MultipartReader *self = (MultipartReader *) userData;
self->currentHeaders.insert(std::make_pair(self->currentHeaderName,
self->currentHeaderValue));
@@ -70,7 +70,7 @@ class MultipartReader {
self->currentHeaderValue.clear();
}
- static void cbHeadersDone(const char *buffer, size_t start, size_t end, void *userData) {
+ static void cbHeadersEnd(const char *buffer, size_t start, size_t end, void *userData) {
MultipartReader *self = (MultipartReader *) userData;
if (self->onPartBegin != NULL) {
self->onPartBegin(self->currentHeaders, self->userData);
View
9 multipart.cpp
@@ -3,7 +3,9 @@
#include <stdio.h>
//#define TEST_PARSER
-#define INPUT_FILE "input2.txt"
+#define INPUT_FILE "input.txt"
+#define BOUNDARY "abcd"
+//#define BOUNDARY "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"
using namespace std;
@@ -80,11 +82,12 @@ main() {
#endif
for (int i = 0; i < 5; i++) {
- parser.setBoundary("abcd");
+ printf("------------\n");
+ parser.setBoundary(BOUNDARY);
FILE *f = fopen(INPUT_FILE, "rb");
while (!parser.stopped() && !feof(f)) {
- char buf[100];
+ char buf[1024 * 32];
size_t len = fread(buf, 1, sizeof(buf), f);
size_t fed = 0;
do {
Please sign in to comment.
Something went wrong with that request. Please try again.