Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 080F1200CD8 for ; Wed, 2 Aug 2017 20:49:59 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0666F16A27F; Wed, 2 Aug 2017 18:49:59 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A587B16A27B for ; Wed, 2 Aug 2017 20:49:57 +0200 (CEST) Received: (qmail 25330 invoked by uid 500); 2 Aug 2017 18:49:56 -0000 Mailing-List: contact commits-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@subversion.apache.org Delivered-To: mailing list commits@subversion.apache.org Received: (qmail 25311 invoked by uid 99); 2 Aug 2017 18:49:55 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Aug 2017 18:49:55 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 5BCF63A01AA for ; Wed, 2 Aug 2017 18:49:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1803899 - in /subversion/trunk/subversion: libsvn_ra_serf/ libsvn_subr/ mod_dav_svn/ Date: Wed, 02 Aug 2017 18:49:55 -0000 To: commits@subversion.apache.org From: kotkov@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170802184955.5BCF63A01AA@svn01-us-west.apache.org> archived-at: Wed, 02 Aug 2017 18:49:59 -0000 Author: kotkov Date: Wed Aug 2 18:49:54 2017 New Revision: 1803899 URL: http://svn.apache.org/viewvc?rev=1803899&view=rev Log: Add 'http-compression=auto' mode on the client, now used by default. Following up on the recently added support for LZ4 compression, this patch introduces the new possible 'auto' mode for our client 'http-compression' configuration option, and starts using it by default. The previously used default was 'http-compression=yes', and the new 'auto' mode is a small, but an important tweak to its behavior. In the new mode, the HTTP compression is still being used, but the negotiating is tweaked to favor svndiff2 with LZ4 compression when working over local networks. The reasoning behind this is that for local networks it probably makes sense to favor compression speed of LZ4 instead of the better compression ratio from zlib-5, which has been used previously. To separate local and wide area networks, we use the connection latency of the initial OPTIONS request obtained with serf_connection_get_latency(). * subversion/libsvn_subr/config_file.c (svn_config_ensure): Document the new default and possible values of the http-compression option. * subversion/libsvn_ra_serf/ra_serf.h (svn_ra_serf__session_t.using_compression): Turn into a tristate field. (svn_ra_serf__session_t.conn_latency): New field. (svn_ra_serf__is_local_network): Declare new helper function. (svn_ra_serf__setup_svndiff_accept_encoding): Accept a session instead of the 'using_compression' boolean argument. * subversion/libsvn_ra_serf/util.c (svn_ra_serf__is_local_network): Implement this new function. (svn_ra_serf__setup_svndiff_accept_encoding): Tweak the Accept-Encoding to indicate that we'd like to see svndiff2 with http-compression=auto and when working over a local network. Otherwise, when using compression, indicate both svndiff2 and svndiff1 support, but tell the server that we favor svndiff1. (setup_request): Properly handle the 'using_compression' field, which is now a tristate. * subversion/libsvn_ra_serf/serf.c (load_config): Get the compression setting as a tristate. (svn_ra_serf__open): Initialize the connection latency to default value before we make the initial OPTIONS request. (ra_serf_dup_session): Add placeholder comment for the new field. * subversion/libsvn_ra_serf/options.c (options_response_handler): Remember the connection latency in the session. * subversion/libsvn_ra_serf/commit.c (negotiate_put_encoding): Rework to support new http-compression=auto mode. Update or rewrite the related comments. * subversion/libsvn_ra_serf/blame.c (blame_context_t): Store session instead of the 'using_compression' field. (setup_headers): Update call to svn_ra_serf__setup_svndiff_accept_encoding(). (svn_ra_serf__get_file_revs): Remember the used session in context. * subversion/libsvn_ra_serf/replay.c (revision_report_t): Store session instead of the 'using_compression' field. (setup_headers): Update call to svn_ra_serf__setup_svndiff_accept_encoding(). (svn_ra_serf__replay_range): Remember the used session in context. * subversion/libsvn_ra_serf/update.c (fetch_ctx_t): Store session instead of the 'using_compression' field. (headers_fetch): Update call to svn_ra_serf__setup_svndiff_accept_encoding(). Properly handle the 'using_compression' field, which is now a tristate. (fetch_for_file): Remember the used session in the fetch context. (setup_update_report_headers): Update call to svn_ra_serf__setup_svndiff_accept_encoding(). * subversion/mod_dav_svn/repos.c (get_svndiff_version): New helper function. (negotiate_encoding_prefs): Tweak the negotiation logic. Only override the client's preference if it supports svndiff2 and SVNCompressionLevel is set to 1. In all other cases, select the svndiff format that the client prefers to see (the one with the largest ;q= value in the Accept- Encoding header). Modified: subversion/trunk/subversion/libsvn_ra_serf/blame.c subversion/trunk/subversion/libsvn_ra_serf/commit.c subversion/trunk/subversion/libsvn_ra_serf/get_file.c subversion/trunk/subversion/libsvn_ra_serf/options.c subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h subversion/trunk/subversion/libsvn_ra_serf/replay.c subversion/trunk/subversion/libsvn_ra_serf/serf.c subversion/trunk/subversion/libsvn_ra_serf/update.c subversion/trunk/subversion/libsvn_ra_serf/util.c subversion/trunk/subversion/libsvn_subr/config_file.c subversion/trunk/subversion/mod_dav_svn/repos.c Modified: subversion/trunk/subversion/libsvn_ra_serf/blame.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/blame.c?rev=1803899&r1=1803898&r2=1803899&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_ra_serf/blame.c (original) +++ subversion/trunk/subversion/libsvn_ra_serf/blame.c Wed Aug 2 18:49:54 2017 @@ -81,7 +81,7 @@ typedef struct blame_context_t { svn_stream_t *stream; - svn_boolean_t using_compression; + svn_ra_serf__session_t *session; } blame_context_t; @@ -329,8 +329,7 @@ setup_headers(serf_bucket_t *headers, { blame_context_t *blame_ctx = baton; - svn_ra_serf__setup_svndiff_accept_encoding(headers, - blame_ctx->using_compression); + svn_ra_serf__setup_svndiff_accept_encoding(headers, blame_ctx->session); return SVN_NO_ERROR; } @@ -360,7 +359,7 @@ svn_ra_serf__get_file_revs(svn_ra_sessio blame_ctx->start = start; blame_ctx->end = end; blame_ctx->include_merged_revisions = include_merged_revisions; - blame_ctx->using_compression = session->using_compression; + blame_ctx->session = session; /* Since Subversion 1.8 we allow retrieving blames backwards. So we can't just unconditionally use end_rev as the peg revision as before */ Modified: subversion/trunk/subversion/libsvn_ra_serf/commit.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/commit.c?rev=1803899&r1=1803898&r2=1803899&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_ra_serf/commit.c (original) +++ subversion/trunk/subversion/libsvn_ra_serf/commit.c Wed Aug 2 18:49:54 2017 @@ -1866,29 +1866,47 @@ open_file(const char *path, } static void -negotiate_put_encoding(int *svndiff_version, - int *svndiff_compression_level, +negotiate_put_encoding(int *svndiff_version_p, + int *svndiff_compression_level_p, svn_ra_serf__session_t *session) { - if (session->supports_svndiff1 && session->using_compression) + int svndiff_version; + int compression_level; + + if (session->using_compression == svn_tristate_unknown) + { + /* With http-compression=auto, prefer svndiff2 over svndiff1 when + * working over a local network, as it is faster and in this case, + * we don't care about worse compression ratio. + * + * Note: For future compatibility, we also handle a theoretically + * possible case where the server has advertised only svndiff2 support. + */ + if (session->supports_svndiff2 && svn_ra_serf__is_local_network(session)) + svndiff_version = 2; + else if (session->supports_svndiff1) + svndiff_version = 1; + else if (session->supports_svndiff2) + svndiff_version = 2; + else + svndiff_version = 0; + } + else if (session->using_compression == svn_tristate_true) { - /* Prefer svndiff1 when using http compression, as svndiff2 is not a + /* Otherwise, prefer svndiff1, as svndiff2 is not a reasonable * substitute for svndiff1 with default compression level. (It gives * better speed and compression ratio comparable to svndiff1 with * compression level 1, but not 5). * - * It might make sense to tweak the current format negotiation scheme - * so that the server would say which versions of svndiff it accepts, - * _including_ the preferred order. This would allow us to dynamically - * pick svndiff2 if that's what the server thinks is appropriate. + * Note: For future compatibility, we also handle a theoretically + * possible case where the server has advertised only svndiff2 support. */ - *svndiff_version = 1; - *svndiff_compression_level = SVN_DELTA_COMPRESSION_LEVEL_DEFAULT; - } - else if (session->supports_svndiff2 && session->using_compression) - { - *svndiff_version = 2; - *svndiff_compression_level = SVN_DELTA_COMPRESSION_LEVEL_DEFAULT; + if (session->supports_svndiff1) + svndiff_version = 1; + else if (session->supports_svndiff2) + svndiff_version = 2; + else + svndiff_version = 0; } else { @@ -1902,9 +1920,16 @@ negotiate_put_encoding(int *svndiff_vers * the usage of the uncompressed format by setting the corresponding * client configuration option, if they want to. */ - *svndiff_version = 0; - *svndiff_compression_level = SVN_DELTA_COMPRESSION_LEVEL_NONE; + svndiff_version = 0; } + + if (svndiff_version == 0) + compression_level = SVN_DELTA_COMPRESSION_LEVEL_NONE; + else + compression_level = SVN_DELTA_COMPRESSION_LEVEL_DEFAULT; + + *svndiff_version_p = svndiff_version; + *svndiff_compression_level_p = compression_level; } static svn_error_t * Modified: subversion/trunk/subversion/libsvn_ra_serf/get_file.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/get_file.c?rev=1803899&r1=1803898&r2=1803899&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_ra_serf/get_file.c (original) +++ subversion/trunk/subversion/libsvn_ra_serf/get_file.c Wed Aug 2 18:49:54 2017 @@ -60,7 +60,7 @@ typedef struct stream_ctx_t { /* Have we read our response headers yet? */ svn_boolean_t read_headers; - svn_boolean_t using_compression; + svn_ra_serf__session_t *session; /* This flag is set when our response is aborted before we reach the * end and we decide to requeue this request. @@ -88,7 +88,7 @@ headers_fetch(serf_bucket_t *headers, { stream_ctx_t *fetch_ctx = baton; - if (fetch_ctx->using_compression) + if (fetch_ctx->session->using_compression != svn_tristate_false) { serf_bucket_headers_setn(headers, "Accept-Encoding", "gzip"); } @@ -396,7 +396,7 @@ svn_ra_serf__get_file(svn_ra_session_t * /* Create the fetch context. */ stream_ctx = apr_pcalloc(scratch_pool, sizeof(*stream_ctx)); stream_ctx->result_stream = stream; - stream_ctx->using_compression = session->using_compression; + stream_ctx->session = session; handler = svn_ra_serf__create_handler(session, scratch_pool); Modified: subversion/trunk/subversion/libsvn_ra_serf/options.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/options.c?rev=1803899&r1=1803898&r2=1803899&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_ra_serf/options.c (original) +++ subversion/trunk/subversion/libsvn_ra_serf/options.c Wed Aug 2 18:49:54 2017 @@ -365,6 +365,7 @@ options_response_handler(serf_request_t { svn_ra_serf__session_t *session = opt_ctx->session; serf_bucket_t *hdrs = serf_bucket_response_get_headers(response); + serf_connection_t *conn; /* Start out assuming all capabilities are unsupported. */ svn_hash_sets(session->capabilities, SVN_RA_CAPABILITY_PARTIAL_REPLAY, @@ -394,6 +395,10 @@ options_response_handler(serf_request_t svn_hash_sets(session->capabilities, SVN_RA_CAPABILITY_MERGEINFO, capability_no); + /* Remember our latency. */ + conn = serf_request_get_conn(request); + session->conn_latency = serf_connection_get_latency(conn); + opt_ctx->headers_processed = TRUE; } Modified: subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h?rev=1803899&r1=1803898&r2=1803899&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h (original) +++ subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h Wed Aug 2 18:49:54 2017 @@ -113,8 +113,12 @@ struct svn_ra_serf__session_t { /* Are we using ssl */ svn_boolean_t using_ssl; - /* Should we use compression for network transmissions? */ - svn_boolean_t using_compression; + /* Tristate flag that indicates if we should use compression for + network transmissions. If svn_tristate_true or svn_tristate_false, + the compression should be enabled and disabled, respectively. + If svn_tristate_unknown, determine this automatically based + on network parameters. */ + svn_tristate_t using_compression; /* The user agent string */ const char *useragent; @@ -268,6 +272,8 @@ struct svn_ra_serf__session_t { /* Indicates whether the server sends the result checksum in the response * to a successful PUT request. */ svn_boolean_t supports_put_result_checksum; + + apr_interval_time_t conn_latency; }; #define SVN_RA_SERF__HAVE_HTTPV2_SUPPORT(sess) ((sess)->me_resource != NULL) @@ -1576,10 +1582,13 @@ svn_ra_serf__uri_parse(apr_uri_t *uri, apr_pool_t *result_pool); /* Setup the "Accept-Encoding" header value for requests that expect - svndiff-encoded deltas, depending on the USING_COMPRESSION value. */ + svndiff-encoded deltas, depending on the SESSION state. */ void svn_ra_serf__setup_svndiff_accept_encoding(serf_bucket_t *headers, - svn_boolean_t using_compression); + svn_ra_serf__session_t *session); + +svn_boolean_t +svn_ra_serf__is_local_network(svn_ra_serf__session_t *session); /* Default limit for in-memory size of a request body. */ #define SVN_RA_SERF__REQUEST_BODY_IN_MEM_SIZE 256 * 1024 Modified: subversion/trunk/subversion/libsvn_ra_serf/replay.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/replay.c?rev=1803899&r1=1803898&r2=1803899&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_ra_serf/replay.c (original) +++ subversion/trunk/subversion/libsvn_ra_serf/replay.c Wed Aug 2 18:49:54 2017 @@ -166,7 +166,7 @@ typedef struct revision_report_t { svn_ra_serf__handler_t *propfind_handler; svn_ra_serf__handler_t *report_handler; /* For done handler */ - svn_boolean_t using_compression; + svn_ra_serf__session_t *session; } revision_report_t; @@ -641,8 +641,7 @@ setup_headers(serf_bucket_t *headers, { struct revision_report_t *ctx = baton; - svn_ra_serf__setup_svndiff_accept_encoding(headers, - ctx->using_compression); + svn_ra_serf__setup_svndiff_accept_encoding(headers, ctx->session); return SVN_NO_ERROR; } @@ -741,7 +740,7 @@ svn_ra_serf__replay_range(svn_ra_session rev_ctx->revision = rev; rev_ctx->low_water_mark = low_water_mark; rev_ctx->send_deltas = send_deltas; - rev_ctx->using_compression = session->using_compression; + rev_ctx->session = session; /* Request all properties of a certain revision. */ rev_ctx->rev_props = apr_hash_make(rev_ctx->pool); Modified: subversion/trunk/subversion/libsvn_ra_serf/serf.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/serf.c?rev=1803899&r1=1803898&r2=1803899&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_ra_serf/serf.c (original) +++ subversion/trunk/subversion/libsvn_ra_serf/serf.c Wed Aug 2 18:49:54 2017 @@ -180,9 +180,10 @@ load_config(svn_ra_serf__session_t *sess config_client = NULL; } - SVN_ERR(svn_config_get_bool(config, &session->using_compression, - SVN_CONFIG_SECTION_GLOBAL, - SVN_CONFIG_OPTION_HTTP_COMPRESSION, TRUE)); + SVN_ERR(svn_config_get_tristate(config, &session->using_compression, + SVN_CONFIG_SECTION_GLOBAL, + SVN_CONFIG_OPTION_HTTP_COMPRESSION, + "auto", svn_tristate_unknown)); svn_config_get(config, &timeout_str, SVN_CONFIG_SECTION_GLOBAL, SVN_CONFIG_OPTION_HTTP_TIMEOUT, NULL); @@ -266,10 +267,10 @@ load_config(svn_ra_serf__session_t *sess if (server_group) { - SVN_ERR(svn_config_get_bool(config, &session->using_compression, - server_group, - SVN_CONFIG_OPTION_HTTP_COMPRESSION, - session->using_compression)); + SVN_ERR(svn_config_get_tristate(config, &session->using_compression, + server_group, + SVN_CONFIG_OPTION_HTTP_COMPRESSION, + "auto", session->using_compression)); svn_config_get(config, &timeout_str, server_group, SVN_CONFIG_OPTION_HTTP_TIMEOUT, timeout_str); @@ -593,6 +594,10 @@ svn_ra_serf__open(svn_ra_session_t *sess && apr_pool_is_ancestor(serf_sess->pool, scratch_pool)); #endif + /* The actual latency will be determined as a part of the initial + OPTIONS request. */ + serf_sess->conn_latency = -1; + err = svn_ra_serf__exchange_capabilities(serf_sess, corrected_url, result_pool, scratch_pool); @@ -754,6 +759,7 @@ ra_serf_dup_session(svn_ra_session_t *ne /* supports_svndiff1 */ /* supports_svndiff2 */ /* supports_put_result_checksum */ + /* conn_latency */ new_sess->context = serf_context_create(result_pool); Modified: subversion/trunk/subversion/libsvn_ra_serf/update.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/update.c?rev=1803899&r1=1803898&r2=1803899&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_ra_serf/update.c (original) +++ subversion/trunk/subversion/libsvn_ra_serf/update.c Wed Aug 2 18:49:54 2017 @@ -365,7 +365,7 @@ typedef struct fetch_ctx_t { /* The handler representing this particular fetch. */ svn_ra_serf__handler_t *handler; - svn_boolean_t using_compression; + svn_ra_serf__session_t *session; /* Stores the information for the file we want to fetch. */ file_baton_t *file; @@ -797,10 +797,9 @@ headers_fetch(serf_bucket_t *headers, { serf_bucket_headers_setn(headers, SVN_DAV_DELTA_BASE_HEADER, fetch_ctx->delta_base); - svn_ra_serf__setup_svndiff_accept_encoding(headers, - fetch_ctx->using_compression); + svn_ra_serf__setup_svndiff_accept_encoding(headers, fetch_ctx->session); } - else if (fetch_ctx->using_compression) + else if (fetch_ctx->session->using_compression != svn_tristate_false) { serf_bucket_headers_setn(headers, "Accept-Encoding", "gzip"); } @@ -1278,7 +1277,7 @@ fetch_for_file(file_baton_t *file, fetch_ctx = apr_pcalloc(file->pool, sizeof(*fetch_ctx)); fetch_ctx->file = file; - fetch_ctx->using_compression = ctx->sess->using_compression; + fetch_ctx->session = ctx->sess; /* Can we somehow get away with just obtaining a DIFF? */ if (SVN_RA_SERF__HAVE_HTTPV2_SUPPORT(ctx->sess)) @@ -2169,8 +2168,7 @@ setup_update_report_headers(serf_bucket_ { report_context_t *report = baton; - svn_ra_serf__setup_svndiff_accept_encoding(headers, - report->sess->using_compression); + svn_ra_serf__setup_svndiff_accept_encoding(headers, report->sess); return SVN_NO_ERROR; } Modified: subversion/trunk/subversion/libsvn_ra_serf/util.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/util.c?rev=1803899&r1=1803898&r2=1803899&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_ra_serf/util.c (original) +++ subversion/trunk/subversion/libsvn_ra_serf/util.c Wed Aug 2 18:49:54 2017 @@ -1571,7 +1571,7 @@ setup_request(serf_request_t *request, { accept_encoding = NULL; } - else if (handler->session->using_compression) + else if (handler->session->using_compression != svn_tristate_false) { /* Accept gzip compression if enabled. */ accept_encoding = "gzip"; @@ -2026,20 +2026,41 @@ svn_ra_serf__uri_parse(apr_uri_t *uri, void svn_ra_serf__setup_svndiff_accept_encoding(serf_bucket_t *headers, - svn_boolean_t using_compression) + svn_ra_serf__session_t *session) { - if (using_compression) + if (session->using_compression == svn_tristate_false) { - /* We are equally interested in svndiff2 and svndiff1, let the - server choose the wire format. */ + /* Don't advertise support for compressed svndiff formats if + compression is disabled. */ + serf_bucket_headers_setn( + headers, "Accept-Encoding", "svndiff"); + } + else if (session->using_compression == svn_tristate_unknown && + svn_ra_serf__is_local_network(session)) + { + /* With http-compression=auto, advertise that we prefer svndiff2 + over svndiff1 when working over a local network, as it is faster + and in this case, we don't care about worse compression ratio. */ serf_bucket_headers_setn( headers, "Accept-Encoding", - "gzip,svndiff2;q=0.9,svndiff1;q=0.9,svndiff;q=0.8"); + "gzip,svndiff2;q=0.9,svndiff1;q=0.8,svndiff;q=0.7"); } else { - /* Do not advertise svndiff1 support if we're not interested in - compression. */ - serf_bucket_headers_setn(headers, "Accept-Encoding", "svndiff"); + /* Otherwise, advertise that we prefer svndiff1 over svndiff2. + svndiff2 is not a reasonable substitute for svndiff1 with default + compression level, because, while it is faster, it also gives worse + compression ratio. While we can use svndiff2 when working over + local networks (see above), we can't do this generally. */ + serf_bucket_headers_setn( + headers, "Accept-Encoding", + "gzip,svndiff1;q=0.9,svndiff2;q=0.8,svndiff;q=0.7"); } } + +svn_boolean_t +svn_ra_serf__is_local_network(svn_ra_serf__session_t *session) +{ + return session->conn_latency >= 0 && + session->conn_latency < apr_time_from_msec(5); +} Modified: subversion/trunk/subversion/libsvn_subr/config_file.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/config_file.c?rev=1803899&r1=1803898&r2=1803899&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_subr/config_file.c (original) +++ subversion/trunk/subversion/libsvn_subr/config_file.c Wed Aug 2 18:49:54 2017 @@ -1148,6 +1148,7 @@ svn_config_ensure(const char *config_dir "### http-timeout Timeout for HTTP requests in seconds" NL "### http-compression Whether to compress HTTP requests" NL + "### (yes/no/auto)." NL "### http-max-connections Maximum number of parallel server" NL "### connections to use for any given" NL "### HTTP operation." NL @@ -1307,7 +1308,7 @@ svn_config_ensure(const char *config_dir "# http-proxy-port = 7000" NL "# http-proxy-username = defaultusername" NL "# http-proxy-password = defaultpassword" NL - "# http-compression = no" NL + "# http-compression = auto" NL "# No http-timeout, so just use the builtin default." NL "# ssl-authority-files = /path/to/CAcert.pem;/path/to/CAcert2.pem" NL "#" NL Modified: subversion/trunk/subversion/mod_dav_svn/repos.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/repos.c?rev=1803899&r1=1803898&r2=1803899&view=diff ============================================================================== --- subversion/trunk/subversion/mod_dav_svn/repos.c (original) +++ subversion/trunk/subversion/mod_dav_svn/repos.c Wed Aug 2 18:49:54 2017 @@ -1739,6 +1739,18 @@ static int sort_encoding_pref(const void return (diff == 0 ? 0 : (diff > 0 ? -1 : 1)); } +static int get_svndiff_version(const struct accept_rec *rec) +{ + if (strcmp(rec->name, "svndiff2") == 0) + return 2; + else if (strcmp(rec->name, "svndiff1") == 0) + return 1; + else if (strcmp(rec->name, "svndiff") == 0) + return 0; + else + return -1; +} + /* Parse and handle any possible Accept-Encoding header that has been sent as part of the request. */ static void @@ -1752,7 +1764,7 @@ negotiate_encoding_prefs(request_rec *r, necessary ones in this file. */ int i; apr_array_header_t *encoding_prefs; - svn_boolean_t accepts_svndiff1 = FALSE; + apr_array_header_t *svndiff_encodings; svn_boolean_t accepts_svndiff2 = FALSE; encoding_prefs = do_header_line(r->pool, @@ -1765,33 +1777,37 @@ negotiate_encoding_prefs(request_rec *r, return; } - svn_sort__array(encoding_prefs, sort_encoding_pref); + svndiff_encodings = apr_array_make(r->pool, 3, sizeof(struct accept_rec)); for (i = 0; i < encoding_prefs->nelts; i++) { - struct accept_rec rec = APR_ARRAY_IDX(encoding_prefs, i, - struct accept_rec); - if (strcmp(rec.name, "svndiff2") == 0) - { - accepts_svndiff2 = TRUE; - } - else if (strcmp(rec.name, "svndiff1") == 0) - { - accepts_svndiff1 = TRUE; - } + const struct accept_rec *rec = &APR_ARRAY_IDX(encoding_prefs, i, + struct accept_rec); + int version = get_svndiff_version(rec); + + if (version > 0) + APR_ARRAY_PUSH(svndiff_encodings, struct accept_rec) = *rec; + + if (version == 2) + accepts_svndiff2 = TRUE; } - /* Enable svndiff2 if the client can read it, and if the server-side - * compression level is set to 1. Svndiff2 offers better speed and - * compression ratio comparable to svndiff1 with compression level 1, - * but not with other compression levels. - */ if (accepts_svndiff2 && dav_svn__get_compression_level(r) == 1) { + /* Enable svndiff2 if the client can read it, and if the server-side + * compression level is set to 1. Svndiff2 offers better speed and + * compression ratio comparable to svndiff1 with compression level 1, + * but not with other compression levels. + */ *svndiff_version = 2; } - else if (accepts_svndiff1) + else if (svndiff_encodings->nelts > 0) { - *svndiff_version = 1; + const struct accept_rec *rec; + + /* Otherwise, use what the client prefers to see. */ + svn_sort__array(svndiff_encodings, sort_encoding_pref); + rec = &APR_ARRAY_IDX(svndiff_encodings, 0, struct accept_rec); + *svndiff_version = get_svndiff_version(rec); } else {