diff options
author | Alexander Færøy <ahf@torproject.org> | 2017-05-12 13:37:29 +0200 |
---|---|---|
committer | Alexander Færøy <ahf@torproject.org> | 2017-05-12 17:18:45 +0200 |
commit | 141f6e321190b7c8f928aba88ad0be8f553ee282 (patch) | |
tree | baf88d89a16f028e4cec18bb8aa5beda33128ae4 /src | |
parent | 59d17ca2bb6ab243bd58b29d26ccf6dd10741abe (diff) | |
download | tor-141f6e321190b7c8f928aba88ad0be8f553ee282.tar.gz tor-141f6e321190b7c8f928aba88ad0be8f553ee282.zip |
Add client_meth_pref array to define client compression preference.
See: https://bugs.torproject.org/21667
Diffstat (limited to 'src')
-rw-r--r-- | src/or/directory.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/or/directory.c b/src/or/directory.c index 7965ffd0ac..d9d402afe2 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -3321,6 +3321,16 @@ parse_accept_encoding_header(const char *h) return result; } +/** Array of compression methods to use (if supported) for requesting + * compressed data, ordered from best to worst. */ +static compress_method_t client_meth_pref[] = { + LZMA_METHOD, + ZSTD_METHOD, + ZLIB_METHOD, + GZIP_METHOD, + NO_METHOD +}; + /** Return a newly allocated string containing a comma separated list of * supported encodings. */ STATIC char * @@ -3329,11 +3339,10 @@ accept_encoding_header(void) smartlist_t *methods = smartlist_new(); char *header = NULL; compress_method_t method; + unsigned i; - // FIXME(ahf): Should we rename `srv_meth_pref_precompressed` and use this - // instead to define the order in the directory module rather than the order - // defined in the compression module? - for (method = UNKNOWN_METHOD; method > NO_METHOD; --method) { + for (i = 0; i < ARRAY_LENGTH(client_meth_pref); ++i) { + method = client_meth_pref[i]; if (tor_compress_supports_method(method)) smartlist_add(methods, (char *)compression_method_get_name(method)); } |