aboutsummaryrefslogtreecommitdiff
path: root/src/or/directory.c
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2017-05-12 12:21:49 +0200
committerAlexander Færøy <ahf@torproject.org>2017-05-12 17:18:45 +0200
commitf8218b5adaa54c61c3b79ad7f055e1a4a433daa0 (patch)
tree8485bb4e62858038c2f575582e102ef097d99e6d /src/or/directory.c
parentcf2f7a1bea3beb03368fc309e7bf7d9ba598b6dd (diff)
downloadtor-f8218b5adaa54c61c3b79ad7f055e1a4a433daa0.tar.gz
tor-f8218b5adaa54c61c3b79ad7f055e1a4a433daa0.zip
Use compression_method_get_by_name() instead of explicit checks.
See: https://bugs.torproject.org/21667
Diffstat (limited to 'src/or/directory.c')
-rw-r--r--src/or/directory.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index 78e0fb3120..bcd2eba1f9 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -2057,20 +2057,15 @@ parse_http_response(const char *headers, int *code, time_t *date,
if (!strcmpstart(s, "Content-Encoding: ")) {
enc = s+18; break;
});
- if (!enc || !strcmp(enc, "identity")) {
+
+ if (enc == NULL)
*compression = NO_METHOD;
- } else if (!strcmp(enc, "deflate") || !strcmp(enc, "x-deflate")) {
- *compression = ZLIB_METHOD;
- } else if (!strcmp(enc, "gzip") || !strcmp(enc, "x-gzip")) {
- *compression = GZIP_METHOD;
- } else if (!strcmp(enc, "x-zstd")) {
- *compression = ZSTD_METHOD;
- } else if (!strcmp(enc, "x-tor-lzma")) {
- *compression = LZMA_METHOD;
- } else {
- log_info(LD_HTTP, "Unrecognized content encoding: %s. Trying to deal.",
- escaped(enc));
- *compression = UNKNOWN_METHOD;
+ else {
+ *compression = compression_method_get_by_name(enc);
+
+ if (*compression == UNKNOWN_METHOD)
+ log_info(LD_HTTP, "Unrecognized content encoding: %s. Trying to deal.",
+ escaped(enc));
}
}
SMARTLIST_FOREACH(parsed_headers, char *, s, tor_free(s));