aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/http-parser
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-04-05 16:45:06 -0700
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-04-05 16:45:06 -0700
commita3262faeeb05bccc72973c743e894ed0940dd4ae (patch)
tree2c4f7bfdb55b9aba396c8faa6bc5db96b77a2094 /contrib/http-parser
parent19297207520f76190307b9f3a145378bc8e7842d (diff)
downloadrspamd-a3262faeeb05bccc72973c743e894ed0940dd4ae.tar.gz
rspamd-a3262faeeb05bccc72973c743e894ed0940dd4ae.zip
Add compatibility layer with old spamc.
Diffstat (limited to 'contrib/http-parser')
-rw-r--r--contrib/http-parser/http_parser.c42
-rw-r--r--contrib/http-parser/http_parser.h3
2 files changed, 41 insertions, 4 deletions
diff --git a/contrib/http-parser/http_parser.c b/contrib/http-parser/http_parser.c
index 298eb28ea..9aef5c185 100644
--- a/contrib/http-parser/http_parser.c
+++ b/contrib/http-parser/http_parser.c
@@ -272,6 +272,8 @@ enum state
, s_req_http_major
, s_req_first_http_minor
, s_req_http_minor
+ , s_req_spamc_start
+ , s_req_spamc
, s_req_line_almost_done
, s_header_field_start
@@ -925,7 +927,7 @@ size_t http_parser_execute (http_parser *parser,
/* or PROPFIND|PROPPATCH|PUT|PATCH|PURGE */
break;
case 'R': parser->method = HTTP_REPORT; break;
- case 'S': parser->method = HTTP_SUBSCRIBE; /* or SEARCH */ break;
+ case 'S': parser->method = HTTP_SUBSCRIBE; /* or SEARCH or SYMBOLS */ break;
case 'T': parser->method = HTTP_TRACE; break;
case 'U': parser->method = HTTP_UNLOCK; /* or UNSUBSCRIBE */ break;
default:
@@ -949,12 +951,18 @@ size_t http_parser_execute (http_parser *parser,
matcher = method_strings[parser->method];
if (ch == ' ' && matcher[parser->index] == '\0') {
- parser->state = s_req_spaces_before_url;
+ if (parser->method != HTTP_SYMBOLS && parser->method != HTTP_CHECK) {
+ parser->state = s_req_spaces_before_url;
+ }
+ else {
+ parser->state = s_req_spamc_start;
+ }
} else if (ch == matcher[parser->index]) {
; /* nada */
} else if (parser->method == HTTP_CONNECT) {
if (parser->index == 1 && ch == 'H') {
- parser->method = HTTP_CHECKOUT;
+ /* XXX: CHECKOUT has been removed */
+ parser->method = HTTP_CHECK;
} else if (parser->index == 2 && ch == 'P') {
parser->method = HTTP_COPY;
} else {
@@ -977,7 +985,10 @@ size_t http_parser_execute (http_parser *parser,
} else if (parser->method == HTTP_SUBSCRIBE) {
if (parser->index == 1 && ch == 'E') {
parser->method = HTTP_SEARCH;
- } else {
+ } else if (ch == 'Y') {
+ parser->method = HTTP_SYMBOLS;
+ }
+ else {
SET_ERRNO(HPE_INVALID_METHOD);
goto error;
}
@@ -1204,6 +1215,29 @@ size_t http_parser_execute (http_parser *parser,
break;
}
+ case s_req_spamc_start:
+ switch (ch) {
+ case 'S':
+ parser->state = s_req_spamc;
+ break;
+ case ' ':
+ break;
+ default:
+ SET_ERRNO(HPE_INVALID_CONSTANT);
+ goto error;
+ }
+ break;
+
+ case s_req_spamc:
+ {
+ if (ch == CR) {
+ parser->state = s_req_line_almost_done;
+ }
+ else if (ch == LF) {
+ parser->state = s_header_field_start;
+ }
+ break;
+ }
/* end of request line */
case s_req_line_almost_done:
diff --git a/contrib/http-parser/http_parser.h b/contrib/http-parser/http_parser.h
index 1a91c23f2..a322634f1 100644
--- a/contrib/http-parser/http_parser.h
+++ b/contrib/http-parser/http_parser.h
@@ -110,6 +110,9 @@ typedef int (*http_cb) (http_parser*);
/* RFC-5789 */ \
XX(24, PATCH, PATCH) \
XX(25, PURGE, PURGE) \
+ /* SPAMC compatibility */ \
+ XX(26, SYMBOLS, SYMBOLS) \
+ XX(27, CHECK, CHECK)
enum http_method
{