[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] branch master updated: use correct HTTP header (content
From: |
gnunet |
Subject: |
[libmicrohttpd] branch master updated: use correct HTTP header (content type, not content encoding) for mime type in example; do check return value in example |
Date: |
Sun, 21 Jan 2024 11:33:48 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository libmicrohttpd.
The following commit(s) were added to refs/heads/master by this push:
new 52a5e465 use correct HTTP header (content type, not content encoding)
for mime type in example; do check return value in example
52a5e465 is described below
commit 52a5e465844add3dd968f2318eab5e6f91a5a1e7
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Jan 21 10:33:44 2024 +0100
use correct HTTP header (content type, not content encoding) for mime type
in example; do check return value in example
---
doc/examples/responseheaders.c | 18 ++++++++++---
doc/examples/sessions.c | 60 ++++++++++++++++++++++++++++++------------
src/microhttpd/daemon.c | 24 ++++++++---------
3 files changed, 70 insertions(+), 32 deletions(-)
diff --git a/doc/examples/responseheaders.c b/doc/examples/responseheaders.c
index 30ac4596..cddcaa66 100644
--- a/doc/examples/responseheaders.c
+++ b/doc/examples/responseheaders.c
@@ -63,9 +63,21 @@ answer_to_connection (void *cls, struct MHD_Connection
*connection,
return MHD_NO;
}
response =
- MHD_create_response_from_fd_at_offset64 ((size_t) sbuf.st_size, fd, 0);
- MHD_add_response_header (response, "Content-Type", MIMETYPE);
- ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
+ MHD_create_response_from_fd_at_offset64 ((size_t) sbuf.st_size,
+ fd,
+ 0);
+ if (MHD_YES !=
+ MHD_add_response_header (response,
+ MHD_HTTP_HEADER_CONTENT_TYPE,
+ MIMETYPE))
+ {
+ fprintf (stderr,
+ "Failed to set content encoding type!\n");
+ /* return response without content encoding anyway ... */
+ }
+ ret = MHD_queue_response (connection,
+ MHD_HTTP_OK,
+ response);
MHD_destroy_response (response);
return ret;
diff --git a/doc/examples/sessions.c b/doc/examples/sessions.c
index 958a775f..0544a2d7 100644
--- a/doc/examples/sessions.c
+++ b/doc/examples/sessions.c
@@ -270,9 +270,15 @@ serve_simple_form (const void *cls,
/* return static form */
response = MHD_create_response_from_buffer_static (strlen (form), form);
add_session_cookie (session, response);
- MHD_add_response_header (response,
- MHD_HTTP_HEADER_CONTENT_ENCODING,
- mime);
+ if (MHD_YES !=
+ MHD_add_response_header (response,
+ MHD_HTTP_HEADER_CONTENT_TYPE,
+ mime))
+ {
+ fprintf (stderr,
+ "Failed to set content type header!\n");
+ /* return response without content type anyway ... */
+ }
ret = MHD_queue_response (connection,
MHD_HTTP_OK,
response);
@@ -327,9 +333,15 @@ fill_v1_form (const void *cls,
if (NULL != response)
{
add_session_cookie (session, response);
- MHD_add_response_header (response,
- MHD_HTTP_HEADER_CONTENT_ENCODING,
- mime);
+ if (MHD_YES !=
+ MHD_add_response_header (response,
+ MHD_HTTP_HEADER_CONTENT_TYPE,
+ mime))
+ {
+ fprintf (stderr,
+ "Failed to set content type header!\n");
+ /* return response without content type anyway ... */
+ }
ret = MHD_queue_response (connection,
MHD_HTTP_OK,
response);
@@ -392,9 +404,15 @@ fill_v1_v2_form (const void *cls,
if (NULL != response)
{
add_session_cookie (session, response);
- MHD_add_response_header (response,
- MHD_HTTP_HEADER_CONTENT_ENCODING,
- mime);
+ if (MHD_YES !=
+ MHD_add_response_header (response,
+ MHD_HTTP_HEADER_CONTENT_TYPE,
+ mime))
+ {
+ fprintf (stderr,
+ "Failed to set content type header!\n");
+ /* return response without content type anyway ... */
+ }
ret = MHD_queue_response (connection,
MHD_HTTP_OK,
response);
@@ -434,9 +452,15 @@ not_found_page (const void *cls,
ret = MHD_queue_response (connection,
MHD_HTTP_NOT_FOUND,
response);
- MHD_add_response_header (response,
- MHD_HTTP_HEADER_CONTENT_ENCODING,
- mime);
+ if (MHD_YES !=
+ MHD_add_response_header (response,
+ MHD_HTTP_HEADER_CONTENT_TYPE,
+ mime))
+ {
+ fprintf (stderr,
+ "Failed to set content type header!\n");
+ /* return response without content type anyway ... */
+ }
MHD_destroy_response (response);
return ret;
}
@@ -470,8 +494,8 @@ static const struct Page pages[] = {
* specified offset
* @param off offset of data in the overall value
* @param size number of bytes in data available
- * @return MHD_YES to continue iterating,
- * MHD_NO to abort the iteration
+ * @return #MHD_YES to continue iterating,
+ * #MHD_NO to abort the iteration
*/
static enum MHD_Result
post_iterator (void *cls,
@@ -615,9 +639,11 @@ create_response (void *cls,
if (0 == strcmp (method, MHD_HTTP_METHOD_POST))
{
/* evaluate POST data */
- MHD_post_process (request->pp,
- upload_data,
- *upload_data_size);
+ if (MHD_YES !=
+ MHD_post_process (request->pp,
+ upload_data,
+ *upload_data_size))
+ return MHD_NO; /* internal error */
if (0 != *upload_data_size)
{
*upload_data_size = 0;
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index f15d0ab0..d6b6401c 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -760,10 +760,10 @@ urh_to_fdset (struct MHD_UpgradeResponseHandle *urh,
(0 != urh->out_buffer_size) ||
(0 != urh->out_buffer_used))
&& (NULL != es))
- MHD_add_to_fd_set_ (conn_sckt,
- es,
- max_fd,
- fd_setsize);
+ (void) MHD_add_to_fd_set_ (conn_sckt,
+ es,
+ max_fd,
+ fd_setsize);
}
if (MHD_INVALID_SOCKET != mhd_sckt)
{
@@ -1056,10 +1056,10 @@ internal_get_fdset2 (struct MHD_Daemon *daemon,
result = MHD_NO;
#ifdef MHD_POSIX_SOCKETS
if (NULL != except_fd_set)
- MHD_add_to_fd_set_ (pos->socket_fd,
- except_fd_set,
- max_fd,
- fd_setsize);
+ (void) MHD_add_to_fd_set_ (pos->socket_fd,
+ except_fd_set,
+ max_fd,
+ fd_setsize);
#endif /* MHD_POSIX_SOCKETS */
break;
case MHD_EVENT_LOOP_INFO_WRITE:
@@ -1070,10 +1070,10 @@ internal_get_fdset2 (struct MHD_Daemon *daemon,
result = MHD_NO;
#ifdef MHD_POSIX_SOCKETS
if (NULL != except_fd_set)
- MHD_add_to_fd_set_ (pos->socket_fd,
- except_fd_set,
- max_fd,
- fd_setsize);
+ (void) MHD_add_to_fd_set_ (pos->socket_fd,
+ except_fd_set,
+ max_fd,
+ fd_setsize);
#endif /* MHD_POSIX_SOCKETS */
break;
case MHD_EVENT_LOOP_INFO_PROCESS:
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libmicrohttpd] branch master updated: use correct HTTP header (content type, not content encoding) for mime type in example; do check return value in example,
gnunet <=