subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kot...@apache.org
Subject svn commit: r1791282 - in /subversion/trunk/subversion/libsvn_ra_serf: blame.c ra_serf.h replay.c update.c util.c
Date Thu, 13 Apr 2017 17:18:07 GMT
Author: kotkov
Date: Thu Apr 13 17:18:06 2017
New Revision: 1791282

URL: http://svn.apache.org/viewvc?rev=1791282&view=rev
Log:
ra_serf: Advertise support for compressed svndiff1 format in the
Accept-Encoding header for file-revs and replay REPORT requests.

This makes "svn blame" and "svnsync sync" receive compressed deltas
when HTTP compression is enabled on both the server and the client.
The new behavior is equivalent to how "svn checkout" currently works
over HTTP.

* subversion/libsvn_ra_serf/ra_serf.h
  (svn_ra_serf__setup_svndiff_accept_encoding): Declare new helper.

* subversion/libsvn_ra_serf/util.c
  (svn_ra_serf__setup_svndiff_accept_encoding): New helper function,
   factored out from ...

* subversion/libsvn_ra_serf/update.c
  (setup_update_report_headers): ...this function.

* subversion/libsvn_ra_serf/blame.c
  (struct blame_context_t): Remember if we are interested in compression
   using the new 'using_compression' field.
  (setup_headers): New function that sets the Accept-Encoding header.
  (svn_ra_serf__get_file_revs): Advertise svndiff1 support in the
   REPORT request headers.

* subversion/libsvn_ra_serf/replay.c
  (struct revision_report_t): Remember if we are interested in compression
   using the new 'using_compression' field.
  (setup_headers): New function that sets the Accept-Encoding header.
  (svn_ra_serf__replay_range): Advertise svndiff1 support in the
   REPORT request headers.

Modified:
    subversion/trunk/subversion/libsvn_ra_serf/blame.c
    subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h
    subversion/trunk/subversion/libsvn_ra_serf/replay.c
    subversion/trunk/subversion/libsvn_ra_serf/update.c
    subversion/trunk/subversion/libsvn_ra_serf/util.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=1791282&r1=1791281&r2=1791282&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/blame.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/blame.c Thu Apr 13 17:18:06 2017
@@ -81,6 +81,8 @@ typedef struct blame_context_t {
 
   svn_stream_t *stream;
 
+  svn_boolean_t using_compression;
+
 } blame_context_t;
 
 
@@ -318,6 +320,21 @@ create_file_revs_body(serf_bucket_t **bo
   return SVN_NO_ERROR;
 }
 
