diff options
author | rofl0r <rofl0r@users.noreply.github.com> | 2020-09-10 14:37:56 +0100 |
---|---|---|
committer | rofl0r <rofl0r@users.noreply.github.com> | 2020-09-10 14:37:56 +0100 |
commit | e94cbdb3a5694b9dfe1f0dcfcef21a38631f7eb8 (patch) | |
tree | f03d9817b177de3f32b4d203b76722646cd6b3ec /src/reqs.c | |
parent | b549ba5af38786319f27ce7abb40c610f11cdea9 (diff) |
handle_connection(): factor out failure code
this allows us in a next step to replace goto fail with a call to that
function, so we can see in a backtrace from where the failure was
triggered.
Diffstat (limited to 'src/reqs.c')
-rw-r--r-- | src/reqs.c | 47 |
1 files changed, 26 insertions, 21 deletions
@@ -1485,6 +1485,31 @@ get_request_entity(struct conn_s *connptr) return ret; } +static void handle_connection_failure(struct conn_s *connptr) +{ + /* + * First, get the body if there is one. + * If we don't read all there is from the socket first, + * it is still marked for reading and we won't be able + * to send our data properly. + */ + if (get_request_entity (connptr) < 0) { + log_message (LOG_WARNING, + "Could not retrieve request entity"); + indicate_http_error (connptr, 400, "Bad Request", + "detail", + "Could not retrieve the request entity " + "the client.", NULL); + update_stats (STAT_BADCONN); + } + + if (connptr->error_variables) { + send_http_error_message (connptr); + } else if (connptr->show_stats) { + showstats (connptr); + } +} + /* * This is the main drive for each connection. As you can tell, for the @@ -1712,27 +1737,7 @@ e401: goto done; fail: - /* - * First, get the body if there is one. - * If we don't read all there is from the socket first, - * it is still marked for reading and we won't be able - * to send our data properly. - */ - if (get_request_entity (connptr) < 0) { - log_message (LOG_WARNING, - "Could not retrieve request entity"); - indicate_http_error (connptr, 400, "Bad Request", - "detail", - "Could not retrieve the request entity " - "the client.", NULL); - update_stats (STAT_BADCONN); - } - - if (connptr->error_variables) { - send_http_error_message (connptr); - } else if (connptr->show_stats) { - showstats (connptr); - } + handle_connection_failure(connptr); done: free_request_struct (request); |