diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-01-04 12:40:03 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-01-04 12:40:03 +0000 |
commit | 43542a78c6bfc10dc06196c0702b802eb6a45591 (patch) | |
tree | 3857b4ec8cd7ce3c8cbba77de74902cdd6b92c10 | |
parent | 3af8f4ce646d29cd5942a1e3dda3b7ed03a82af6 (diff) | |
download | libmicrohttpd-43542a78c6bfc10dc06196c0702b802eb6a45591.tar.gz libmicrohttpd-43542a78c6bfc10dc06196c0702b802eb6a45591.zip |
introducing MHD_create_response_from_buffer, deprecating MHD_create_response_from_data
49 files changed, 297 insertions, 143 deletions
@@ -1,3 +1,8 @@ | |||
1 | Tue Jan 4 13:07:21 CET 2011 | ||
2 | Added MHD_create_response_from_buffer, deprecating | ||
3 | MHD_create_response_from_data. Deprecating | ||
4 | MHD_create_response_from_fd as well. -CG | ||
5 | |||
1 | Sun Dec 26 00:02:15 CET 2010 | 6 | Sun Dec 26 00:02:15 CET 2010 |
2 | Releasing libmicrohttpd 0.9.4. -CG | 7 | Releasing libmicrohttpd 0.9.4. -CG |
3 | 8 | ||
diff --git a/doc/chapters/basicauthentication.inc b/doc/chapters/basicauthentication.inc index 8c7c241c..bbdd3641 100644 --- a/doc/chapters/basicauthentication.inc +++ b/doc/chapters/basicauthentication.inc | |||
@@ -107,8 +107,8 @@ answer_to_connection (void *cls, struct MHD_Connection *connection, | |||
107 | { | 107 | { |
108 | const char *page = "<html><body>Go away.</body></html>"; | 108 | const char *page = "<html><body>Go away.</body></html>"; |
109 | response = | 109 | response = |
110 | MHD_create_response_from_data (strlen (page), (void *) page, MHD_NO, | 110 | MHD_create_response_from_buffer (strlen (page), (void *) page, |
111 | MHD_NO); | 111 | MHD_RESPMEM_PERSISTENT); |
112 | ret = MHD_queue_basic_auth_fail_response (connection, | 112 | ret = MHD_queue_basic_auth_fail_response (connection, |
113 | "my realm", | 113 | "my realm", |
114 | response); | 114 | response); |
@@ -117,8 +117,8 @@ answer_to_connection (void *cls, struct MHD_Connection *connection, | |||
117 | { | 117 | { |
118 | const char *page = "<html><body>A secret.</body></html>"; | 118 | const char *page = "<html><body>A secret.</body></html>"; |
119 | response = | 119 | response = |
120 | MHD_create_response_from_data (strlen (page), (void *) page, MHD_NO, | 120 | MHD_create_response_from_buffer (strlen (page), (void *) page, |
121 | MHD_NO); | 121 | MHD_RESPMEM_PERSISTENT); |
122 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 122 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
123 | } | 123 | } |
124 | MHD_destroy_response (response); | 124 | MHD_destroy_response (response); |
diff --git a/doc/chapters/hellobrowser.inc b/doc/chapters/hellobrowser.inc index 65681de2..bfb5166e 100644 --- a/doc/chapters/hellobrowser.inc +++ b/doc/chapters/hellobrowser.inc | |||
@@ -54,7 +54,7 @@ HTTP is a rather strict protocol and the client would certainly consider it "ina | |||
54 | just sent the answer string "as is". Instead, it has to be wrapped with additional information stored in so-called headers and footers. Most of the work in this area is done by the library for us---we | 54 | just sent the answer string "as is". Instead, it has to be wrapped with additional information stored in so-called headers and footers. Most of the work in this area is done by the library for us---we |
55 | just have to ask. Our reply string packed in the necessary layers will be called a "response". | 55 | just have to ask. Our reply string packed in the necessary layers will be called a "response". |
56 | To obtain such a response we hand our data (the reply--string) and its size over to the | 56 | To obtain such a response we hand our data (the reply--string) and its size over to the |
57 | @code{MHD_create_response_from_data} function. The last two parameters basically tell @emph{MHD} | 57 | @code{MHD_create_response_from_buffer} function. The last two parameters basically tell @emph{MHD} |
58 | that we do not want it to dispose the message data for us when it has been sent and there also needs | 58 | that we do not want it to dispose the message data for us when it has been sent and there also needs |
59 | no internal copy to be done because the @emph{constant} string won't change anyway. | 59 | no internal copy to be done because the @emph{constant} string won't change anyway. |
60 | 60 | ||
@@ -62,8 +62,8 @@ no internal copy to be done because the @emph{constant} string won't change anyw | |||
62 | struct MHD_Response *response; | 62 | struct MHD_Response *response; |
63 | int ret; | 63 | int ret; |
64 | 64 | ||
65 | response = MHD_create_response_from_data (strlen (page), | 65 | response = MHD_create_response_from_buffer (strlen (page), |
66 | (void*) page, MHD_NO, MHD_NO); | 66 | (void*) page, MHD_RESPMEM_PERSISTENT); |
67 | 67 | ||
68 | @end verbatim | 68 | @end verbatim |
69 | 69 | ||
diff --git a/doc/chapters/largerpost.inc b/doc/chapters/largerpost.inc index 2f0a404c..1f60028f 100644 --- a/doc/chapters/largerpost.inc +++ b/doc/chapters/largerpost.inc | |||
@@ -67,8 +67,8 @@ send_page (struct MHD_Connection *connection, | |||
67 | int ret; | 67 | int ret; |
68 | struct MHD_Response *response; | 68 | struct MHD_Response *response; |
69 | 69 | ||
70 | response = MHD_create_response_from_data (strlen (page), (void*) page, | 70 | response = MHD_create_response_from_buffer (strlen (page), (void*) page, |
71 | MHD_NO, MHD_YES); | 71 | MHD_RESPMEM_MUST_COPY); |
72 | if (!response) return MHD_NO; | 72 | if (!response) return MHD_NO; |
73 | 73 | ||
74 | ret = MHD_queue_response (connection, status_code, response); | 74 | ret = MHD_queue_response (connection, status_code, response); |
diff --git a/doc/chapters/responseheaders.inc b/doc/chapters/responseheaders.inc index 70fb3208..0c9f7ab2 100644 --- a/doc/chapters/responseheaders.inc +++ b/doc/chapters/responseheaders.inc | |||
@@ -63,9 +63,9 @@ server side and if so, the client should be informed with @code{MHD_HTTP_INTERNA | |||
63 | "<html><body>An internal server error has occured!\ | 63 | "<html><body>An internal server error has occured!\ |
64 | </body></html>"; | 64 | </body></html>"; |
65 | response = | 65 | response = |
66 | MHD_create_response_from_data (strlen (errorstr), | 66 | MHD_create_response_from_buffer (strlen (errorstr), |
67 | (void *) errorstr, | 67 | (void *) errorstr, |
68 | MHD_NO, MHD_NO); | 68 | MHD_RESPMEM_PERSISTENT); |
69 | if (response) | 69 | if (response) |
70 | { | 70 | { |
71 | ret = | 71 | ret = |
@@ -84,8 +84,8 @@ server side and if so, the client should be informed with @code{MHD_HTTP_INTERNA | |||
84 | 84 | ||
85 | if (buffer) free(buffer); | 85 | if (buffer) free(buffer); |
86 | 86 | ||
87 | response = MHD_create_response_from_data(strlen(errorstr), (void*)errorstr, | 87 | response = MHD_create_response_from_buffer (strlen(errorstr), (void*) errorstr, |
88 | MHD_NO, MHD_NO); | 88 | MHD_RESPMEM_PERSISTENT); |
89 | 89 | ||
90 | if (response) | 90 | if (response) |
91 | { | 91 | { |
@@ -113,7 +113,7 @@ But in the case of success a response will be constructed directly from the file | |||
113 | } | 113 | } |
114 | 114 | ||
115 | response = | 115 | response = |
116 | MHD_create_response_from_fd (fd, sbuf.st_size); | 116 | MHD_create_response_from_fd_at_offset (fd, sbuf.st_size, 0); |
117 | MHD_add_response_header (response, "Content-Type", MIMETYPE); | 117 | MHD_add_response_header (response, "Content-Type", MIMETYPE); |
118 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 118 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
119 | MHD_destroy_response (response); | 119 | MHD_destroy_response (response); |
diff --git a/doc/examples/basicauthentication.c b/doc/examples/basicauthentication.c index 0b5ce62c..da617098 100644 --- a/doc/examples/basicauthentication.c +++ b/doc/examples/basicauthentication.c | |||
@@ -40,8 +40,8 @@ answer_to_connection (void *cls, struct MHD_Connection *connection, | |||
40 | { | 40 | { |
41 | const char *page = "<html><body>Go away.</body></html>"; | 41 | const char *page = "<html><body>Go away.</body></html>"; |
42 | response = | 42 | response = |
43 | MHD_create_response_from_data (strlen (page), (void *) page, MHD_NO, | 43 | MHD_create_response_from_buffer (strlen (page), (void *) page, |
44 | MHD_NO); | 44 | MHD_RESPMEM_PERSISTENT); |
45 | ret = MHD_queue_basic_auth_fail_response (connection, | 45 | ret = MHD_queue_basic_auth_fail_response (connection, |
46 | "my realm", | 46 | "my realm", |
47 | response); | 47 | response); |
@@ -50,8 +50,8 @@ answer_to_connection (void *cls, struct MHD_Connection *connection, | |||
50 | { | 50 | { |
51 | const char *page = "<html><body>A secret.</body></html>"; | 51 | const char *page = "<html><body>A secret.</body></html>"; |
52 | response = | 52 | response = |
53 | MHD_create_response_from_data (strlen (page), (void *) page, MHD_NO, | 53 | MHD_create_response_from_buffer (strlen (page), (void *) page, |
54 | MHD_NO); | 54 | MHD_RESPMEM_PERSISTENT); |
55 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 55 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
56 | } | 56 | } |
57 | MHD_destroy_response (response); | 57 | MHD_destroy_response (response); |
diff --git a/doc/examples/hellobrowser.c b/doc/examples/hellobrowser.c index b155833d..defb5ae4 100644 --- a/doc/examples/hellobrowser.c +++ b/doc/examples/hellobrowser.c | |||
@@ -16,8 +16,8 @@ answer_to_connection (void *cls, struct MHD_Connection *connection, | |||
16 | int ret; | 16 | int ret; |
17 | 17 | ||
18 | response = | 18 | response = |
19 | MHD_create_response_from_data (strlen (page), (void *) page, MHD_NO, | 19 | MHD_create_response_from_buffer (strlen (page), (void *) page, |
20 | MHD_NO); | 20 | MHD_RESPMEM_PERSISTENT); |
21 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 21 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
22 | MHD_destroy_response (response); | 22 | MHD_destroy_response (response); |
23 | 23 | ||
diff --git a/doc/examples/largepost.c b/doc/examples/largepost.c index 82f06e26..df36f1e9 100644 --- a/doc/examples/largepost.c +++ b/doc/examples/largepost.c | |||
@@ -51,8 +51,8 @@ send_page (struct MHD_Connection *connection, const char *page, | |||
51 | struct MHD_Response *response; | 51 | struct MHD_Response *response; |
52 | 52 | ||
53 | response = | 53 | response = |
54 | MHD_create_response_from_data (strlen (page), (void *) page, MHD_NO, | 54 | MHD_create_response_from_buffer (strlen (page), (void *) page, |
55 | MHD_YES); | 55 | MHD_RESPMEM_PERSISTENT); |
56 | if (!response) | 56 | if (!response) |
57 | return MHD_NO; | 57 | return MHD_NO; |
58 | 58 | ||
diff --git a/doc/examples/responseheaders.c b/doc/examples/responseheaders.c index c45f7c24..a78db1b9 100644 --- a/doc/examples/responseheaders.c +++ b/doc/examples/responseheaders.c | |||
@@ -31,9 +31,9 @@ answer_to_connection (void *cls, struct MHD_Connection *connection, | |||
31 | "<html><body>An internal server error has occured!\ | 31 | "<html><body>An internal server error has occured!\ |
32 | </body></html>"; | 32 | </body></html>"; |
33 | response = | 33 | response = |
34 | MHD_create_response_from_data (strlen (errorstr), | 34 | MHD_create_response_from_buffer (strlen (errorstr), |
35 | (void *) errorstr, | 35 | (void *) errorstr, |
36 | MHD_NO, MHD_NO); | 36 | MHD_RESPMEM_PERSISTENT); |
37 | if (response) | 37 | if (response) |
38 | { | 38 | { |
39 | ret = | 39 | ret = |
@@ -47,7 +47,7 @@ answer_to_connection (void *cls, struct MHD_Connection *connection, | |||
47 | return MHD_NO; | 47 | return MHD_NO; |
48 | } | 48 | } |
49 | response = | 49 | response = |
50 | MHD_create_response_from_fd (fd, sbuf.st_size); | 50 | MHD_create_response_from_fd_at_offset (fd, sbuf.st_size, 0); |
51 | MHD_add_response_header (response, "Content-Type", MIMETYPE); | 51 | MHD_add_response_header (response, "Content-Type", MIMETYPE); |
52 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 52 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
53 | MHD_destroy_response (response); | 53 | MHD_destroy_response (response); |
diff --git a/doc/examples/simplepost.c b/doc/examples/simplepost.c index 225f4122..1bf2885b 100644 --- a/doc/examples/simplepost.c +++ b/doc/examples/simplepost.c | |||
@@ -40,8 +40,8 @@ send_page (struct MHD_Connection *connection, const char *page) | |||
40 | 40 | ||
41 | 41 | ||
42 | response = | 42 | response = |
43 | MHD_create_response_from_data (strlen (page), (void *) page, MHD_NO, | 43 | MHD_create_response_from_buffer (strlen (page), (void *) page, |
44 | MHD_NO); | 44 | MHD_RESPMEM_PERSISTENT); |
45 | if (!response) | 45 | if (!response) |
46 | return MHD_NO; | 46 | return MHD_NO; |
47 | 47 | ||
diff --git a/doc/examples/tlsauthentication.c b/doc/examples/tlsauthentication.c index 906d97b5..7d6e66f5 100644 --- a/doc/examples/tlsauthentication.c +++ b/doc/examples/tlsauthentication.c | |||
@@ -113,7 +113,8 @@ ask_for_authentication (struct MHD_Connection *connection, const char *realm) | |||
113 | char *headervalue; | 113 | char *headervalue; |
114 | const char *strbase = "Basic realm="; | 114 | const char *strbase = "Basic realm="; |
115 | 115 | ||
116 | response = MHD_create_response_from_data (0, NULL, MHD_NO, MHD_NO); | 116 | response = MHD_create_response_from_buffer (0, NULL, |
117 | MHD_RESPMEM_PERSISTENT); | ||
117 | if (!response) | 118 | if (!response) |
118 | return MHD_NO; | 119 | return MHD_NO; |
119 | 120 | ||
@@ -186,8 +187,8 @@ secret_page (struct MHD_Connection *connection) | |||
186 | const char *page = "<html><body>A secret.</body></html>"; | 187 | const char *page = "<html><body>A secret.</body></html>"; |
187 | 188 | ||
188 | response = | 189 | response = |
189 | MHD_create_response_from_data (strlen (page), (void *) page, MHD_NO, | 190 | MHD_create_response_from_buffer (strlen (page), (void *) page, |
190 | MHD_NO); | 191 | MHD_RESPMEM_PERSISTENT); |
191 | if (!response) | 192 | if (!response) |
192 | return MHD_NO; | 193 | return MHD_NO; |
193 | 194 | ||
diff --git a/doc/microhttpd.texi b/doc/microhttpd.texi index fd646fef..e96ef842 100644 --- a/doc/microhttpd.texi +++ b/doc/microhttpd.texi | |||
@@ -674,6 +674,31 @@ We had to close the session since @mhd{} was being shut down. | |||
674 | @end deftp | 674 | @end deftp |
675 | 675 | ||
676 | 676 | ||
677 | @deftp {Enumeration} MHD_ResponseMemoryMode | ||
678 | The @code{MHD_ResponeMemoryMode} specifies how MHD should treat | ||
679 | the memory buffer given for the response in | ||
680 | @code{MHD_create_response_from_buffer}. | ||
681 | |||
682 | @table @code | ||
683 | @item MHD_RESPMEM_PERSISTENT | ||
684 | Buffer is a persistent (static/global) buffer that won't change | ||
685 | for at least the lifetime of the response, MHD should just use | ||
686 | it, not free it, not copy it, just keep an alias to it. | ||
687 | |||
688 | @item MHD_RESPMEM_MUST_FREE | ||
689 | Buffer is heap-allocated with @code{malloc} (or equivalent) and | ||
690 | should be freed by MHD after processing the response has | ||
691 | concluded (response reference counter reaches zero). | ||
692 | |||
693 | @item MHD_RESPMEM_MUST_COPY | ||
694 | Buffer is in transient memory, but not on the heap (for example, | ||
695 | on the stack or non-malloc allocated) and only valid during the | ||
696 | call to @code{MHD_create_response_from_buffer}. MHD must make its | ||
697 | own private copy of the data for processing. | ||
698 | |||
699 | @end table | ||
700 | @end deftp | ||
701 | |||
677 | 702 | ||
678 | @deftp {Enumeration} MHD_ConnectionInfoType | 703 | @deftp {Enumeration} MHD_ConnectionInfoType |
679 | Values of this enum are used to specify what information about a | 704 | Values of this enum are used to specify what information about a |
@@ -1245,7 +1270,7 @@ structures through @cfunction{Tcl_IncrRefCount} and | |||
1245 | a @code{MHD_Response} object is allocated: | 1270 | a @code{MHD_Response} object is allocated: |
1246 | 1271 | ||
1247 | @example | 1272 | @example |
1248 | struct MHD_Response * response = MHD_create_response_from_data(...); | 1273 | struct MHD_Response * response = MHD_create_response_from_buffer(...); |
1249 | /* here: reference counter = 1 */ | 1274 | /* here: reference counter = 1 */ |
1250 | @end example | 1275 | @end example |
1251 | 1276 | ||
@@ -1312,6 +1337,8 @@ Return @mynull{} on error (i.e. invalid arguments, out of memory). | |||
1312 | @deftypefun {struct MHD_Response *} MHD_create_response_from_fd (uint64_t size, int fd) | 1337 | @deftypefun {struct MHD_Response *} MHD_create_response_from_fd (uint64_t size, int fd) |
1313 | Create a response object. The response object can be extended with | 1338 | Create a response object. The response object can be extended with |
1314 | header information and then it can be used any number of times. | 1339 | header information and then it can be used any number of times. |
1340 | Function is deprecated, use @code{MHD_create_response_from_fd_at_offset} | ||
1341 | instead (with an offset of zero). | ||
1315 | 1342 | ||
1316 | @table @var | 1343 | @table @var |
1317 | @item size | 1344 | @item size |
@@ -1352,9 +1379,34 @@ Return @mynull{} on error (i.e. invalid arguments, out of memory). | |||
1352 | @end deftypefun | 1379 | @end deftypefun |
1353 | 1380 | ||
1354 | 1381 | ||
1382 | @deftypefun {struct MHD_Response *} MHD_create_response_from_buffer (size_t size, void *data, enum MHD_ResponseMemoryMode mode) | ||
1383 | Create a response object. The response object can be extended with | ||
1384 | header information and then it can be used any number of times. | ||
1385 | |||
1386 | @table @var | ||
1387 | @item size | ||
1388 | size of the data portion of the response; | ||
1389 | |||
1390 | @item buffer | ||
1391 | the data itself; | ||
1392 | |||
1393 | @item mode | ||
1394 | memory management options for buffer; use | ||
1395 | MHD_RESPMEM_PERSISTENT if the buffer is static/global memory, | ||
1396 | use MHD_RESPMEM_MUST_FREE if the buffer is heap-allocated and | ||
1397 | should be freed by @mhd{} and MHD_RESPMEM_MUST_COPY if the | ||
1398 | buffer is in transient memory (i.e. on the stack) and must | ||
1399 | be copied by @mhd{}; | ||
1400 | @end table | ||
1401 | |||
1402 | Return @mynull{} on error (i.e. invalid arguments, out of memory). | ||
1403 | @end deftypefun | ||
1404 | |||
1405 | |||
1355 | @deftypefun {struct MHD_Response *} MHD_create_response_from_data (size_t size, void *data, int must_free, int must_copy) | 1406 | @deftypefun {struct MHD_Response *} MHD_create_response_from_data (size_t size, void *data, int must_free, int must_copy) |
1356 | Create a response object. The response object can be extended with | 1407 | Create a response object. The response object can be extended with |
1357 | header information and then it can be used any number of times. | 1408 | header information and then it can be used any number of times. |
1409 | This function is deprecated, use @code{MHD_create_response_from_buffer} instead. | ||
1358 | 1410 | ||
1359 | @table @var | 1411 | @table @var |
1360 | @item size | 1412 | @item size |
@@ -1385,8 +1437,8 @@ const char * data = "<html><body><p>Error!</p></body></html>"; | |||
1385 | struct MHD_Connection * connection = ...; | 1437 | struct MHD_Connection * connection = ...; |
1386 | struct MHD_Response * response; | 1438 | struct MHD_Response * response; |
1387 | 1439 | ||
1388 | response = MHD_create_response_from_data(strlen(data), data, | 1440 | response = MHD_create_response_from_buffer (strlen(data), data, |
1389 | MHD_NO, MHD_NO); | 1441 | MHD_RESPMEM_PERSISTENT); |
1390 | MHD_queue_response(connection, 404, response); | 1442 | MHD_queue_response(connection, 404, response); |
1391 | MHD_destroy_response(response); | 1443 | MHD_destroy_response(response); |
1392 | @end example | 1444 | @end example |
@@ -1599,9 +1651,9 @@ ahc_echo (void *cls, | |||
1599 | username = MHD_digest_auth_get_username(connection); | 1651 | username = MHD_digest_auth_get_username(connection); |
1600 | if (username == NULL) | 1652 | if (username == NULL) |
1601 | @{ | 1653 | @{ |
1602 | response = MHD_create_response_from_data(strlen (DENIED), | 1654 | response = MHD_create_response_from_buffer(strlen (DENIED), |
1603 | DENIED, | 1655 | DENIED, |
1604 | MHD_NO, MHD_NO); | 1656 | MHD_RESPMEM_PERSISTENT); |
1605 | ret = MHD_queue_auth_fail_response(connection, realm, | 1657 | ret = MHD_queue_auth_fail_response(connection, realm, |
1606 | OPAQUE, | 1658 | OPAQUE, |
1607 | response, | 1659 | response, |
@@ -1617,9 +1669,9 @@ ahc_echo (void *cls, | |||
1617 | if ( (ret == MHD_INVALID_NONCE) || | 1669 | if ( (ret == MHD_INVALID_NONCE) || |
1618 | (ret == MHD_NO) ) | 1670 | (ret == MHD_NO) ) |
1619 | @{ | 1671 | @{ |
1620 | response = MHD_create_response_from_data(strlen (DENIED), | 1672 | response = MHD_create_response_from_buffer(strlen (DENIED), |
1621 | DENIED, | 1673 | DENIED, |
1622 | MHD_NO, MHD_NO); | 1674 | MHD_RESPMEM_PERSISTENT); |
1623 | if (NULL == response) | 1675 | if (NULL == response) |
1624 | return MHD_NO; | 1676 | return MHD_NO; |
1625 | ret = MHD_queue_auth_fail_response(connection, realm, | 1677 | ret = MHD_queue_auth_fail_response(connection, realm, |
@@ -1629,8 +1681,8 @@ ahc_echo (void *cls, | |||
1629 | MHD_destroy_response(response); | 1681 | MHD_destroy_response(response); |
1630 | return ret; | 1682 | return ret; |
1631 | @} | 1683 | @} |
1632 | response = MHD_create_response_from_data(strlen(PAGE), PAGE, | 1684 | response = MHD_create_response_from_buffer (strlen(PAGE), PAGE, |
1633 | MHD_NO, MHD_NO); | 1685 | MHD_RESPMEM_PERSISTENT); |
1634 | ret = MHD_queue_response(connection, MHD_HTTP_OK, response); | 1686 | ret = MHD_queue_response(connection, MHD_HTTP_OK, response); |
1635 | MHD_destroy_response(response); | 1687 | MHD_destroy_response(response); |
1636 | return ret; | 1688 | return ret; |
diff --git a/src/daemon/connection.c b/src/daemon/connection.c index 8a6d4619..f20614dc 100644 --- a/src/daemon/connection.c +++ b/src/daemon/connection.c | |||
@@ -716,8 +716,9 @@ transmit_error_response (struct MHD_Connection *connection, | |||
716 | status_code, message); | 716 | status_code, message); |
717 | #endif | 717 | #endif |
718 | EXTRA_CHECK (connection->response == NULL); | 718 | EXTRA_CHECK (connection->response == NULL); |
719 | response = MHD_create_response_from_data (strlen (message), | 719 | response = MHD_create_response_from_buffer (strlen (message), |
720 | (void *) message, MHD_NO, MHD_NO); | 720 | (void *) message, |
721 | MHD_RESPMEM_PERSISTENT); | ||
721 | MHD_queue_response (connection, status_code, response); | 722 | MHD_queue_response (connection, status_code, response); |
722 | EXTRA_CHECK (connection->response != NULL); | 723 | EXTRA_CHECK (connection->response != NULL); |
723 | MHD_destroy_response (response); | 724 | MHD_destroy_response (response); |
@@ -1663,8 +1664,9 @@ parse_connection_headers (struct MHD_Connection *connection) | |||
1663 | #endif | 1664 | #endif |
1664 | EXTRA_CHECK (connection->response == NULL); | 1665 | EXTRA_CHECK (connection->response == NULL); |
1665 | response = | 1666 | response = |
1666 | MHD_create_response_from_data (strlen (REQUEST_LACKS_HOST), | 1667 | MHD_create_response_from_buffer (strlen (REQUEST_LACKS_HOST), |
1667 | REQUEST_LACKS_HOST, MHD_NO, MHD_NO); | 1668 | REQUEST_LACKS_HOST, |
1669 | MHD_RESPMEM_PERSISTENT); | ||
1668 | MHD_queue_response (connection, MHD_HTTP_BAD_REQUEST, response); | 1670 | MHD_queue_response (connection, MHD_HTTP_BAD_REQUEST, response); |
1669 | MHD_destroy_response (response); | 1671 | MHD_destroy_response (response); |
1670 | return; | 1672 | return; |
diff --git a/src/daemon/response.c b/src/daemon/response.c index 7d9ae17c..db846674 100644 --- a/src/daemon/response.c +++ b/src/daemon/response.c | |||
@@ -352,6 +352,7 @@ struct MHD_Response *MHD_create_response_from_fd (size_t size, | |||
352 | * right away, the data maybe released anytime after | 352 | * right away, the data maybe released anytime after |
353 | * this call returns | 353 | * this call returns |
354 | * @return NULL on error (i.e. invalid arguments, out of memory) | 354 | * @return NULL on error (i.e. invalid arguments, out of memory) |
355 | * @deprecated use MHD_create_response_from_buffer instead | ||
355 | */ | 356 | */ |
356 | struct MHD_Response * | 357 | struct MHD_Response * |
357 | MHD_create_response_from_data (size_t size, | 358 | MHD_create_response_from_data (size_t size, |
@@ -382,7 +383,7 @@ MHD_create_response_from_data (size_t size, | |||
382 | return NULL; | 383 | return NULL; |
383 | } | 384 | } |
384 | memcpy (tmp, data, size); | 385 | memcpy (tmp, data, size); |
385 | must_free = 1; | 386 | must_free = MHD_YES; |
386 | data = tmp; | 387 | data = tmp; |
387 | } | 388 | } |
388 | retVal->crc = NULL; | 389 | retVal->crc = NULL; |
@@ -395,6 +396,28 @@ MHD_create_response_from_data (size_t size, | |||
395 | return retVal; | 396 | return retVal; |
396 | } | 397 | } |
397 | 398 | ||
399 | |||
400 | /** | ||
401 | * Create a response object. The response object can be extended with | ||
402 | * header information and then be used any number of times. | ||
403 | * | ||
404 | * @param size size of the data portion of the response | ||
405 | * @param buffer size bytes containing the response's data portion | ||
406 | * @param mode flags for buffer management | ||
407 | * @return NULL on error (i.e. invalid arguments, out of memory) | ||
408 | */ | ||
409 | struct MHD_Response * | ||
410 | MHD_create_response_from_buffer (size_t size, | ||
411 | void *buffer, | ||
412 | enum MHD_ResponseMemoryMode mode) | ||
413 | { | ||
414 | return MHD_create_response_from_data (size, | ||
415 | buffer, | ||
416 | mode == MHD_RESPMEM_MUST_FREE, | ||
417 | mode == MHD_RESPMEM_MUST_COPY); | ||
418 | } | ||
419 | |||
420 | |||
398 | /** | 421 | /** |
399 | * Destroy a response object and associated resources. Note that | 422 | * Destroy a response object and associated resources. Note that |
400 | * libmicrohttpd may keep some of the resources around if the response | 423 | * libmicrohttpd may keep some of the resources around if the response |
diff --git a/src/examples/authorization_example.c b/src/examples/authorization_example.c index b271053e..60512183 100644 --- a/src/examples/authorization_example.c +++ b/src/examples/authorization_example.c | |||
@@ -63,17 +63,18 @@ ahc_echo (void *cls, | |||
63 | (0 != strcmp (auth, "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="))) | 63 | (0 != strcmp (auth, "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="))) |
64 | { | 64 | { |
65 | /* require: "Aladdin" with password "open sesame" */ | 65 | /* require: "Aladdin" with password "open sesame" */ |
66 | response = MHD_create_response_from_data (strlen (DENIED), | 66 | response = MHD_create_response_from_buffer (strlen (DENIED), |
67 | (void *) DENIED, MHD_NO, | 67 | (void *) DENIED, |
68 | MHD_NO); | 68 | MHD_RESPMEM_PERSISTENT); |
69 | MHD_add_response_header (response, MHD_HTTP_HEADER_WWW_AUTHENTICATE, | 69 | MHD_add_response_header (response, MHD_HTTP_HEADER_WWW_AUTHENTICATE, |
70 | "Basic realm=\"TestRealm\""); | 70 | "Basic realm=\"TestRealm\""); |
71 | code = MHD_HTTP_UNAUTHORIZED; | 71 | code = MHD_HTTP_UNAUTHORIZED; |
72 | } | 72 | } |
73 | else | 73 | else |
74 | { | 74 | { |
75 | response = MHD_create_response_from_data (strlen (me), | 75 | response = MHD_create_response_from_buffer (strlen (me), |
76 | (void *) me, MHD_NO, MHD_NO); | 76 | (void *) me, |
77 | MHD_RESPMEM_PERSISTENT); | ||
77 | code = MHD_HTTP_OK; | 78 | code = MHD_HTTP_OK; |
78 | } | 79 | } |
79 | ret = MHD_queue_response (connection, code, response); | 80 | ret = MHD_queue_response (connection, code, response); |
diff --git a/src/examples/digest_auth_example.c b/src/examples/digest_auth_example.c index bf6f896f..01f09dec 100644 --- a/src/examples/digest_auth_example.c +++ b/src/examples/digest_auth_example.c | |||
@@ -49,9 +49,9 @@ ahc_echo (void *cls, | |||
49 | username = MHD_digest_auth_get_username(connection); | 49 | username = MHD_digest_auth_get_username(connection); |
50 | if (username == NULL) | 50 | if (username == NULL) |
51 | { | 51 | { |
52 | response = MHD_create_response_from_data(strlen (DENIED), | 52 | response = MHD_create_response_from_buffer(strlen (DENIED), |
53 | DENIED, | 53 | DENIED, |
54 | MHD_NO, MHD_NO); | 54 | MHD_RESPMEM_PERSISTENT); |
55 | ret = MHD_queue_auth_fail_response(connection, realm, | 55 | ret = MHD_queue_auth_fail_response(connection, realm, |
56 | OPAQUE, | 56 | OPAQUE, |
57 | response, | 57 | response, |
@@ -67,9 +67,9 @@ ahc_echo (void *cls, | |||
67 | if ( (ret == MHD_INVALID_NONCE) || | 67 | if ( (ret == MHD_INVALID_NONCE) || |
68 | (ret == MHD_NO) ) | 68 | (ret == MHD_NO) ) |
69 | { | 69 | { |
70 | response = MHD_create_response_from_data(strlen (DENIED), | 70 | response = MHD_create_response_from_buffer(strlen (DENIED), |
71 | DENIED, | 71 | DENIED, |
72 | MHD_NO, MHD_NO); | 72 | MHD_RESPMEM_PERSISTENT); |
73 | if (NULL == response) | 73 | if (NULL == response) |
74 | return MHD_NO; | 74 | return MHD_NO; |
75 | ret = MHD_queue_auth_fail_response(connection, realm, | 75 | ret = MHD_queue_auth_fail_response(connection, realm, |
@@ -79,8 +79,8 @@ ahc_echo (void *cls, | |||
79 | MHD_destroy_response(response); | 79 | MHD_destroy_response(response); |
80 | return ret; | 80 | return ret; |
81 | } | 81 | } |
82 | response = MHD_create_response_from_data(strlen(PAGE), PAGE, | 82 | response = MHD_create_response_from_buffer(strlen(PAGE), PAGE, |
83 | MHD_NO, MHD_NO); | 83 | MHD_RESPMEM_PERSISTENT); |
84 | ret = MHD_queue_response(connection, MHD_HTTP_OK, response); | 84 | ret = MHD_queue_response(connection, MHD_HTTP_OK, response); |
85 | MHD_destroy_response(response); | 85 | MHD_destroy_response(response); |
86 | return ret; | 86 | return ret; |
diff --git a/src/examples/fileserver_example.c b/src/examples/fileserver_example.c index f470a236..4441ac49 100644 --- a/src/examples/fileserver_example.c +++ b/src/examples/fileserver_example.c | |||
@@ -75,9 +75,9 @@ ahc_echo (void *cls, | |||
75 | file = NULL; | 75 | file = NULL; |
76 | if (file == NULL) | 76 | if (file == NULL) |
77 | { | 77 | { |
78 | response = MHD_create_response_from_data (strlen (PAGE), | 78 | response = MHD_create_response_from_buffer (strlen (PAGE), |
79 | (void *) PAGE, | 79 | (void *) PAGE, |
80 | MHD_NO, MHD_NO); | 80 | MHD_RESPMEM_PERSISTENT); |
81 | ret = MHD_queue_response (connection, MHD_HTTP_NOT_FOUND, response); | 81 | ret = MHD_queue_response (connection, MHD_HTTP_NOT_FOUND, response); |
82 | MHD_destroy_response (response); | 82 | MHD_destroy_response (response); |
83 | } | 83 | } |
diff --git a/src/examples/fileserver_example_dirs.c b/src/examples/fileserver_example_dirs.c index 836c0623..d5be6e2d 100644 --- a/src/examples/fileserver_example_dirs.c +++ b/src/examples/fileserver_example_dirs.c | |||
@@ -117,10 +117,9 @@ ahc_echo (void *cls, | |||
117 | sizeof (emsg), | 117 | sizeof (emsg), |
118 | "Failed to open directory `.': %s\n", | 118 | "Failed to open directory `.': %s\n", |
119 | strerror (errno)); | 119 | strerror (errno)); |
120 | response = MHD_create_response_from_data (strlen (emsg), | 120 | response = MHD_create_response_from_buffer (strlen (emsg), |
121 | emsg, | 121 | emsg, |
122 | MHD_NO, | 122 | MHD_RESPMEM_MUST_COPY); |
123 | MHD_YES); | ||
124 | if (response == NULL) | 123 | if (response == NULL) |
125 | return MHD_NO; | 124 | return MHD_NO; |
126 | ret = MHD_queue_response (connection, MHD_HTTP_SERVICE_UNAVAILABLE, response); | 125 | ret = MHD_queue_response (connection, MHD_HTTP_SERVICE_UNAVAILABLE, response); |
diff --git a/src/examples/fileserver_example_external_select.c b/src/examples/fileserver_example_external_select.c index a4dfcc1c..a7ab824a 100644 --- a/src/examples/fileserver_example_external_select.c +++ b/src/examples/fileserver_example_external_select.c | |||
@@ -76,9 +76,9 @@ ahc_echo (void *cls, | |||
76 | file = NULL; | 76 | file = NULL; |
77 | if (file == NULL) | 77 | if (file == NULL) |
78 | { | 78 | { |
79 | response = MHD_create_response_from_data (strlen (PAGE), | 79 | response = MHD_create_response_from_buffer (strlen (PAGE), |
80 | (void *) PAGE, | 80 | (void *) PAGE, |
81 | MHD_NO, MHD_NO); | 81 | MHD_RESPMEM_PERSISTENT); |
82 | ret = MHD_queue_response (connection, MHD_HTTP_NOT_FOUND, response); | 82 | ret = MHD_queue_response (connection, MHD_HTTP_NOT_FOUND, response); |
83 | MHD_destroy_response (response); | 83 | MHD_destroy_response (response); |
84 | } | 84 | } |
diff --git a/src/examples/https_fileserver_example.c b/src/examples/https_fileserver_example.c index fe1512ed..ca9d8a32 100644 --- a/src/examples/https_fileserver_example.c +++ b/src/examples/https_fileserver_example.c | |||
@@ -144,9 +144,9 @@ http_ahc (void *cls, | |||
144 | file = NULL; | 144 | file = NULL; |
145 | if (file == NULL) | 145 | if (file == NULL) |
146 | { | 146 | { |
147 | response = MHD_create_response_from_data (strlen (EMPTY_PAGE), | 147 | response = MHD_create_response_from_buffer (strlen (EMPTY_PAGE), |
148 | (void *) EMPTY_PAGE, | 148 | (void *) EMPTY_PAGE, |
149 | MHD_NO, MHD_NO); | 149 | MHD_RESPMEM_PERSISTENT); |
150 | ret = MHD_queue_response (connection, MHD_HTTP_NOT_FOUND, response); | 150 | ret = MHD_queue_response (connection, MHD_HTTP_NOT_FOUND, response); |
151 | MHD_destroy_response (response); | 151 | MHD_destroy_response (response); |
152 | } | 152 | } |
diff --git a/src/examples/minimal_example.c b/src/examples/minimal_example.c index 992a7ca3..9293242b 100644 --- a/src/examples/minimal_example.c +++ b/src/examples/minimal_example.c | |||
@@ -49,8 +49,9 @@ ahc_echo (void *cls, | |||
49 | return MHD_YES; | 49 | return MHD_YES; |
50 | } | 50 | } |
51 | *ptr = NULL; /* reset when done */ | 51 | *ptr = NULL; /* reset when done */ |
52 | response = MHD_create_response_from_data (strlen (me), | 52 | response = MHD_create_response_from_buffer (strlen (me), |
53 | (void *) me, MHD_NO, MHD_NO); | 53 | (void *) me, |
54 | MHD_RESPMEM_PERSISTENT); | ||
54 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 55 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
55 | MHD_destroy_response (response); | 56 | MHD_destroy_response (response); |
56 | return ret; | 57 | return ret; |
diff --git a/src/examples/querystring_example.c b/src/examples/querystring_example.c index b9f6fb47..533fc8e5 100644 --- a/src/examples/querystring_example.c +++ b/src/examples/querystring_example.c | |||
@@ -57,7 +57,8 @@ ahc_echo (void *cls, | |||
57 | if (me == NULL) | 57 | if (me == NULL) |
58 | return MHD_NO; | 58 | return MHD_NO; |
59 | sprintf (me, fmt, "q", val); | 59 | sprintf (me, fmt, "q", val); |
60 | response = MHD_create_response_from_data (strlen (me), me, MHD_YES, MHD_NO); | 60 | response = MHD_create_response_from_buffer (strlen (me), me, |
61 | MHD_RESPMEM_MUST_FREE); | ||
61 | if (response == NULL) | 62 | if (response == NULL) |
62 | { | 63 | { |
63 | free (me); | 64 | free (me); |
diff --git a/src/examples/refuse_post_example.c b/src/examples/refuse_post_example.c index 5445160b..0c389bb0 100644 --- a/src/examples/refuse_post_example.c +++ b/src/examples/refuse_post_example.c | |||
@@ -56,9 +56,9 @@ ahc_echo (void *cls, | |||
56 | /* always to busy for POST requests */ | 56 | /* always to busy for POST requests */ |
57 | if (0 == strcmp (method, "POST")) | 57 | if (0 == strcmp (method, "POST")) |
58 | { | 58 | { |
59 | response = MHD_create_response_from_data (strlen (BUSYPAGE), | 59 | response = MHD_create_response_from_buffer (strlen (BUSYPAGE), |
60 | (void *) BUSYPAGE, MHD_NO, | 60 | (void *) BUSYPAGE, |
61 | MHD_NO); | 61 | MHD_RESPMEM_PERSISTENT); |
62 | ret = | 62 | ret = |
63 | MHD_queue_response (connection, MHD_HTTP_SERVICE_UNAVAILABLE, | 63 | MHD_queue_response (connection, MHD_HTTP_SERVICE_UNAVAILABLE, |
64 | response); | 64 | response); |
@@ -68,8 +68,9 @@ ahc_echo (void *cls, | |||
68 | } | 68 | } |
69 | 69 | ||
70 | *ptr = NULL; /* reset when done */ | 70 | *ptr = NULL; /* reset when done */ |
71 | response = MHD_create_response_from_data (strlen (me), | 71 | response = MHD_create_response_from_buffer (strlen (me), |
72 | (void *) me, MHD_NO, MHD_NO); | 72 | (void *) me, |
73 | MHD_RESPMEM_PERSISTENT); | ||
73 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 74 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
74 | MHD_destroy_response (response); | 75 | MHD_destroy_response (response); |
75 | return ret; | 76 | return ret; |
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h index f123969b..c63e43bb 100644 --- a/src/include/microhttpd.h +++ b/src/include/microhttpd.h | |||
@@ -1199,6 +1199,8 @@ struct MHD_Response *MHD_create_response_from_callback (uint64_t size, | |||
1199 | MHD_ContentReaderFreeCallback | 1199 | MHD_ContentReaderFreeCallback |
1200 | crfc); | 1200 | crfc); |
1201 | 1201 | ||
1202 | |||
1203 | |||
1202 | /** | 1204 | /** |
1203 | * Create a response object. The response object can be extended with | 1205 | * Create a response object. The response object can be extended with |
1204 | * header information and then be used any number of times. | 1206 | * header information and then be used any number of times. |
@@ -1210,6 +1212,7 @@ struct MHD_Response *MHD_create_response_from_callback (uint64_t size, | |||
1210 | * right away, the data maybe released anytime after | 1212 | * right away, the data maybe released anytime after |
1211 | * this call returns | 1213 | * this call returns |
1212 | * @return NULL on error (i.e. invalid arguments, out of memory) | 1214 | * @return NULL on error (i.e. invalid arguments, out of memory) |
1215 | * @deprecated use MHD_create_response_from_buffer instead | ||
1213 | */ | 1216 | */ |
1214 | struct MHD_Response *MHD_create_response_from_data (size_t size, | 1217 | struct MHD_Response *MHD_create_response_from_data (size_t size, |
1215 | void *data, | 1218 | void *data, |
@@ -1218,12 +1221,59 @@ struct MHD_Response *MHD_create_response_from_data (size_t size, | |||
1218 | 1221 | ||
1219 | 1222 | ||
1220 | /** | 1223 | /** |
1224 | * Specification for how MHD should treat the memory buffer | ||
1225 | * given for the response. | ||
1226 | */ | ||
1227 | enum MHD_ResponseMemoryMode { | ||
1228 | |||
1229 | /** | ||
1230 | * Buffer is a persistent (static/global) buffer that won't change | ||
1231 | * for at least the lifetime of the response, MHD should just use | ||
1232 | * it, not free it, not copy it, just keep an alias to it. | ||
1233 | */ | ||
1234 | MHD_RESPMEM_PERSISTENT, | ||
1235 | |||
1236 | /** | ||
1237 | * Buffer is heap-allocated with 'malloc' (or equivalent) and | ||
1238 | * should be freed by MHD after processing the response has | ||
1239 | * concluded (response reference counter reaches zero). | ||
1240 | */ | ||
1241 | MHD_RESPMEM_MUST_FREE, | ||
1242 | |||
1243 | /** | ||
1244 | * Buffer is in transient memory, but not on the heap (for example, | ||
1245 | * on the stack or non-malloc allocated) and only valid during the | ||
1246 | * call to 'MHD_create_response_from_buffer'. MHD must make its | ||
1247 | * own private copy of the data for processing. | ||
1248 | */ | ||
1249 | MHD_RESPMEM_MUST_COPY | ||
1250 | |||
1251 | }; | ||
1252 | |||
1253 | |||
1254 | /** | ||
1255 | * Create a response object. The response object can be extended with | ||
1256 | * header information and then be used any number of times. | ||
1257 | * | ||
1258 | * @param size size of the data portion of the response | ||
1259 | * @param buffer size bytes containing the response's data portion | ||
1260 | * @param mode flags for buffer management | ||
1261 | * @return NULL on error (i.e. invalid arguments, out of memory) | ||
1262 | */ | ||
1263 | struct MHD_Response * | ||
1264 | MHD_create_response_from_buffer (size_t size, | ||
1265 | void *buffer, | ||
1266 | enum MHD_ResponseMemoryMode mode); | ||
1267 | |||
1268 | |||
1269 | /** | ||
1221 | * Create a response object. The response object can be extended with | 1270 | * Create a response object. The response object can be extended with |
1222 | * header information and then be used any number of times. | 1271 | * header information and then be used any number of times. |
1223 | * | 1272 | * |
1224 | * @param size size of the data portion of the response | 1273 | * @param size size of the data portion of the response |
1225 | * @param fd file descriptor referring to a file on disk with the data; will be closed when response is destroyed | 1274 | * @param fd file descriptor referring to a file on disk with the data; will be closed when response is destroyed |
1226 | * @return NULL on error (i.e. invalid arguments, out of memory) | 1275 | * @return NULL on error (i.e. invalid arguments, out of memory) |
1276 | * @deprecated use MHD_create_response_from_fd_at_offset instead | ||
1227 | */ | 1277 | */ |
1228 | struct MHD_Response *MHD_create_response_from_fd (size_t size, | 1278 | struct MHD_Response *MHD_create_response_from_fd (size_t size, |
1229 | int fd); | 1279 | int fd); |
diff --git a/src/testcurl/daemontest_digestauth.c b/src/testcurl/daemontest_digestauth.c index 67006272..2fa9f49e 100644 --- a/src/testcurl/daemontest_digestauth.c +++ b/src/testcurl/daemontest_digestauth.c | |||
@@ -81,9 +81,9 @@ ahc_echo (void *cls, | |||
81 | if ( (username == NULL) || | 81 | if ( (username == NULL) || |
82 | (0 != strcmp (username, "testuser")) ) | 82 | (0 != strcmp (username, "testuser")) ) |
83 | { | 83 | { |
84 | response = MHD_create_response_from_data(strlen (DENIED), | 84 | response = MHD_create_response_from_buffer(strlen (DENIED), |
85 | DENIED, | 85 | DENIED, |
86 | MHD_NO, MHD_NO); | 86 | MHD_RESPMEM_PERSISTENT); |
87 | ret = MHD_queue_auth_fail_response(connection, realm, | 87 | ret = MHD_queue_auth_fail_response(connection, realm, |
88 | OPAQUE, | 88 | OPAQUE, |
89 | response, | 89 | response, |
@@ -99,9 +99,9 @@ ahc_echo (void *cls, | |||
99 | if ( (ret == MHD_INVALID_NONCE) || | 99 | if ( (ret == MHD_INVALID_NONCE) || |
100 | (ret == MHD_NO) ) | 100 | (ret == MHD_NO) ) |
101 | { | 101 | { |
102 | response = MHD_create_response_from_data(strlen (DENIED), | 102 | response = MHD_create_response_from_buffer(strlen (DENIED), |
103 | DENIED, | 103 | DENIED, |
104 | MHD_NO, MHD_NO); | 104 | MHD_RESPMEM_PERSISTENT); |
105 | if (NULL == response) | 105 | if (NULL == response) |
106 | return MHD_NO; | 106 | return MHD_NO; |
107 | ret = MHD_queue_auth_fail_response(connection, realm, | 107 | ret = MHD_queue_auth_fail_response(connection, realm, |
@@ -111,8 +111,8 @@ ahc_echo (void *cls, | |||
111 | MHD_destroy_response(response); | 111 | MHD_destroy_response(response); |
112 | return ret; | 112 | return ret; |
113 | } | 113 | } |
114 | response = MHD_create_response_from_data(strlen(PAGE), PAGE, | 114 | response = MHD_create_response_from_buffer(strlen(PAGE), PAGE, |
115 | MHD_NO, MHD_NO); | 115 | MHD_RESPMEM_PERSISTENT); |
116 | ret = MHD_queue_response(connection, MHD_HTTP_OK, response); | 116 | ret = MHD_queue_response(connection, MHD_HTTP_OK, response); |
117 | MHD_destroy_response(response); | 117 | MHD_destroy_response(response); |
118 | return ret; | 118 | return ret; |
diff --git a/src/testcurl/daemontest_get.c b/src/testcurl/daemontest_get.c index 9303e54c..c8e47cd5 100644 --- a/src/testcurl/daemontest_get.c +++ b/src/testcurl/daemontest_get.c | |||
@@ -85,8 +85,9 @@ ahc_echo (void *cls, | |||
85 | return MHD_YES; | 85 | return MHD_YES; |
86 | } | 86 | } |
87 | *unused = NULL; | 87 | *unused = NULL; |
88 | response = MHD_create_response_from_data (strlen (url), | 88 | response = MHD_create_response_from_buffer (strlen (url), |
89 | (void *) url, MHD_NO, MHD_YES); | 89 | (void *) url, |
90 | MHD_RESPMEM_MUST_COPY); | ||
90 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 91 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
91 | MHD_destroy_response (response); | 92 | MHD_destroy_response (response); |
92 | if (ret == MHD_NO) | 93 | if (ret == MHD_NO) |
diff --git a/src/testcurl/daemontest_iplimit.c b/src/testcurl/daemontest_iplimit.c index 93e6b06c..6b714e92 100644 --- a/src/testcurl/daemontest_iplimit.c +++ b/src/testcurl/daemontest_iplimit.c | |||
@@ -80,8 +80,9 @@ ahc_echo (void *cls, | |||
80 | return MHD_YES; | 80 | return MHD_YES; |
81 | } | 81 | } |
82 | *unused = NULL; | 82 | *unused = NULL; |
83 | response = MHD_create_response_from_data (strlen (url), | 83 | response = MHD_create_response_from_buffer (strlen (url), |
84 | (void *) url, MHD_NO, MHD_YES); | 84 | (void *) url, |
85 | MHD_RESPMEM_MUST_COPY); | ||
85 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 86 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
86 | MHD_destroy_response (response); | 87 | MHD_destroy_response (response); |
87 | if (ret == MHD_NO) | 88 | if (ret == MHD_NO) |
diff --git a/src/testcurl/daemontest_large_put.c b/src/testcurl/daemontest_large_put.c index 6492a48c..3767f703 100644 --- a/src/testcurl/daemontest_large_put.c +++ b/src/testcurl/daemontest_large_put.c | |||
@@ -122,8 +122,9 @@ ahc_echo (void *cls, | |||
122 | *done = 1; | 122 | *done = 1; |
123 | return MHD_YES; | 123 | return MHD_YES; |
124 | } | 124 | } |
125 | response = MHD_create_response_from_data (strlen (url), | 125 | response = MHD_create_response_from_buffer (strlen (url), |
126 | (void *) url, MHD_NO, MHD_YES); | 126 | (void *) url, |
127 | MHD_RESPMEM_MUST_COPY); | ||
127 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 128 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
128 | MHD_destroy_response (response); | 129 | MHD_destroy_response (response); |
129 | return ret; | 130 | return ret; |
diff --git a/src/testcurl/daemontest_long_header.c b/src/testcurl/daemontest_long_header.c index 28b34117..33f2f292 100644 --- a/src/testcurl/daemontest_long_header.c +++ b/src/testcurl/daemontest_long_header.c | |||
@@ -79,8 +79,9 @@ ahc_echo (void *cls, | |||
79 | 79 | ||
80 | if (0 != strcmp (me, method)) | 80 | if (0 != strcmp (me, method)) |
81 | return MHD_NO; /* unexpected method */ | 81 | return MHD_NO; /* unexpected method */ |
82 | response = MHD_create_response_from_data (strlen (url), | 82 | response = MHD_create_response_from_buffer (strlen (url), |
83 | (void *) url, MHD_NO, MHD_YES); | 83 | (void *) url, |
84 | MHD_RESPMEM_MUST_COPY); | ||
84 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 85 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
85 | MHD_destroy_response (response); | 86 | MHD_destroy_response (response); |
86 | return ret; | 87 | return ret; |
diff --git a/src/testcurl/daemontest_parse_cookies.c b/src/testcurl/daemontest_parse_cookies.c index bfa8f860..16e0aecd 100644 --- a/src/testcurl/daemontest_parse_cookies.c +++ b/src/testcurl/daemontest_parse_cookies.c | |||
@@ -95,8 +95,9 @@ ahc_echo (void *cls, | |||
95 | hdr = MHD_lookup_connection_value (connection, MHD_COOKIE_KIND, "name4"); | 95 | hdr = MHD_lookup_connection_value (connection, MHD_COOKIE_KIND, "name4"); |
96 | if ((hdr == NULL) || (0 != strcmp (hdr, "var4 with spaces"))) | 96 | if ((hdr == NULL) || (0 != strcmp (hdr, "var4 with spaces"))) |
97 | abort (); | 97 | abort (); |
98 | response = MHD_create_response_from_data (strlen (url), | 98 | response = MHD_create_response_from_buffer (strlen (url), |
99 | (void *) url, MHD_NO, MHD_YES); | 99 | (void *) url, |
100 | MHD_RESPMEM_PERSISTENT); | ||
100 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 101 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
101 | MHD_destroy_response (response); | 102 | MHD_destroy_response (response); |
102 | if (ret == MHD_NO) | 103 | if (ret == MHD_NO) |
diff --git a/src/testcurl/daemontest_post.c b/src/testcurl/daemontest_post.c index c6233925..ba682cf5 100644 --- a/src/testcurl/daemontest_post.c +++ b/src/testcurl/daemontest_post.c | |||
@@ -113,9 +113,9 @@ ahc_echo (void *cls, | |||
113 | MHD_post_process (pp, upload_data, *upload_data_size); | 113 | MHD_post_process (pp, upload_data, *upload_data_size); |
114 | if ((eok == 3) && (0 == *upload_data_size)) | 114 | if ((eok == 3) && (0 == *upload_data_size)) |
115 | { | 115 | { |
116 | response = MHD_create_response_from_data (strlen (url), | 116 | response = MHD_create_response_from_buffer (strlen (url), |
117 | (void *) url, | 117 | (void *) url, |
118 | MHD_NO, MHD_YES); | 118 | MHD_RESPMEM_MUST_COPY); |
119 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 119 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
120 | MHD_destroy_response (response); | 120 | MHD_destroy_response (response); |
121 | MHD_destroy_post_processor (pp); | 121 | MHD_destroy_post_processor (pp); |
@@ -432,7 +432,8 @@ ahc_cancel (void *cls, | |||
432 | { | 432 | { |
433 | *unused = "wibble"; | 433 | *unused = "wibble"; |
434 | /* We don't want the body. Send a 500. */ | 434 | /* We don't want the body. Send a 500. */ |
435 | response = MHD_create_response_from_data(0, NULL, 0, 0); | 435 | response = MHD_create_response_from_buffer (0, NULL, |
436 | MHD_RESPMEM_PERSISTENT); | ||
436 | ret = MHD_queue_response(connection, 500, response); | 437 | ret = MHD_queue_response(connection, 500, response); |
437 | if (ret != MHD_YES) | 438 | if (ret != MHD_YES) |
438 | fprintf(stderr, "Failed to queue response\n"); | 439 | fprintf(stderr, "Failed to queue response\n"); |
diff --git a/src/testcurl/daemontest_post_loop.c b/src/testcurl/daemontest_post_loop.c index b1e1ab3f..f241744a 100644 --- a/src/testcurl/daemontest_post_loop.c +++ b/src/testcurl/daemontest_post_loop.c | |||
@@ -83,7 +83,8 @@ ahc_echo (void *cls, | |||
83 | { | 83 | { |
84 | if (*mptr != &marker) | 84 | if (*mptr != &marker) |
85 | abort (); | 85 | abort (); |
86 | response = MHD_create_response_from_data (2, "OK", MHD_NO, MHD_NO); | 86 | response = MHD_create_response_from_buffer (2, "OK", |
87 | MHD_RESPMEM_PERSISTENT); | ||
87 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 88 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
88 | MHD_destroy_response (response); | 89 | MHD_destroy_response (response); |
89 | *mptr = NULL; | 90 | *mptr = NULL; |
diff --git a/src/testcurl/daemontest_postform.c b/src/testcurl/daemontest_postform.c index a1e29f69..545250ec 100644 --- a/src/testcurl/daemontest_postform.c +++ b/src/testcurl/daemontest_postform.c | |||
@@ -116,9 +116,9 @@ ahc_echo (void *cls, | |||
116 | MHD_post_process (pp, upload_data, *upload_data_size); | 116 | MHD_post_process (pp, upload_data, *upload_data_size); |
117 | if ((eok == 3) && (0 == *upload_data_size)) | 117 | if ((eok == 3) && (0 == *upload_data_size)) |
118 | { | 118 | { |
119 | response = MHD_create_response_from_data (strlen (url), | 119 | response = MHD_create_response_from_buffer (strlen (url), |
120 | (void *) url, | 120 | (void *) url, |
121 | MHD_NO, MHD_YES); | 121 | MHD_RESPMEM_MUST_COPY); |
122 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 122 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
123 | MHD_destroy_response (response); | 123 | MHD_destroy_response (response); |
124 | MHD_destroy_post_processor (pp); | 124 | MHD_destroy_post_processor (pp); |
diff --git a/src/testcurl/daemontest_process_arguments.c b/src/testcurl/daemontest_process_arguments.c index 23fe78e3..0e7edbf7 100644 --- a/src/testcurl/daemontest_process_arguments.c +++ b/src/testcurl/daemontest_process_arguments.c | |||
@@ -88,8 +88,9 @@ ahc_echo (void *cls, | |||
88 | MHD_GET_ARGUMENT_KIND, "hash"); | 88 | MHD_GET_ARGUMENT_KIND, "hash"); |
89 | if ((hdr == NULL) || (0 != strcmp (hdr, "#"))) | 89 | if ((hdr == NULL) || (0 != strcmp (hdr, "#"))) |
90 | abort (); | 90 | abort (); |
91 | response = MHD_create_response_from_data (strlen (url), | 91 | response = MHD_create_response_from_buffer (strlen (url), |
92 | (void *) url, MHD_NO, MHD_YES); | 92 | (void *) url, |
93 | MHD_RESPMEM_MUST_COPY); | ||
93 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 94 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
94 | MHD_destroy_response (response); | 95 | MHD_destroy_response (response); |
95 | if (ret == MHD_NO) | 96 | if (ret == MHD_NO) |
diff --git a/src/testcurl/daemontest_process_headers.c b/src/testcurl/daemontest_process_headers.c index cd4bd68c..fc0c5aef 100644 --- a/src/testcurl/daemontest_process_headers.c +++ b/src/testcurl/daemontest_process_headers.c | |||
@@ -115,8 +115,9 @@ ahc_echo (void *cls, | |||
115 | if ((hdr == NULL) || (0 != strcmp (hdr, "NowPresent"))) | 115 | if ((hdr == NULL) || (0 != strcmp (hdr, "NowPresent"))) |
116 | abort (); | 116 | abort (); |
117 | 117 | ||
118 | response = MHD_create_response_from_data (strlen (url), | 118 | response = MHD_create_response_from_buffer (strlen (url), |
119 | (void *) url, MHD_NO, MHD_YES); | 119 | (void *) url, |
120 | MHD_RESPMEM_MUST_COPY); | ||
120 | MHD_add_response_header (response, "MyHeader", "MyValue"); | 121 | MHD_add_response_header (response, "MyHeader", "MyValue"); |
121 | hdr = MHD_get_response_header (response, "MyHeader"); | 122 | hdr = MHD_get_response_header (response, "MyHeader"); |
122 | if (0 != strcmp ("MyValue", hdr)) | 123 | if (0 != strcmp ("MyValue", hdr)) |
diff --git a/src/testcurl/daemontest_put.c b/src/testcurl/daemontest_put.c index 76e96320..1899e434 100644 --- a/src/testcurl/daemontest_put.c +++ b/src/testcurl/daemontest_put.c | |||
@@ -102,8 +102,8 @@ ahc_echo (void *cls, | |||
102 | *done = 1; | 102 | *done = 1; |
103 | return MHD_YES; | 103 | return MHD_YES; |
104 | } | 104 | } |
105 | response = MHD_create_response_from_data (strlen (url), | 105 | response = MHD_create_response_from_buffer (strlen (url), (void*) url, |
106 | (void *) url, MHD_NO, MHD_YES); | 106 | MHD_RESPMEM_MUST_COPY); |
107 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 107 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
108 | MHD_destroy_response (response); | 108 | MHD_destroy_response (response); |
109 | return ret; | 109 | return ret; |
diff --git a/src/testcurl/daemontest_put_chunked.c b/src/testcurl/daemontest_put_chunked.c index 3fa1f092..46c17330 100644 --- a/src/testcurl/daemontest_put_chunked.c +++ b/src/testcurl/daemontest_put_chunked.c | |||
@@ -111,8 +111,9 @@ ahc_echo (void *cls, | |||
111 | #endif | 111 | #endif |
112 | return MHD_YES; | 112 | return MHD_YES; |
113 | } | 113 | } |
114 | response = MHD_create_response_from_data (strlen (url), | 114 | response = MHD_create_response_from_buffer (strlen (url), |
115 | (void *) url, MHD_NO, MHD_YES); | 115 | (void *) url, |
116 | MHD_RESPMEM_MUST_COPY); | ||
116 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 117 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
117 | MHD_destroy_response (response); | 118 | MHD_destroy_response (response); |
118 | return ret; | 119 | return ret; |
diff --git a/src/testcurl/daemontest_termination.c b/src/testcurl/daemontest_termination.c index 3f25916c..2d6ab93b 100644 --- a/src/testcurl/daemontest_termination.c +++ b/src/testcurl/daemontest_termination.c | |||
@@ -65,7 +65,8 @@ connection_handler (void *cls, | |||
65 | } | 65 | } |
66 | 66 | ||
67 | struct MHD_Response *response = | 67 | struct MHD_Response *response = |
68 | MHD_create_response_from_data (strlen ("Response"), "Response", 0, 0); | 68 | MHD_create_response_from_buffer (strlen ("Response"), "Response", |
69 | MHD_RESPMEM_PERSISTENT); | ||
69 | int ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 70 | int ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
70 | MHD_destroy_response (response); | 71 | MHD_destroy_response (response); |
71 | 72 | ||
diff --git a/src/testcurl/daemontest_timeout.c b/src/testcurl/daemontest_timeout.c index 6032d78d..f3d82243 100644 --- a/src/testcurl/daemontest_timeout.c +++ b/src/testcurl/daemontest_timeout.c | |||
@@ -113,8 +113,9 @@ ahc_echo (void *cls, | |||
113 | *done = 1; | 113 | *done = 1; |
114 | return MHD_YES; | 114 | return MHD_YES; |
115 | } | 115 | } |
116 | response = MHD_create_response_from_data (strlen (url), | 116 | response = MHD_create_response_from_buffer (strlen (url), |
117 | (void *) url, MHD_NO, MHD_YES); | 117 | (void *) url, |
118 | MHD_RESPMEM_MUST_COPY); | ||
118 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 119 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
119 | MHD_destroy_response (response); | 120 | MHD_destroy_response (response); |
120 | return ret; | 121 | return ret; |
diff --git a/src/testcurl/https/mhds_get_test_select.c b/src/testcurl/https/mhds_get_test_select.c index b31db5cc..1ddab1d3 100644 --- a/src/testcurl/https/mhds_get_test_select.c +++ b/src/testcurl/https/mhds_get_test_select.c | |||
@@ -61,8 +61,9 @@ ahc_echo (void *cls, | |||
61 | return MHD_YES; | 61 | return MHD_YES; |
62 | } | 62 | } |
63 | *unused = NULL; | 63 | *unused = NULL; |
64 | response = MHD_create_response_from_data (strlen (url), | 64 | response = MHD_create_response_from_buffer (strlen (url), |
65 | (void *) url, MHD_NO, MHD_YES); | 65 | (void *) url, |
66 | MHD_RESPMEM_MUST_COPY); | ||
66 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 67 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
67 | MHD_destroy_response (response); | 68 | MHD_destroy_response (response); |
68 | if (ret == MHD_NO) | 69 | if (ret == MHD_NO) |
diff --git a/src/testcurl/https/mhds_session_info_test.c b/src/testcurl/https/mhds_session_info_test.c index a5ff42f8..4f8c67d2 100644 --- a/src/testcurl/https/mhds_session_info_test.c +++ b/src/testcurl/https/mhds_session_info_test.c | |||
@@ -78,9 +78,9 @@ query_session_ahc (void *cls, struct MHD_Connection *connection, | |||
78 | return -1; | 78 | return -1; |
79 | } | 79 | } |
80 | 80 | ||
81 | response = MHD_create_response_from_data (strlen (EMPTY_PAGE), | 81 | response = MHD_create_response_from_buffer (strlen (EMPTY_PAGE), |
82 | (void *) EMPTY_PAGE, | 82 | (void *) EMPTY_PAGE, |
83 | MHD_NO, MHD_NO); | 83 | MHD_RESPMEM_PERSISTENT); |
84 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 84 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
85 | MHD_destroy_response (response); | 85 | MHD_destroy_response (response); |
86 | return ret; | 86 | return ret; |
diff --git a/src/testcurl/https/tls_test_common.c b/src/testcurl/https/tls_test_common.c index 1b63862c..e990312f 100644 --- a/src/testcurl/https/tls_test_common.c +++ b/src/testcurl/https/tls_test_common.c | |||
@@ -178,9 +178,9 @@ http_ahc (void *cls, struct MHD_Connection *connection, | |||
178 | return MHD_YES; | 178 | return MHD_YES; |
179 | } | 179 | } |
180 | *ptr = NULL; /* reset when done */ | 180 | *ptr = NULL; /* reset when done */ |
181 | response = MHD_create_response_from_data (strlen (test_data), | 181 | response = MHD_create_response_from_buffer (strlen (test_data), |
182 | (void *) test_data, | 182 | (void *) test_data, |
183 | MHD_NO, MHD_NO); | 183 | MHD_RESPMEM_PERSISTENT); |
184 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 184 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
185 | MHD_destroy_response (response); | 185 | MHD_destroy_response (response); |
186 | return ret; | 186 | return ret; |
diff --git a/src/testzzuf/daemontest_get.c b/src/testzzuf/daemontest_get.c index ed0e7719..4aed7fb5 100644 --- a/src/testzzuf/daemontest_get.c +++ b/src/testzzuf/daemontest_get.c | |||
@@ -81,8 +81,9 @@ ahc_echo (void *cls, | |||
81 | return MHD_YES; | 81 | return MHD_YES; |
82 | } | 82 | } |
83 | *unused = NULL; | 83 | *unused = NULL; |
84 | response = MHD_create_response_from_data (strlen (url), | 84 | response = MHD_create_response_from_buffer (strlen (url), |
85 | (void *) url, MHD_NO, MHD_YES); | 85 | (void *) url, |
86 | MHD_RESPMEM_MUST_COPY); | ||
86 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 87 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
87 | MHD_destroy_response (response); | 88 | MHD_destroy_response (response); |
88 | if (ret == MHD_NO) | 89 | if (ret == MHD_NO) |
diff --git a/src/testzzuf/daemontest_large_put.c b/src/testzzuf/daemontest_large_put.c index ff616555..10fc8b06 100644 --- a/src/testzzuf/daemontest_large_put.c +++ b/src/testzzuf/daemontest_large_put.c | |||
@@ -119,8 +119,9 @@ ahc_echo (void *cls, | |||
119 | *done = 1; | 119 | *done = 1; |
120 | return MHD_YES; | 120 | return MHD_YES; |
121 | } | 121 | } |
122 | response = MHD_create_response_from_data (strlen (url), | 122 | response = MHD_create_response_from_buffer (strlen (url), |
123 | (void *) url, MHD_NO, MHD_YES); | 123 | (void *) url, |
124 | MHD_RESPMEM_MUST_COPY); | ||
124 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 125 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
125 | MHD_destroy_response (response); | 126 | MHD_destroy_response (response); |
126 | return ret; | 127 | return ret; |
diff --git a/src/testzzuf/daemontest_long_header.c b/src/testzzuf/daemontest_long_header.c index 99b9e5e3..d285768f 100644 --- a/src/testzzuf/daemontest_long_header.c +++ b/src/testzzuf/daemontest_long_header.c | |||
@@ -81,8 +81,9 @@ ahc_echo (void *cls, | |||
81 | 81 | ||
82 | if (0 != strcmp (me, method)) | 82 | if (0 != strcmp (me, method)) |
83 | return MHD_NO; /* unexpected method */ | 83 | return MHD_NO; /* unexpected method */ |
84 | response = MHD_create_response_from_data (strlen (url), | 84 | response = MHD_create_response_from_buffer (strlen (url), |
85 | (void *) url, MHD_NO, MHD_YES); | 85 | (void *) url, |
86 | MHD_RESPMEM_MUST_COPY); | ||
86 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 87 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
87 | MHD_destroy_response (response); | 88 | MHD_destroy_response (response); |
88 | return ret; | 89 | return ret; |
diff --git a/src/testzzuf/daemontest_post.c b/src/testzzuf/daemontest_post.c index 6323a5eb..66077b4f 100644 --- a/src/testzzuf/daemontest_post.c +++ b/src/testzzuf/daemontest_post.c | |||
@@ -115,9 +115,9 @@ ahc_echo (void *cls, | |||
115 | MHD_post_process (pp, upload_data, *upload_data_size); | 115 | MHD_post_process (pp, upload_data, *upload_data_size); |
116 | if ((eok == 3) && (0 == *upload_data_size)) | 116 | if ((eok == 3) && (0 == *upload_data_size)) |
117 | { | 117 | { |
118 | response = MHD_create_response_from_data (strlen (url), | 118 | response = MHD_create_response_from_buffer (strlen (url), |
119 | (void *) url, | 119 | (void *) url, |
120 | MHD_NO, MHD_YES); | 120 | MHD_RESPMEM_MUST_COPY); |
121 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 121 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
122 | MHD_destroy_response (response); | 122 | MHD_destroy_response (response); |
123 | MHD_destroy_post_processor (pp); | 123 | MHD_destroy_post_processor (pp); |
diff --git a/src/testzzuf/daemontest_postform.c b/src/testzzuf/daemontest_postform.c index 817b0bc7..873c7fef 100644 --- a/src/testzzuf/daemontest_postform.c +++ b/src/testzzuf/daemontest_postform.c | |||
@@ -120,9 +120,9 @@ ahc_echo (void *cls, | |||
120 | MHD_post_process (pp, upload_data, *upload_data_size); | 120 | MHD_post_process (pp, upload_data, *upload_data_size); |
121 | if ((eok == 3) && (0 == *upload_data_size)) | 121 | if ((eok == 3) && (0 == *upload_data_size)) |
122 | { | 122 | { |
123 | response = MHD_create_response_from_data (strlen (url), | 123 | response = MHD_create_response_from_buffer (strlen (url), |
124 | (void *) url, | 124 | (void *) url, |
125 | MHD_NO, MHD_YES); | 125 | MHD_RESPMEM_MUST_COPY); |
126 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 126 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
127 | MHD_destroy_response (response); | 127 | MHD_destroy_response (response); |
128 | MHD_destroy_post_processor (pp); | 128 | MHD_destroy_post_processor (pp); |
diff --git a/src/testzzuf/daemontest_put.c b/src/testzzuf/daemontest_put.c index c759e055..c658c39c 100644 --- a/src/testzzuf/daemontest_put.c +++ b/src/testzzuf/daemontest_put.c | |||
@@ -105,8 +105,9 @@ ahc_echo (void *cls, | |||
105 | *done = 1; | 105 | *done = 1; |
106 | return MHD_YES; | 106 | return MHD_YES; |
107 | } | 107 | } |
108 | response = MHD_create_response_from_data (strlen (url), | 108 | response = MHD_create_response_from_buffer (strlen (url), |
109 | (void *) url, MHD_NO, MHD_YES); | 109 | (void *) url, |
110 | MHD_RESPMEM_MUST_COPY); | ||
110 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 111 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
111 | MHD_destroy_response (response); | 112 | MHD_destroy_response (response); |
112 | return ret; | 113 | return ret; |
diff --git a/src/testzzuf/daemontest_put_chunked.c b/src/testzzuf/daemontest_put_chunked.c index d49478ee..47d0f0ba 100644 --- a/src/testzzuf/daemontest_put_chunked.c +++ b/src/testzzuf/daemontest_put_chunked.c | |||
@@ -111,8 +111,9 @@ ahc_echo (void *cls, | |||
111 | #endif | 111 | #endif |
112 | return MHD_YES; | 112 | return MHD_YES; |
113 | } | 113 | } |
114 | response = MHD_create_response_from_data (strlen (url), | 114 | response = MHD_create_response_from_buffer (strlen (url), |
115 | (void *) url, MHD_NO, MHD_YES); | 115 | (void *) url, |
116 | MHD_RESPMEM_MUST_COPY); | ||
116 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 117 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
117 | MHD_destroy_response (response); | 118 | MHD_destroy_response (response); |
118 | return ret; | 119 | return ret; |