[tor-commits] [tor/master] Add client_meth_pref array to define client compression preference.
nickm at torproject.org
nickm at torproject.org
Mon May 15 21:26:28 UTC 2017
commit 141f6e321190b7c8f928aba88ad0be8f553ee282
Author: Alexander Færøy <ahf at torproject.org>
Date: Fri May 12 13:37:29 2017 +0200
Add client_meth_pref array to define client compression preference.
See: https://bugs.torproject.org/21667
---
src/or/directory.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/or/directory.c b/src/or/directory.c
index 7965ffd..d9d402a 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));
}
More information about the tor-commits
mailing list