aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-03-04 15:52:06 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-03-07 21:29:40 +0300
commite9292a95ec87a3c4fe1c1662fae4b3cf8d887bbb (patch)
tree47041aeb01fa873b1887d5f47b102ea84c8e95cf
parent02634d01472ce8fe4b50f99c31db0327e27ed7e8 (diff)
downloadlibmicrohttpd-e9292a95ec87a3c4fe1c1662fae4b3cf8d887bbb.tar.gz
libmicrohttpd-e9292a95ec87a3c4fe1c1662fae4b3cf8d887bbb.zip
connection.c: added function to check used reply
Log warning if response has body, but no body is allowed for this connection.
-rw-r--r--src/microhttpd/connection.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index f6a871c0..9e764b02 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1815,6 +1815,32 @@ setup_reply_properties (struct MHD_Connection *connection)
1815 1815
1816 1816
1817/** 1817/**
1818 * Check whether queued response is suitable for @a connection.
1819 * @param connection to connection to check
1820 */
1821static void
1822check_connection_reply (struct MHD_Connection *connection)
1823{
1824 struct MHD_Connection *const c = connection; /**< a short alias */
1825 struct MHD_Response *const r = c->response; /**< a short alias */
1826 mhd_assert (c->rp_props.set);
1827
1828#ifdef HAVE_MESSAGES
1829 if ((! c->rp_props.use_reply_body_headers) && (0 != r->total_size))
1830 {
1831 MHD_DLOG (c->daemon,
1832 _ ("This reply with response code %u cannot use reply body. "
1833 "Non-empty response body is ignored and not used.\n"),
1834 (unsigned) (c->responseCode & (~MHD_ICY_FLAG)));
1835 }
1836#else
1837 (void) c; /* Mute compiler warning */
1838 (void) r; /* Mute compiler warning */
1839#endif
1840}
1841
1842
1843/**
1818 * Append data to the buffer if enough space is available, 1844 * Append data to the buffer if enough space is available,
1819 * update position. 1845 * update position.
1820 * @param[out] buf the buffer to append data to 1846 * @param[out] buf the buffer to append data to
@@ -2012,6 +2038,8 @@ build_header_response (struct MHD_Connection *connection)
2012 ! c->rp_props.use_reply_body_headers); 2038 ! c->rp_props.use_reply_body_headers);
2013#endif /* UPGRADE_SUPPORT */ 2039#endif /* UPGRADE_SUPPORT */
2014 2040
2041 check_connection_reply (c);
2042
2015 rcode = (unsigned) (c->responseCode & (~MHD_ICY_FLAG)); 2043 rcode = (unsigned) (c->responseCode & (~MHD_ICY_FLAG));
2016 if (MHD_CONN_MUST_CLOSE == c->keepalive) 2044 if (MHD_CONN_MUST_CLOSE == c->keepalive)
2017 { 2045 {