diff options
author | Alexander Færøy <ahf@torproject.org> | 2017-05-12 12:54:16 +0200 |
---|---|---|
committer | Alexander Færøy <ahf@torproject.org> | 2017-05-12 17:18:45 +0200 |
commit | ef187bc280f1501bd7918b9c76a692027b320a67 (patch) | |
tree | 2ef70277d6f48a901722b3bf54c703ef74f3ca47 /src/or/directory.c | |
parent | 3a05687c6d4c1ed11707e53b5dbec1b81e2a9c0a (diff) | |
download | tor-ef187bc280f1501bd7918b9c76a692027b320a67.tar.gz tor-ef187bc280f1501bd7918b9c76a692027b320a67.zip |
Use compression_method_get_human_name() in connection_dir_client_reached_eof()
This patch refactors connection_dir_client_reached_eof() to use
compression_method_get_human_name() to set description1 and
description2 variables.
See: https://bugs.torproject.org/21667
Diffstat (limited to 'src/or/directory.c')
-rw-r--r-- | src/or/directory.c | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/src/or/directory.c b/src/or/directory.c index bcd2eba1f9..ed4f961acf 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -2307,32 +2307,18 @@ connection_dir_client_reached_eof(dir_connection_t *conn) if (compression == UNKNOWN_METHOD || guessed != compression) { /* Tell the user if we don't believe what we're told about compression.*/ const char *description1, *description2; - if (compression == ZLIB_METHOD) - description1 = "as deflated"; - else if (compression == GZIP_METHOD) - description1 = "as gzipped"; - else if (compression == ZSTD_METHOD) - description1 = "as Zstandard compressed"; - else if (compression == LZMA_METHOD) - description1 = "as LZMA compressed"; - else if (compression == NO_METHOD) - description1 = "as uncompressed"; - else - description1 = "with an unknown Content-Encoding"; - if (guessed == ZLIB_METHOD) - description2 = "deflated"; - else if (guessed == GZIP_METHOD) - description2 = "gzipped"; - else if (guessed == ZSTD_METHOD) - description2 = "Zstandard compressed"; - else if (guessed == LZMA_METHOD) - description2 = "LZMA compressed"; - else if (!plausible) + + description1 = compression_method_get_human_name(compression); + + if (BUG(description1 == NULL)) + description1 = compression_method_get_human_name(UNKNOWN_METHOD); + + if (guessed == UNKNOWN_METHOD && !plausible) description2 = "confusing binary junk"; else - description2 = "uncompressed"; + description2 = compression_method_get_human_name(guessed); - log_info(LD_HTTP, "HTTP body from server '%s:%d' was labeled %s, " + log_info(LD_HTTP, "HTTP body from server '%s:%d' was labeled as %s, " "but it seems to be %s.%s", conn->base_.address, conn->base_.port, description1, description2, |