diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-11-20 16:59:21 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-11-20 20:45:22 +0000 |
commit | 647adeec7fedbac5c39731a67f2b284b2d93090c (patch) | |
tree | bbc41eb7df79dd517100cd50d9850c77f228ac21 | |
parent | 33046bee3cd67f531e38ffb34ba93b8f0d5e4610 (diff) | |
download | rspamd-647adeec7fedbac5c39731a67f2b284b2d93090c.tar.gz rspamd-647adeec7fedbac5c39731a67f2b284b2d93090c.zip |
[Minor] Improve encryption requirement error code
-rw-r--r-- | src/libutil/http.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libutil/http.c b/src/libutil/http.c index bc4fc5283..a82fc24f7 100644 --- a/src/libutil/http.c +++ b/src/libutil/http.c @@ -45,6 +45,7 @@ enum rspamd_http_priv_flags { RSPAMD_HTTP_CONN_FLAG_NEW_HEADER = 1 << 1, RSPAMD_HTTP_CONN_FLAG_RESETED = 1 << 2, RSPAMD_HTTP_CONN_FLAG_TOO_LARGE = 1 << 3, + RSPAMD_HTTP_CONN_FLAG_ENCRYPTION_NEEDED = 1 << 4, }; #define IS_CONN_ENCRYPTED(c) ((c)->flags & RSPAMD_HTTP_CONN_FLAG_ENCRYPTED) @@ -915,6 +916,7 @@ rspamd_http_on_message_complete (http_parser * parser) priv = conn->priv; if ((conn->opts & RSPAMD_HTTP_REQUIRE_ENCRYPTION) && !IS_CONN_ENCRYPTED (priv)) { + priv->flags |= RSPAMD_HTTP_CONN_FLAG_ENCRYPTION_NEEDED; msg_err ("unencrypted connection when encryption has been requested"); return -1; } @@ -1185,8 +1187,12 @@ rspamd_http_event_handler (int fd, short what, gpointer ud) "Request entity too large: %zu", (size_t)priv->parser.content_length); } + else if (priv->flags & RSPAMD_HTTP_CONN_FLAG_ENCRYPTION_NEEDED) { + err = g_error_new (HTTP_ERROR, 400, + "Encryption required"); + } else { - err = g_error_new (HTTP_ERROR, priv->parser.http_errno, + err = g_error_new (HTTP_ERROR, 500 + priv->parser.http_errno, "HTTP parser error: %s", http_errno_description (priv->parser.http_errno)); } |