mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Send "Accept-Encoding" to directory servers.
See: https://bugs.torproject.org/21667
This commit is contained in:
parent
6305637197
commit
a3a31fa120
@ -1667,6 +1667,7 @@ directory_send_command(dir_connection_t *conn,
|
||||
char decorated_address[128];
|
||||
smartlist_t *headers = smartlist_new();
|
||||
char *url;
|
||||
char *accept_encoding;
|
||||
size_t url_len;
|
||||
char request[8192];
|
||||
size_t request_len, total_request_len = 0;
|
||||
@ -1723,6 +1724,12 @@ directory_send_command(dir_connection_t *conn,
|
||||
proxystring[0] = 0;
|
||||
}
|
||||
|
||||
/* Add Accept-Encoding. */
|
||||
accept_encoding = accept_encoding_header();
|
||||
smartlist_add_asprintf(headers, "Accept-Encoding: %s\r\n",
|
||||
accept_encoding);
|
||||
tor_free(accept_encoding);
|
||||
|
||||
/* Add additional headers, if any */
|
||||
{
|
||||
config_line_t *h;
|
||||
@ -3333,6 +3340,29 @@ parse_accept_encoding_header(const char *h)
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Return a newly allocated string containing a comma separated list of
|
||||
* supported encodings. */
|
||||
STATIC char *
|
||||
accept_encoding_header(void)
|
||||
{
|
||||
smartlist_t *methods = smartlist_new();
|
||||
char *header = NULL;
|
||||
compress_method_t method;
|
||||
|
||||
// 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) {
|
||||
if (tor_compress_supports_method(method))
|
||||
smartlist_add(methods, (char *)compression_method_get_name(method));
|
||||
}
|
||||
|
||||
header = smartlist_join_strings(methods, ", ", 0, NULL);
|
||||
smartlist_free(methods);
|
||||
|
||||
return header;
|
||||
}
|
||||
|
||||
/** Decide whether a client would accept the consensus we have.
|
||||
*
|
||||
* Clients can say they only want a consensus if it's signed by more
|
||||
|
@ -160,6 +160,7 @@ struct get_handler_args_t;
|
||||
STATIC int handle_get_hs_descriptor_v3(dir_connection_t *conn,
|
||||
const struct get_handler_args_t *args);
|
||||
STATIC int directory_handle_command(dir_connection_t *conn);
|
||||
STATIC char *accept_encoding_header(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user