[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [libmicrohttpd] 04/08: test_large_put: support incremental
From: |
gnunet |
Subject: |
[GNUnet-SVN] [libmicrohttpd] 04/08: test_large_put: support incremental reading of incoming data |
Date: |
Sun, 22 Jan 2017 22:12:13 +0100 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit f3010a183ca3c90262a692af0ef8bde512f005ce
Author: Evgeny Grin (Karlson2k) <address@hidden>
AuthorDate: Sun Jan 22 19:26:30 2017 +0300
test_large_put: support incremental reading of incoming data
---
src/testcurl/test_large_put.c | 48 +++++++++++++++++++++++--------------------
1 file changed, 26 insertions(+), 22 deletions(-)
diff --git a/src/testcurl/test_large_put.c b/src/testcurl/test_large_put.c
index 65489e7f..d916b053 100644
--- a/src/testcurl/test_large_put.c
+++ b/src/testcurl/test_large_put.c
@@ -46,16 +46,8 @@
#endif
static int oneone;
+static int incr_read; /* Use incremental read */
-/**
- * Do not make this much larger since we will hit the
- * MHD default buffer limit and the test code is not
- * written for incremental upload processing...
- * (larger values will likely cause MHD to generate
- * an internal server error -- which would be avoided
- * by writing the putBuffer method in a more general
- * fashion).
- */
#define PUT_SIZE (256 * 1024)
static char *put_buffer;
@@ -103,35 +95,46 @@ ahc_echo (void *cls,
const char *method,
const char *version,
const char *upload_data, size_t *upload_data_size,
- void **unused)
+ void **pparam)
{
int *done = cls;
struct MHD_Response *response;
int ret;
+ static size_t processed;
if (0 != strcmp ("PUT", method))
return MHD_NO; /* unexpected method */
if ((*done) == 0)
{
- if (*upload_data_size != PUT_SIZE)
+ size_t *pproc;
+ if (NULL == *pparam)
{
-#if 0
- fprintf (stderr,
- "Waiting for more data (%u/%u)...\n",
- *upload_data_size, PUT_SIZE);
-#endif
- return MHD_YES; /* not yet ready */
+ processed = 0;
+ *pparam = &processed; /* Safe as long as only one parallel request
served. */
}
- if (0 == memcmp (upload_data, put_buffer, PUT_SIZE))
+ pproc = (size_t*) *pparam;
+
+ if (0 == *upload_data_size)
+ return MHD_YES; /* No data to process. */
+
+ if (*pproc + *upload_data_size > PUT_SIZE)
{
- *upload_data_size = 0;
+ fprintf (stderr, "Incoming data larger than expected.\n");
+ return MHD_NO;
}
- else
+ if ( (!incr_read) && (*upload_data_size != PUT_SIZE) )
+ return MHD_YES; /* Wait until whole request is received. */
+
+ if (0 != memcmp(upload_data, put_buffer + (*pproc), *upload_data_size))
{
- printf ("Invalid upload data!\n");
+ fprintf (stderr, "Incoming data does not match sent data.\n");
return MHD_NO;
}
- *done = 1;
+ *pproc += *upload_data_size;
+ *upload_data_size = 0; /* Current block of data is fully processed. */
+
+ if (PUT_SIZE == *pproc)
+ *done = 1; /* Whole request is processed. */
return MHD_YES;
}
response = MHD_create_response_from_buffer (strlen (url),
@@ -476,6 +479,7 @@ main (int argc, char *const *argv)
unsigned int errorCount = 0;
oneone = has_in_name(argv[0], "11");
+ incr_read = has_in_name(argv[0], "_inc");
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
return 99;
put_buffer = malloc (PUT_SIZE);
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [libmicrohttpd] branch master updated (44eec406 -> c623d35d), gnunet, 2017/01/22
- [GNUnet-SVN] [libmicrohttpd] 05/08: test_large_put: initialise test buffer with varied data to detect more errors., gnunet, 2017/01/22
- [GNUnet-SVN] [libmicrohttpd] 07/08: test_large_put: added test with incremental read and limited buffer, gnunet, 2017/01/22
- [GNUnet-SVN] [libmicrohttpd] 01/08: test_large_put: updated to use correct check for "11" in name and return '99' in case of system failures., gnunet, 2017/01/22
- [GNUnet-SVN] [libmicrohttpd] 03/08: test_large_put: use proper types for size variables, gnunet, 2017/01/22
- [GNUnet-SVN] [libmicrohttpd] 02/08: test_large_put: renamed functions for readability, gnunet, 2017/01/22
- [GNUnet-SVN] [libmicrohttpd] 04/08: test_large_put: support incremental reading of incoming data,
gnunet <=
- [GNUnet-SVN] [libmicrohttpd] 08/08: test_large_put: added poll() and epoll testing., gnunet, 2017/01/22
- [GNUnet-SVN] [libmicrohttpd] 06/08: test_large_put: added verbosity, gnunet, 2017/01/22