summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2016-02-04 17:44:10 +0100
committerMattes D <github@xoft.cz>2016-03-01 16:19:58 +0100
commit12d95ab0474dffa443bf82834177db7e10110fae (patch)
treea263e20ce91346df7babcce30940c9c03124784a /tests
parentFixed HTTP parsing when in insecure mode. (diff)
downloadcuberite-12d95ab0474dffa443bf82834177db7e10110fae.tar
cuberite-12d95ab0474dffa443bf82834177db7e10110fae.tar.gz
cuberite-12d95ab0474dffa443bf82834177db7e10110fae.tar.bz2
cuberite-12d95ab0474dffa443bf82834177db7e10110fae.tar.lz
cuberite-12d95ab0474dffa443bf82834177db7e10110fae.tar.xz
cuberite-12d95ab0474dffa443bf82834177db7e10110fae.tar.zst
cuberite-12d95ab0474dffa443bf82834177db7e10110fae.zip
Diffstat (limited to '')
-rw-r--r--tests/HTTP/CMakeLists.txt9
-rw-r--r--tests/HTTP/HTTPResponseParser_file.cpp10
2 files changed, 13 insertions, 6 deletions
diff --git a/tests/HTTP/CMakeLists.txt b/tests/HTTP/CMakeLists.txt
index f6989d831..c11c601d9 100644
--- a/tests/HTTP/CMakeLists.txt
+++ b/tests/HTTP/CMakeLists.txt
@@ -42,5 +42,12 @@ endif()
# HTTPResponseParser_file: Feed file contents into a cHTTPResponseParser and print the callbacks as they're called:
add_executable(HTTPResponseParser_file-exe HTTPResponseParser_file.cpp)
target_link_libraries(HTTPResponseParser_file-exe HTTP)
-add_test(NAME HTTPResponseParser_file-test1 COMMAND HTTPResponseParser_file-exe HTTPResponse1.data)
+
+# Test parsing the file in 2-byte chunks (should go from response line parsing through headers parsing to body parsing, each within a different step):
+add_test(NAME HTTPResponseParser_file-test1-2 COMMAND HTTPResponseParser_file-exe HTTPResponse1.data 2)
+
+# Test parsing the file in 128-byte chunks (should parse response line and part of headers in one step, the rest in another step):
+add_test(NAME HTTPResponseParser_file-test1-128 COMMAND HTTPResponseParser_file-exe HTTPResponse1.data 128)
+
+# Test parsing a chunked-encoding content:
add_test(NAME HTTPResponseParser_file-test2 COMMAND HTTPResponseParser_file-exe HTTPResponse2.data)
diff --git a/tests/HTTP/HTTPResponseParser_file.cpp b/tests/HTTP/HTTPResponseParser_file.cpp
index 48ff928bc..7e8d127b7 100644
--- a/tests/HTTP/HTTPResponseParser_file.cpp
+++ b/tests/HTTP/HTTPResponseParser_file.cpp
@@ -122,16 +122,16 @@ int main(int argc, char * argv[])
printf("Read 0 bytes from file (EOF?), terminating\n");
break;
}
- auto numLeft = parser.Parse(buf, numBytes);
- if (numLeft == AString::npos)
+ auto numConsumed = parser.Parse(buf, numBytes);
+ if (numConsumed == AString::npos)
{
printf("Parser indicates there was an error, terminating parsing.\n");
break;
}
- ASSERT(numLeft <= numBytes);
- if (numLeft > 0)
+ ASSERT(numConsumed <= numBytes);
+ if (numConsumed < numBytes)
{
- printf("Parser indicates stream end, but there's more data (at least %u bytes) in the file.\n", static_cast<unsigned>(numLeft));
+ printf("Parser indicates stream end, but there's more data (at least %u bytes) in the file.\n", static_cast<unsigned>(numBytes - numConsumed));
}
}
if (!parser.IsFinished())