aboutsummaryrefslogtreecommitdiff
path: root/src/lib/action_from_response.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/action_from_response.c')
-rw-r--r--src/lib/action_from_response.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/lib/action_from_response.c b/src/lib/action_from_response.c
index 3c13cf42..883fcb98 100644
--- a/src/lib/action_from_response.c
+++ b/src/lib/action_from_response.c
@@ -31,27 +31,30 @@
31 * 31 *
32 * @param cls the `struct MHD_Response` 32 * @param cls the `struct MHD_Response`
33 * @param request the request we are processing 33 * @param request the request we are processing
34 * @return #MHD_SC_OK on success
34 */ 35 */
35static void 36static enum MHD_StatusCode
36response_action (void *cls, 37response_action (void *cls,
37 struct MHD_Request *request) 38 struct MHD_Request *request)
38{ 39{
39 struct MHD_Response *response = cls; 40 struct MHD_Response *response = cls;
40 struct MHD_Daemon *daemon = response->daemon; 41 struct MHD_Daemon *daemon = request->daemon;
41 42
43 /* If daemon was shut down in parallel,
44 * response will be aborted now or on later stage. */
42 if (daemon->shutdown) 45 if (daemon->shutdown)
43 return MHD_YES; /* If daemon was shut down in parallel, 46 return MHD_SC_DAEMON_ALREADY_SHUTDOWN;
44 * response will be aborted now or on later stage. */
45 47
46#ifdef UPGRADE_SUPPORT 48#ifdef UPGRADE_SUPPORT
47 if ( (NULL != response->upgrade_handler) && 49 if ( (NULL != response->upgrade_handler) &&
48 (0 == (daemon->options & MHD_ALLOW_UPGRADE)) ) 50 daemon->disallow_upgrade )
49 { 51 {
50#ifdef HAVE_MESSAGES 52#ifdef HAVE_MESSAGES
51 MHD_DLOG (daemon, 53 MHD_DLOG (daemon,
54 MHD_SC_UPGRADE_ON_DAEMON_WITH_UPGRADE_DISALLOWED,
52 _("Attempted 'upgrade' connection on daemon without MHD_ALLOW_UPGRADE option!\n")); 55 _("Attempted 'upgrade' connection on daemon without MHD_ALLOW_UPGRADE option!\n"));
53#endif 56#endif
54 return MHD_NO; 57 return MHD_SC_UPGRADE_ON_DAEMON_WITH_UPGRADE_DISALLOWED;
55 } 58 }
56#endif /* UPGRADE_SUPPORT */ 59#endif /* UPGRADE_SUPPORT */
57 request->response = response; 60 request->response = response;
@@ -66,9 +69,7 @@ response_action (void *cls,
66 request->resp_sender = MHD_resp_sender_sendfile; 69 request->resp_sender = MHD_resp_sender_sendfile;
67#endif /* _MHD_HAVE_SENDFILE */ 70#endif /* _MHD_HAVE_SENDFILE */
68 71
69 if ( ( (NULL != request->method) && 72 if ( (MHD_METHOD_HEAD == request->method) ||
70 (MHD_str_equal_caseless_ (request->method,
71 MHD_HTTP_METHOD_HEAD)) ) ||
72 (MHD_HTTP_OK > response->status_code) || 73 (MHD_HTTP_OK > response->status_code) ||
73 (MHD_HTTP_NO_CONTENT == response->status_code) || 74 (MHD_HTTP_NO_CONTENT == response->status_code) ||
74 (MHD_HTTP_NOT_MODIFIED == response->status_code) ) 75 (MHD_HTTP_NOT_MODIFIED == response->status_code) )
@@ -79,19 +80,17 @@ response_action (void *cls,
79 request->response_write_position = response->total_size; 80 request->response_write_position = response->total_size;
80 } 81 }
81 if ( (MHD_REQUEST_HEADERS_PROCESSED == request->state) && 82 if ( (MHD_REQUEST_HEADERS_PROCESSED == request->state) &&
82 (NULL != connection->method) && 83 (MHD_METHOD_POST == request->method) ||
83 ( (MHD_str_equal_caseless_ (request->method, 84 (MHD_METHOD_PUT == request->method) )
84 MHD_HTTP_METHOD_POST)) ||
85 (MHD_str_equal_caseless_ (request->method,
86 MHD_HTTP_METHOD_PUT))) )
87 { 85 {
88 /* response was queued "early", refuse to read body / footers or 86 /* response was queued "early", refuse to read body / footers or
89 further requests! */ 87 further requests! */
90 connection->read_closed = true; 88 request->connection->read_closed = true;
91 request->state = MHD_CONNECTION_FOOTERS_RECEIVED; 89 request->state = MHD_REQUEST_FOOTERS_RECEIVED;
92 } 90 }
93 if (! request->in_idle) 91 if (! request->in_idle)
94 (void) MHD_connection_handle_idle (connection); 92 (void) MHD_connection_handle_idle (request->connection);
93 return MHD_SC_OK;
95} 94}
96 95
97 96
@@ -114,7 +113,7 @@ response_action (void *cls,
114 */ 113 */
115_MHD_EXTERN struct MHD_Action * 114_MHD_EXTERN struct MHD_Action *
116MHD_action_from_response (struct MHD_Response *response, 115MHD_action_from_response (struct MHD_Response *response,
117 enum MHD_bool destroy_after_use) 116 enum MHD_Bool destroy_after_use)
118{ 117{
119 response->action.action = &response_action; 118 response->action.action = &response_action;
120 response->action.action_cls = response; 119 response->action.action_cls = response;