[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 03/08: Replaced MHD_RESPMEM_PERSISTENT usage in examples
From: |
gnunet |
Subject: |
[libmicrohttpd] 03/08: Replaced MHD_RESPMEM_PERSISTENT usage in examples and code |
Date: |
Sat, 14 May 2022 15:11:38 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit 85ae657849685d27b79ae6b14f7248d81ec99d2c
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sat May 14 15:07:47 2022 +0300
Replaced MHD_RESPMEM_PERSISTENT usage in examples and code
New functions do not produce compiler warnings.
---
doc/examples/tlsauthentication.c | 3 +--
doc/examples/websocket.c | 25 +++++++++++++------------
src/examples/connection_close.c | 5 ++---
src/examples/minimal_example_empty.c | 4 +---
src/examples/minimal_example_empty_tls.c | 4 +---
src/examples/websocket_chatserver_example.c | 22 ++++++++++------------
src/microhttpd/test_response_entries.c | 2 +-
src/testcurl/https/test_empty_response.c | 3 +--
src/testcurl/https/test_https_get.c | 4 +---
src/testcurl/https/test_https_session_info.c | 5 ++---
src/testcurl/https/tls_test_common.c | 5 ++---
src/testcurl/test_digestauth.c | 15 ++++++---------
src/testcurl/test_digestauth_concurrent.c | 15 ++++++---------
src/testcurl/test_digestauth_sha256.c | 15 ++++++---------
src/testcurl/test_digestauth_with_arguments.c | 14 ++++++--------
src/testcurl/test_get.c | 4 +---
src/testcurl/test_get_chunked.c | 3 +--
src/testcurl/test_get_empty.c | 8 ++------
src/testcurl/test_post.c | 3 +--
src/testcurl/test_post_loop.c | 4 ++--
src/testcurl/test_termination.c | 3 +--
21 files changed, 67 insertions(+), 99 deletions(-)
diff --git a/doc/examples/tlsauthentication.c b/doc/examples/tlsauthentication.c
index 3c39a0f5..57556d0b 100644
--- a/doc/examples/tlsauthentication.c
+++ b/doc/examples/tlsauthentication.c
@@ -130,8 +130,7 @@ ask_for_authentication (struct MHD_Connection *connection,
const char *realm)
size_t slen;
const char *strbase = "Basic realm=";
- response = MHD_create_response_from_buffer (0, NULL,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_empty (MHD_RF_NONE);
if (! response)
return MHD_NO;
diff --git a/doc/examples/websocket.c b/doc/examples/websocket.c
index 77bc55cd..018d4c5a 100644
--- a/doc/examples/websocket.c
+++ b/doc/examples/websocket.c
@@ -330,10 +330,9 @@ access_handler (void *cls,
if (0 == strcmp (url, "/"))
{
/* Default page for visiting the server */
- struct MHD_Response *response = MHD_create_response_from_buffer (
- strlen (PAGE),
- PAGE,
- MHD_RESPMEM_PERSISTENT);
+ struct MHD_Response *response;
+ response = MHD_create_response_from_buffer_static (strlen (PAGE),
+ PAGE);
ret = MHD_queue_response (connection,
MHD_HTTP_OK,
response);
@@ -400,10 +399,11 @@ access_handler (void *cls,
else
{
/* return error page */
- struct MHD_Response *response = MHD_create_response_from_buffer (
- strlen (PAGE_INVALID_WEBSOCKET_REQUEST),
- PAGE_INVALID_WEBSOCKET_REQUEST,
- MHD_RESPMEM_PERSISTENT);
+ struct MHD_Response *response;
+ response =
+ MHD_create_response_from_buffer_static (strlen (
+
PAGE_INVALID_WEBSOCKET_REQUEST),
+
PAGE_INVALID_WEBSOCKET_REQUEST);
ret = MHD_queue_response (connection,
MHD_HTTP_BAD_REQUEST,
response);
@@ -412,10 +412,11 @@ access_handler (void *cls,
}
else
{
- struct MHD_Response *response = MHD_create_response_from_buffer (
- strlen (PAGE_NOT_FOUND),
- PAGE_NOT_FOUND,
- MHD_RESPMEM_PERSISTENT);
+ struct MHD_Response *response;
+ response =
+ MHD_create_response_from_buffer_static (strlen (
+ PAGE_NOT_FOUND),
+ PAGE_NOT_FOUND);
ret = MHD_queue_response (connection,
MHD_HTTP_NOT_FOUND,
response);
diff --git a/src/examples/connection_close.c b/src/examples/connection_close.c
index e5f787a3..8558eb46 100644
--- a/src/examples/connection_close.c
+++ b/src/examples/connection_close.c
@@ -61,9 +61,8 @@ ahc_echo (void *cls,
return MHD_YES;
}
*req_cls = NULL; /* reset when done */
- response = MHD_create_response_from_buffer (strlen (me),
- (void *) me,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_from_buffer_static (strlen (me),
+ me);
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
return ret;
diff --git a/src/examples/minimal_example_empty.c
b/src/examples/minimal_example_empty.c
index 43719a24..84837f08 100644
--- a/src/examples/minimal_example_empty.c
+++ b/src/examples/minimal_example_empty.c
@@ -55,9 +55,7 @@ ahc_echo (void *cls,
return MHD_YES;
}
*req_cls = NULL; /* reset when done */
- response = MHD_create_response_from_buffer (0,
- NULL,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_empty (MHD_RF_NONE);
ret = MHD_queue_response (connection,
MHD_HTTP_NO_CONTENT,
response);
diff --git a/src/examples/minimal_example_empty_tls.c
b/src/examples/minimal_example_empty_tls.c
index 9c352717..c8c3763f 100644
--- a/src/examples/minimal_example_empty_tls.c
+++ b/src/examples/minimal_example_empty_tls.c
@@ -55,9 +55,7 @@ ahc_echo (void *cls,
return MHD_YES;
}
*req_cls = NULL; /* reset when done */
- response = MHD_create_response_from_buffer (0,
- NULL,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_empty (MHD_RF_NONE);
ret = MHD_queue_response (connection,
MHD_HTTP_NO_CONTENT,
response);
diff --git a/src/examples/websocket_chatserver_example.c
b/src/examples/websocket_chatserver_example.c
index 052b4221..cc3005a2 100644
--- a/src/examples/websocket_chatserver_example.c
+++ b/src/examples/websocket_chatserver_example.c
@@ -2163,10 +2163,9 @@ access_handler (void *cls,
if (0 == strcmp (url, "/"))
{
/* Default page for visiting the server */
- struct MHD_Response *response = MHD_create_response_from_buffer (strlen (
- PAGE),
- PAGE,
-
MHD_RESPMEM_PERSISTENT);
+ struct MHD_Response *response;
+ response = MHD_create_response_from_buffer_static (strlen (PAGE),
+ PAGE);
ret = MHD_queue_response (connection,
MHD_HTTP_OK,
response);
@@ -2259,10 +2258,10 @@ access_handler (void *cls,
else
{
/* return error page */
- struct MHD_Response *response = MHD_create_response_from_buffer (strlen (
-
PAGE_INVALID_WEBSOCKET_REQUEST),
-
PAGE_INVALID_WEBSOCKET_REQUEST,
-
MHD_RESPMEM_PERSISTENT);
+ struct MHD_Response *response;
+ response = MHD_create_response_from_buffer_static (strlen (
+
PAGE_INVALID_WEBSOCKET_REQUEST),
+
PAGE_INVALID_WEBSOCKET_REQUEST);
ret = MHD_queue_response (connection,
MHD_HTTP_BAD_REQUEST,
response);
@@ -2271,10 +2270,9 @@ access_handler (void *cls,
}
else
{
- struct MHD_Response *response = MHD_create_response_from_buffer (strlen (
-
PAGE_NOT_FOUND),
-
PAGE_NOT_FOUND,
-
MHD_RESPMEM_PERSISTENT);
+ struct MHD_Response *response;
+ response = MHD_create_response_from_buffer_static (strlen (PAGE_NOT_FOUND),
+ PAGE_NOT_FOUND);
ret = MHD_queue_response (connection,
MHD_HTTP_NOT_FOUND,
response);
diff --git a/src/microhttpd/test_response_entries.c
b/src/microhttpd/test_response_entries.c
index 5386b8da..7e1b18a8 100644
--- a/src/microhttpd/test_response_entries.c
+++ b/src/microhttpd/test_response_entries.c
@@ -54,7 +54,7 @@ main (int argc,
(void) argv; /* Unused. Silence compiler warning. */
struct MHD_Response *r;
- r = MHD_create_response_from_buffer (0, "", MHD_RESPMEM_PERSISTENT);
+ r = MHD_create_response_empty (MHD_RF_NONE);
if (NULL == r)
{
fprintf (stderr, "Cannot create a response.\n");
diff --git a/src/testcurl/https/test_empty_response.c
b/src/testcurl/https/test_empty_response.c
index f4cce216..b338fa2e 100644
--- a/src/testcurl/https/test_empty_response.c
+++ b/src/testcurl/https/test_empty_response.c
@@ -52,8 +52,7 @@ ahc_echo (void *cls,
(void) cls; (void) url; (void) method; (void) version; /*
Unused. Silent compiler warning. */
(void) upload_data; (void) upload_data_size; (void) req_cls; /*
Unused. Silent compiler warning. */
- response = MHD_create_response_from_buffer (0, NULL,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_empty (MHD_RF_NONE);
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
return ret;
diff --git a/src/testcurl/https/test_https_get.c
b/src/testcurl/https/test_https_get.c
index 968a0b96..184cc48e 100644
--- a/src/testcurl/https/test_https_get.c
+++ b/src/testcurl/https/test_https_get.c
@@ -120,9 +120,7 @@ ahc_empty (void *cls,
return MHD_YES;
}
*req_cls = NULL;
- response = MHD_create_response_from_buffer (0,
- NULL,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_empty (MHD_RF_NONE);
ret = MHD_queue_response (connection,
MHD_HTTP_OK,
response);
diff --git a/src/testcurl/https/test_https_session_info.c
b/src/testcurl/https/test_https_session_info.c
index e428e278..b0ccb576 100644
--- a/src/testcurl/https/test_https_session_info.c
+++ b/src/testcurl/https/test_https_session_info.c
@@ -84,9 +84,8 @@ query_session_ahc (void *cls, struct MHD_Connection
*connection,
}
}
- response = MHD_create_response_from_buffer (strlen (EMPTY_PAGE),
- (void *) EMPTY_PAGE,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_from_buffer_static (strlen (EMPTY_PAGE),
+ EMPTY_PAGE);
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
return ret;
diff --git a/src/testcurl/https/tls_test_common.c
b/src/testcurl/https/tls_test_common.c
index 8d33e5d4..f3c561fe 100644
--- a/src/testcurl/https/tls_test_common.c
+++ b/src/testcurl/https/tls_test_common.c
@@ -224,9 +224,8 @@ http_ahc (void *cls,
return MHD_YES;
}
*req_cls = NULL; /* reset when done */
- response = MHD_create_response_from_buffer (strlen (test_data),
- (void *) test_data,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_from_buffer_static (strlen (test_data),
+ test_data);
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
return ret;
diff --git a/src/testcurl/test_digestauth.c b/src/testcurl/test_digestauth.c
index e05e4f31..6f22c1f2 100644
--- a/src/testcurl/test_digestauth.c
+++ b/src/testcurl/test_digestauth.c
@@ -282,9 +282,8 @@ ahc_echo (void *cls,
if ( (username == NULL) ||
(0 != strcmp (username, "testuser")) )
{
- response = MHD_create_response_from_buffer (strlen (DENIED),
- DENIED,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_from_buffer_static (strlen (DENIED),
+ DENIED);
if (NULL == response)
mhdErrorExitDesc ("MHD_create_response_from_buffer failed");
ret = MHD_queue_auth_fail_response2 (connection,
@@ -307,9 +306,8 @@ ahc_echo (void *cls,
MHD_free (username);
if (ret_e != MHD_DAUTH_OK)
{
- response = MHD_create_response_from_buffer (strlen (DENIED),
- DENIED,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_from_buffer_static (strlen (DENIED),
+ DENIED);
if (NULL == response)
mhdErrorExitDesc ("MHD_create_response_from_buffer() failed");
ret = MHD_queue_auth_fail_response2 (connection,
@@ -324,9 +322,8 @@ ahc_echo (void *cls,
MHD_destroy_response (response);
return ret;
}
- response = MHD_create_response_from_buffer (strlen (PAGE),
- PAGE,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_from_buffer_static (strlen (PAGE),
+ PAGE);
if (NULL == response)
mhdErrorExitDesc ("MHD_create_response_from_buffer() failed");
ret = MHD_queue_response (connection,
diff --git a/src/testcurl/test_digestauth_concurrent.c
b/src/testcurl/test_digestauth_concurrent.c
index 5795c686..045b673d 100644
--- a/src/testcurl/test_digestauth_concurrent.c
+++ b/src/testcurl/test_digestauth_concurrent.c
@@ -293,9 +293,8 @@ ahc_echo (void *cls,
if ( (username == NULL) ||
(0 != strcmp (username, "testuser")) )
{
- response = MHD_create_response_from_buffer (strlen (DENIED),
- DENIED,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_from_buffer_static (strlen (DENIED),
+ DENIED);
if (NULL == response)
mhdErrorExitDesc ("MHD_create_response_from_buffer failed");
ret = MHD_queue_auth_fail_response2 (connection,
@@ -318,9 +317,8 @@ ahc_echo (void *cls,
MHD_free (username);
if (ret_e != MHD_DAUTH_OK)
{
- response = MHD_create_response_from_buffer (strlen (DENIED),
- DENIED,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_from_buffer_static (strlen (DENIED),
+ DENIED);
if (NULL == response)
mhdErrorExitDesc ("MHD_create_response_from_buffer() failed");
ret = MHD_queue_auth_fail_response2 (connection,
@@ -335,9 +333,8 @@ ahc_echo (void *cls,
MHD_destroy_response (response);
return ret;
}
- response = MHD_create_response_from_buffer (strlen (PAGE),
- PAGE,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_from_buffer_static (strlen (PAGE),
+ PAGE);
if (NULL == response)
mhdErrorExitDesc ("MHD_create_response_from_buffer() failed");
ret = MHD_queue_response (connection,
diff --git a/src/testcurl/test_digestauth_sha256.c
b/src/testcurl/test_digestauth_sha256.c
index bfab4a7e..90e5ad5f 100644
--- a/src/testcurl/test_digestauth_sha256.c
+++ b/src/testcurl/test_digestauth_sha256.c
@@ -111,9 +111,8 @@ ahc_echo (void *cls,
if ( (username == NULL) ||
(0 != strcmp (username, "testuser")) )
{
- response = MHD_create_response_from_buffer (strlen (DENIED),
- DENIED,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_from_buffer_static (strlen (DENIED),
+ DENIED);
ret = MHD_queue_auth_fail_response2 (connection,
realm,
MY_OPAQUE,
@@ -132,9 +131,8 @@ ahc_echo (void *cls,
MHD_free (username);
if (ret_e != MHD_DAUTH_OK)
{
- response = MHD_create_response_from_buffer (strlen (DENIED),
- DENIED,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_from_buffer_static (strlen (DENIED),
+ DENIED);
if (NULL == response)
return MHD_NO;
ret = MHD_queue_auth_fail_response2 (connection,
@@ -147,9 +145,8 @@ ahc_echo (void *cls,
MHD_destroy_response (response);
return ret;
}
- response = MHD_create_response_from_buffer (strlen (PAGE),
- PAGE,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_from_buffer_static (strlen (PAGE),
+ PAGE);
ret = MHD_queue_response (connection,
MHD_HTTP_OK,
response);
diff --git a/src/testcurl/test_digestauth_with_arguments.c
b/src/testcurl/test_digestauth_with_arguments.c
index 773fd5f5..843e4684 100644
--- a/src/testcurl/test_digestauth_with_arguments.c
+++ b/src/testcurl/test_digestauth_with_arguments.c
@@ -104,9 +104,8 @@ ahc_echo (void *cls,
if ( (username == NULL) ||
(0 != strcmp (username, "testuser")) )
{
- response = MHD_create_response_from_buffer (strlen (DENIED),
- DENIED,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_from_buffer_static (strlen (DENIED),
+ DENIED);
ret = MHD_queue_auth_fail_response2 (connection, realm,
MY_OPAQUE,
response,
@@ -123,9 +122,8 @@ ahc_echo (void *cls,
MHD_free (username);
if (ret_e != MHD_DAUTH_OK)
{
- response = MHD_create_response_from_buffer (strlen (DENIED),
- DENIED,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_from_buffer_static (strlen (DENIED),
+ DENIED);
if (NULL == response)
return MHD_NO;
ret = MHD_queue_auth_fail_response2 (connection, realm,
@@ -137,8 +135,8 @@ ahc_echo (void *cls,
MHD_destroy_response (response);
return ret;
}
- response = MHD_create_response_from_buffer (strlen (PAGE), PAGE,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_from_buffer_static (strlen (PAGE),
+ PAGE);
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
return ret;
diff --git a/src/testcurl/test_get.c b/src/testcurl/test_get.c
index a60c0797..8fe1c771 100644
--- a/src/testcurl/test_get.c
+++ b/src/testcurl/test_get.c
@@ -765,9 +765,7 @@ ahc_empty (void *cls,
return MHD_YES;
}
*req_cls = NULL;
- response = MHD_create_response_from_buffer (0,
- NULL,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_empty (MHD_RF_NONE);
ret = MHD_queue_response (connection,
MHD_HTTP_OK,
response);
diff --git a/src/testcurl/test_get_chunked.c b/src/testcurl/test_get_chunked.c
index 876016cc..4f7b5606 100644
--- a/src/testcurl/test_get_chunked.c
+++ b/src/testcurl/test_get_chunked.c
@@ -232,8 +232,7 @@ ahc_echo (void *cls,
free (buf);
}
else
- response = MHD_create_response_from_buffer (0, NULL,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_empty (MHD_RF_NONE);
}
if (NULL == response)
abort ();
diff --git a/src/testcurl/test_get_empty.c b/src/testcurl/test_get_empty.c
index fdbb2d42..32d6b16f 100644
--- a/src/testcurl/test_get_empty.c
+++ b/src/testcurl/test_get_empty.c
@@ -125,9 +125,7 @@ ahc_echo (void *cls,
return MHD_YES;
}
*req_cls = NULL;
- response = MHD_create_response_from_buffer (0,
- NULL,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_empty (MHD_RF_NONE);
ret = MHD_queue_response (connection,
MHD_HTTP_NO_CONTENT,
response);
@@ -723,9 +721,7 @@ ahc_empty (void *cls,
return MHD_YES;
}
*req_cls = NULL;
- response = MHD_create_response_from_buffer (0,
- NULL,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_empty (MHD_RF_NONE);
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
if (ret == MHD_NO)
diff --git a/src/testcurl/test_post.c b/src/testcurl/test_post.c
index 90b8f48a..e36391fd 100644
--- a/src/testcurl/test_post.c
+++ b/src/testcurl/test_post.c
@@ -610,8 +610,7 @@ ahc_cancel (void *cls,
{
*req_cls = "wibble";
/* We don't want the body. Send a 500. */
- response = MHD_create_response_from_buffer (0, NULL,
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_empty (MHD_RF_NONE);
ret = MHD_queue_response (connection, 500, response);
if (ret != MHD_YES)
fprintf (stderr, "Failed to queue response\n");
diff --git a/src/testcurl/test_post_loop.c b/src/testcurl/test_post_loop.c
index 37cd121b..ec42ffce 100644
--- a/src/testcurl/test_post_loop.c
+++ b/src/testcurl/test_post_loop.c
@@ -103,8 +103,8 @@ ahc_echo (void *cls,
{
if (*req_cls != &marker)
abort ();
- response = MHD_create_response_from_buffer (2, "OK",
- MHD_RESPMEM_PERSISTENT);
+ response = MHD_create_response_from_buffer_static (2,
+ "OK");
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
*req_cls = NULL;
diff --git a/src/testcurl/test_termination.c b/src/testcurl/test_termination.c
index 72b77219..239f10ec 100644
--- a/src/testcurl/test_termination.c
+++ b/src/testcurl/test_termination.c
@@ -78,8 +78,7 @@ connection_handler (void *cls,
}
response =
- MHD_create_response_from_buffer (strlen ("Response"), "Response",
- MHD_RESPMEM_PERSISTENT);
+ MHD_create_response_from_buffer_static (strlen ("Response"), "Response");
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] branch master updated (f50b6be7 -> 83fe7b77), gnunet, 2022/05/14
- [libmicrohttpd] 02/08: MHD_create_response_from_buffer_copy(): fixed doxy, gnunet, 2022/05/14
- [libmicrohttpd] 04/08: Return NULL for MHD_CONNECTION_INFO_CLIENT_ADDRESS if information is not available, gnunet, 2022/05/14
- [libmicrohttpd] 01/08: Replaced MHD_RESPMEM_MUST_FREE with more portable solution in examples, gnunet, 2022/05/14
- [libmicrohttpd] 03/08: Replaced MHD_RESPMEM_PERSISTENT usage in examples and code,
gnunet <=
- [libmicrohttpd] 08/08: Fixed additional compiler warnings on W32, gnunet, 2022/05/14
- [libmicrohttpd] 05/08: Fixed return type for get_system_fdsetsize_value (), gnunet, 2022/05/14
- [libmicrohttpd] 06/08: Fixed handling of connections with non-standard client addresses (pipe or UNIX sockets)., gnunet, 2022/05/14
- [libmicrohttpd] 07/08: Fixed some compiler warnings on W32, gnunet, 2022/05/14