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.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/src/lib/action_from_response.c b/src/lib/action_from_response.c
index 43f33cb5..6253fb22 100644
--- a/src/lib/action_from_response.c
+++ b/src/lib/action_from_response.c
@@ -36,7 +36,7 @@
36 */ 36 */
37static enum MHD_StatusCode 37static enum MHD_StatusCode
38response_action (void *cls, 38response_action (void *cls,
39 struct MHD_Request *request) 39 struct MHD_Request *request)
40{ 40{
41 struct MHD_Response *response = cls; 41 struct MHD_Response *response = cls;
42 struct MHD_Daemon *daemon = request->daemon; 42 struct MHD_Daemon *daemon = request->daemon;
@@ -49,14 +49,15 @@ response_action (void *cls,
49#ifdef UPGRADE_SUPPORT 49#ifdef UPGRADE_SUPPORT
50 if ( (NULL != response->upgrade_handler) && 50 if ( (NULL != response->upgrade_handler) &&
51 daemon->disallow_upgrade ) 51 daemon->disallow_upgrade )
52 { 52 {
53#ifdef HAVE_MESSAGES 53#ifdef HAVE_MESSAGES
54 MHD_DLOG (daemon, 54 MHD_DLOG (daemon,
55 MHD_SC_UPGRADE_ON_DAEMON_WITH_UPGRADE_DISALLOWED, 55 MHD_SC_UPGRADE_ON_DAEMON_WITH_UPGRADE_DISALLOWED,
56 _("Attempted 'upgrade' connection on daemon without MHD_ALLOW_UPGRADE option!\n")); 56 _ (
57 "Attempted 'upgrade' connection on daemon without MHD_ALLOW_UPGRADE option!\n"));
57#endif 58#endif
58 return MHD_SC_UPGRADE_ON_DAEMON_WITH_UPGRADE_DISALLOWED; 59 return MHD_SC_UPGRADE_ON_DAEMON_WITH_UPGRADE_DISALLOWED;
59 } 60 }
60#endif /* UPGRADE_SUPPORT */ 61#endif /* UPGRADE_SUPPORT */
61 request->response = response; 62 request->response = response;
62#if defined(_MHD_HAVE_SENDFILE) 63#if defined(_MHD_HAVE_SENDFILE)
@@ -74,21 +75,21 @@ response_action (void *cls,
74 (MHD_HTTP_OK > response->status_code) || 75 (MHD_HTTP_OK > response->status_code) ||
75 (MHD_HTTP_NO_CONTENT == response->status_code) || 76 (MHD_HTTP_NO_CONTENT == response->status_code) ||
76 (MHD_HTTP_NOT_MODIFIED == response->status_code) ) 77 (MHD_HTTP_NOT_MODIFIED == response->status_code) )
77 { 78 {
78 /* if this is a "HEAD" request, or a status code for 79 /* if this is a "HEAD" request, or a status code for
79 which a body is not allowed, pretend that we 80 which a body is not allowed, pretend that we
80 have already sent the full message body. */ 81 have already sent the full message body. */
81 request->response_write_position = response->total_size; 82 request->response_write_position = response->total_size;
82 } 83 }
83 if ( (MHD_REQUEST_HEADERS_PROCESSED == request->state) && 84 if ( (MHD_REQUEST_HEADERS_PROCESSED == request->state) &&
84 ( (MHD_METHOD_POST == request->method) || 85 ( (MHD_METHOD_POST == request->method) ||
85 (MHD_METHOD_PUT == request->method) ) ) 86 (MHD_METHOD_PUT == request->method) ) )
86 { 87 {
87 /* response was queued "early", refuse to read body / footers or 88 /* response was queued "early", refuse to read body / footers or
88 further requests! */ 89 further requests! */
89 request->connection->read_closed = true; 90 request->connection->read_closed = true;
90 request->state = MHD_REQUEST_FOOTERS_RECEIVED; 91 request->state = MHD_REQUEST_FOOTERS_RECEIVED;
91 } 92 }
92 if (! request->in_idle) 93 if (! request->in_idle)
93 (void) MHD_request_handle_idle_ (request); 94 (void) MHD_request_handle_idle_ (request);
94 return MHD_SC_OK; 95 return MHD_SC_OK;
@@ -114,16 +115,16 @@ response_action (void *cls,
114 */ 115 */
115_MHD_EXTERN const struct MHD_Action * 116_MHD_EXTERN const struct MHD_Action *
116MHD_action_from_response (struct MHD_Response *response, 117MHD_action_from_response (struct MHD_Response *response,
117 enum MHD_Bool destroy_after_use) 118 enum MHD_Bool destroy_after_use)
118{ 119{
119 response->action.action = &response_action; 120 response->action.action = &response_action;
120 response->action.action_cls = response; 121 response->action.action_cls = response;
121 if (! destroy_after_use) 122 if (! destroy_after_use)
122 { 123 {
123 MHD_mutex_lock_chk_ (&response->mutex); 124 MHD_mutex_lock_chk_ (&response->mutex);
124 response->reference_count++; 125 response->reference_count++;
125 MHD_mutex_unlock_chk_ (&response->mutex); 126 MHD_mutex_unlock_chk_ (&response->mutex);
126 } 127 }
127 return &response->action; 128 return &response->action;
128} 129}
129 130