+/* Implements svn_ra_serf__request_header_delegate_t */
+static svn_error_t *
+setup_headers(serf_bucket_t *headers,
+              void *baton,
+              apr_pool_t *request_pool,
+              apr_pool_t *scratch_pool)
+{
+  blame_context_t *blame_ctx = baton;
+
+  svn_ra_serf__setup_svndiff_accept_encoding(headers,
+                                             blame_ctx->using_compression);
+
+  return SVN_NO_ERROR;
+}
+
 svn_error_t *
 svn_ra_serf__get_file_revs(svn_ra_session_t *ra_session,
                            const char *path,
@@ -343,6 +360,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;
 
   /* Since Subversion 1.8 we allow retrieving blames backwards. So we can't
      just unconditionally use end_rev as the peg revision as before */
@@ -369,6 +387,9 @@ svn_ra_serf__get_file_revs(svn_ra_sessio
   handler->body_type = "text/xml";
   handler->body_delegate = create_file_revs_body;
   handler->body_delegate_baton = blame_ctx;
+  handler->custom_accept_encoding = TRUE;
+  handler->header_delegate = setup_headers;
+  handler->header_delegate_baton = blame_ctx;
 
   SVN_ERR(svn_ra_serf__context_run_one(handler, pool));
 

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=1791282&r1=1791281&r2=1791282&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h Thu Apr 13 17:18:06 2017
@@ -1568,6 +1568,11 @@ svn_ra_serf__uri_parse(apr_uri_t *uri,
                        const char *url_str,
                        apr_pool_t *result_pool);
 
+/* Setup the "Accept-Encoding" header value for requests that expect
+   svndiff-encoded deltas, depending on the USING_COMPRESSION value. */
+void
+svn_ra_serf__setup_svndiff_accept_encoding(serf_bucket_t *headers,
+                                           svn_boolean_t using_compression);
 
 /* 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=1791282&r1=1791281&r2=1791282&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/replay.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/replay.c Thu Apr 13 17:18:06 2017
@@ -166,6 +166,8 @@ 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;
+
 } revision_report_t;
 
 /* Conforms to svn_ra_serf__xml_opened_t */
@@ -630,6 +632,21 @@ replay_done(serf_request_t *request,
   return SVN_NO_ERROR;
 }
 
+/* Implements svn_ra_serf__request_header_delegate_t */
+static svn_error_t *
+setup_headers(serf_bucket_t *headers,
+              void *baton,
+              apr_pool_t *request_pool,
+              apr_pool_t *scratch_pool)
+{
+  struct revision_report_t *ctx = baton;
+
+  svn_ra_serf__setup_svndiff_accept_encoding(headers,
+                                             ctx->using_compression);
+
+  return SVN_NO_ERROR;
+}
+
 svn_error_t *
 svn_ra_serf__replay_range(svn_ra_session_t *ra_session,
                           svn_revnum_t start_revision,
@@ -724,6 +741,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;
 
           /* Request all properties of a certain revision. */
           rev_ctx->rev_props = apr_hash_make(rev_ctx->pool);
@@ -781,6 +799,10 @@ svn_ra_serf__replay_range(svn_ra_session
           handler->done_delegate = replay_done;
           handler->done_delegate_baton = rev_ctx;
 
+          handler->custom_accept_encoding = TRUE;
+          handler->header_delegate = setup_headers;
+          handler->header_delegate_baton = rev_ctx;
+
           rev_ctx->report_handler = handler;
           svn_ra_serf__request_create(handler);
 

Modified: subversion/trunk/subversion/libsvn_ra_serf/update.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/update.c?rev=1791282&r1=1791281&r2=1791282&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/update.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/update.c Thu Apr 13 17:18:06 2017
@@ -2178,17 +2178,8 @@ setup_update_report_headers(serf_bucket_
 {
   report_context_t *report = baton;
 
-  if (report->sess->using_compression)
-    {
-      serf_bucket_headers_setn(headers, "Accept-Encoding",
-                               "gzip,svndiff1;q=0.9,svndiff;q=0.8");
-    }
-  else
-    {
-      /* Do not advertise svndiff1 support if we're not interested in
-         compression. */
-      serf_bucket_headers_setn(headers, "Accept-Encoding", "svndiff");
-    }
+  svn_ra_serf__setup_svndiff_accept_encoding(headers,
+                                             report->sess->using_compression);
 
   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=1791282&r1=1791281&r2=1791282&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/util.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/util.c Thu Apr 13 17:18:06 2017
@@ -2023,3 +2023,22 @@ svn_ra_serf__uri_parse(apr_uri_t *uri,
 
   return SVN_NO_ERROR;
 }
+
+void
+svn_ra_serf__setup_svndiff_accept_encoding(serf_bucket_t *headers,
+                                           svn_boolean_t using_compression)
+{
+  if (using_compression)
+    {
+      serf_bucket_headers_setn(headers, "Accept-Encoding",
+                               "gzip,svndiff1;q=0.9,svndiff;q=0.8");
+    }
+  else
+    {
+      /* Do not advertise svndiff1 support if we're not interested in
+         compression. */
+      serf_bucket_headers_setn(headers, "Accept-Encoding", "svndiff");
+    }
+
+  return SVN_NO_ERROR;
+}



Mime
View raw message