Commit a65078b8 authored by Sergey Lyubka's avatar Sergey Lyubka

Calling begin_request() after auth checks.

parent 7107afae
...@@ -1703,10 +1703,11 @@ int mg_get_cookie(const struct mg_connection *conn, const char *cookie_name, ...@@ -1703,10 +1703,11 @@ int mg_get_cookie(const struct mg_connection *conn, const char *cookie_name,
int name_len, len = -1; int name_len, len = -1;
if (dst == NULL || dst_size == 0) { if (dst == NULL || dst_size == 0) {
len = -2; len = -2;
} else if (cookie_name == NULL || (s = mg_get_header(conn, "Cookie")) == NULL) { } else if (cookie_name == NULL ||
len = -1; (s = mg_get_header(conn, "Cookie")) == NULL) {
dst[0] = '\0'; len = -1;
dst[0] = '\0';
} else { } else {
name_len = (int) strlen(cookie_name); name_len = (int) strlen(cookie_name);
end = s + strlen(s); end = s + strlen(s);
...@@ -4201,15 +4202,15 @@ static void handle_request(struct mg_connection *conn) { ...@@ -4201,15 +4202,15 @@ static void handle_request(struct mg_connection *conn) {
get_remote_ip(conn), ri->uri); get_remote_ip(conn), ri->uri);
DEBUG_TRACE(("%s", ri->uri)); DEBUG_TRACE(("%s", ri->uri));
if (conn->ctx->callbacks.begin_request != NULL && if (!conn->client.is_ssl && conn->client.ssl_redir &&
conn->ctx->callbacks.begin_request(conn)) {
// Do nothing, callback has served the request
} else if (!conn->client.is_ssl && conn->client.ssl_redir &&
(ssl_index = get_first_ssl_listener_index(conn->ctx)) > -1) { (ssl_index = get_first_ssl_listener_index(conn->ctx)) > -1) {
redirect_to_https_port(conn, ssl_index); redirect_to_https_port(conn, ssl_index);
} else if (!is_put_or_delete_request(conn) && } else if (!is_put_or_delete_request(conn) &&
!check_authorization(conn, path)) { !check_authorization(conn, path)) {
send_authorization_request(conn); send_authorization_request(conn);
} else if (conn->ctx->callbacks.begin_request != NULL &&
conn->ctx->callbacks.begin_request(conn)) {
// Do nothing, callback has served the request
#if defined(USE_WEBSOCKET) #if defined(USE_WEBSOCKET)
} else if (is_websocket_request(conn)) { } else if (is_websocket_request(conn)) {
handle_websocket_request(conn); handle_websocket_request(conn);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment