diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-11-07 14:25:05 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2023-06-20 23:22:55 +0300 |
commit | 48ae1a36dabff33746c8399f190b92e4c77ecb6e (patch) | |
tree | 5c4e67cb669ad12ca6c0011c703f9d049c82da3d /src/testcurl | |
parent | 04ad057ab93959a7d437709eb59dfa5ca950a293 (diff) | |
download | libmicrohttpd-48ae1a36dabff33746c8399f190b92e4c77ecb6e.tar.gz libmicrohttpd-48ae1a36dabff33746c8399f190b92e4c77ecb6e.zip |
Added test with large folded header
Diffstat (limited to 'src/testcurl')
-rw-r--r-- | src/testcurl/Makefile.am | 3 | ||||
-rw-r--r-- | src/testcurl/test_put_header_fold.c | 49 |
2 files changed, 49 insertions, 3 deletions
diff --git a/src/testcurl/Makefile.am b/src/testcurl/Makefile.am index c9a9473f..b95c798d 100644 --- a/src/testcurl/Makefile.am +++ b/src/testcurl/Makefile.am | |||
@@ -141,6 +141,7 @@ check_PROGRAMS = \ | |||
141 | test_put_header_fold \ | 141 | test_put_header_fold \ |
142 | test_put_large_header_fold \ | 142 | test_put_large_header_fold \ |
143 | test_put_header_fold_last \ | 143 | test_put_header_fold_last \ |
144 | test_put_header_fold_large \ | ||
144 | $(EMPTY_ITEM) | 145 | $(EMPTY_ITEM) |
145 | 146 | ||
146 | if ENABLE_COOKIE | 147 | if ENABLE_COOKIE |
@@ -642,3 +643,5 @@ test_put_large_header_fold_SOURCES = $(test_put_header_fold_SOURCES) | |||
642 | test_get_header_fold_SOURCES = $(test_put_header_fold_SOURCES) | 643 | test_get_header_fold_SOURCES = $(test_put_header_fold_SOURCES) |
643 | 644 | ||
644 | test_put_header_fold_last_SOURCES = $(test_put_header_fold_SOURCES) | 645 | test_put_header_fold_last_SOURCES = $(test_put_header_fold_SOURCES) |
646 | |||
647 | test_put_header_fold_large_SOURCES = $(test_put_header_fold_SOURCES) | ||
diff --git a/src/testcurl/test_put_header_fold.c b/src/testcurl/test_put_header_fold.c index c9a1d46d..61a781af 100644 --- a/src/testcurl/test_put_header_fold.c +++ b/src/testcurl/test_put_header_fold.c | |||
@@ -268,6 +268,7 @@ static int use_get; | |||
268 | static int use_put; | 268 | static int use_put; |
269 | static int use_put_large; | 269 | static int use_put_large; |
270 | static int use_hdr_last; /**< If non-zero, folded header is placed last */ | 270 | static int use_hdr_last; /**< If non-zero, folded header is placed last */ |
271 | static int use_hdr_large; /**< If non-zero, folded header is large */ | ||
271 | 272 | ||
272 | /* Static data */ | 273 | /* Static data */ |
273 | static struct curl_slist *libcurl_headers = NULL; | 274 | static struct curl_slist *libcurl_headers = NULL; |
@@ -294,9 +295,48 @@ libcurl_headers_init (void) | |||
294 | libcurlErrorExitDesc ("curl_slist_append() failed"); | 295 | libcurlErrorExitDesc ("curl_slist_append() failed"); |
295 | } | 296 | } |
296 | 297 | ||
297 | libcurl_headers = curl_slist_append (libcurl_headers, RQ_HEADER2); | 298 | if (! use_hdr_large) |
298 | if (NULL == libcurl_headers) | 299 | { |
299 | libcurlErrorExitDesc ("curl_slist_append() failed"); | 300 | libcurl_headers = curl_slist_append (libcurl_headers, RQ_HEADER2); |
301 | if (NULL == libcurl_headers) | ||
302 | libcurlErrorExitDesc ("curl_slist_append() failed"); | ||
303 | } | ||
304 | else | ||
305 | { | ||
306 | char *buf; | ||
307 | size_t pos; | ||
308 | buf = malloc (TEST_UPLOAD_DATA_SIZE + 1); | ||
309 | if (NULL == buf) | ||
310 | externalErrorExitDesc ("malloc() failed"); | ||
311 | pos = 0; | ||
312 | memcpy (buf, RQ_HEADER2_NAME, MHD_STATICSTR_LEN_ (RQ_HEADER2_NAME)); | ||
313 | pos += MHD_STATICSTR_LEN_ (RQ_HEADER2_NAME); | ||
314 | buf[pos++] = ':'; | ||
315 | buf[pos++] = ' '; | ||
316 | memcpy (buf + pos, | ||
317 | RQ_HEADER2_VALUE_S, MHD_STATICSTR_LEN_ (RQ_HEADER2_VALUE_S)); | ||
318 | pos += MHD_STATICSTR_LEN_ (RQ_HEADER2_VALUE_S); | ||
319 | memcpy (buf + pos, HDR_FOLD, MHD_STATICSTR_LEN_ (HDR_FOLD)); | ||
320 | pos += MHD_STATICSTR_LEN_ (HDR_FOLD); | ||
321 | memset (buf + pos, 'a', | ||
322 | TEST_UPLOAD_DATA_SIZE - pos | ||
323 | - MHD_STATICSTR_LEN_ (RQ_HEADER2_VALUE_E) - 1); | ||
324 | pos += TEST_UPLOAD_DATA_SIZE - pos | ||
325 | - MHD_STATICSTR_LEN_ (RQ_HEADER2_VALUE_E) - 1; | ||
326 | buf[pos++] = ' '; | ||
327 | memcpy (buf + pos, | ||
328 | RQ_HEADER2_VALUE_E, MHD_STATICSTR_LEN_ (RQ_HEADER2_VALUE_E)); | ||
329 | pos += MHD_STATICSTR_LEN_ (RQ_HEADER2_VALUE_E); | ||
330 | if (TEST_UPLOAD_DATA_SIZE != pos) | ||
331 | externalErrorExitDesc ("Position miscalculation"); | ||
332 | buf[pos] = 0; | ||
333 | |||
334 | libcurl_headers = curl_slist_append (libcurl_headers, buf); | ||
335 | if (NULL == libcurl_headers) | ||
336 | libcurlErrorExitDesc ("curl_slist_append() failed"); | ||
337 | |||
338 | free (buf); | ||
339 | } | ||
300 | 340 | ||
301 | if (! use_hdr_last) | 341 | if (! use_hdr_last) |
302 | { | 342 | { |
@@ -1078,6 +1118,8 @@ performCheck (void) | |||
1078 | port += UINT16_C (4); | 1118 | port += UINT16_C (4); |
1079 | if (use_hdr_last) | 1119 | if (use_hdr_last) |
1080 | port += UINT16_C (8); | 1120 | port += UINT16_C (8); |
1121 | if (use_hdr_large) | ||
1122 | port += UINT16_C (16); | ||
1081 | } | 1123 | } |
1082 | 1124 | ||
1083 | if (1) | 1125 | if (1) |
@@ -1226,6 +1268,7 @@ main (int argc, char *const *argv) | |||
1226 | 1268 | ||
1227 | use_put_large = has_in_name (argv[0], "_put_large"); | 1269 | use_put_large = has_in_name (argv[0], "_put_large"); |
1228 | use_hdr_last = has_in_name (argv[0], "_last"); | 1270 | use_hdr_last = has_in_name (argv[0], "_last"); |
1271 | use_hdr_large = has_in_name (argv[0], "_fold_large"); | ||
1229 | 1272 | ||
1230 | if (1 != | 1273 | if (1 != |
1231 | ((use_get ? 1 : 0) + (use_put ? 1 : 0))) | 1274 | ((use_get ? 1 : 0) + (use_put ? 1 : 0))) |