You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by cm...@apache.org on 2010/07/30 21:27:02 UTC

svn commit: r980931 - in /subversion/branches/issue-2779-dev: BRANCH-README subversion/libsvn_ra_serf/options.c subversion/libsvn_ra_serf/ra_serf.h subversion/libsvn_ra_serf/serf.c

Author: cmpilato
Date: Fri Jul 30 19:27:01 2010
New Revision: 980931

URL: http://svn.apache.org/viewvc?rev=980931&view=rev
Log:
On the 'issue-2779-dev' branch:
Get ra_serf's 301/302 handling back to parity with ra_neon's.

* subversion/libsvn_ra_serf/ra_serf.h
  (svn_ra_serf__exchange_capabilities): Add 'corrected_url' parameter.

* subversion/libsvn_ra_serf/options.c
  (svn_ra_serf__exchange_capabilities): Add 'corrected_url' parameter,
    and handle 301 and 302 status codes directly when 'corrected_url' is
    of interest to the caller.
  (svn_ra_serf__has_capability): Update call to
    svn_ra_serf__exchange_capabilities().

* subversion/libsvn_ra_serf/serf.c
  (svn_ra_serf__open): Update call to svn_ra_serf__exchange_capabilities().

* BRANCH-README
  Note that the ra_serf basic work is done, too.

Modified:
    subversion/branches/issue-2779-dev/BRANCH-README
    subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/options.c
    subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/ra_serf.h
    subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/serf.c

Modified: subversion/branches/issue-2779-dev/BRANCH-README
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/BRANCH-README?rev=980931&r1=980930&r2=980931&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/BRANCH-README (original)
+++ subversion/branches/issue-2779-dev/BRANCH-README Fri Jul 30 19:27:01 2010
@@ -14,7 +14,7 @@ The solution's approach is as follows:
      session opening and capabilities exchange.
 
        - ra_neon  [DONE]
-       - ra_serf  [see issue #3685[2]]
+       - ra_serf  [DONE]
 
   2. Rev svn_ra_open3(), teaching the new version to gracefully return
      the corrected URL provided by the server, while still allowing

Modified: subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/options.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/options.c?rev=980931&r1=980930&r2=980931&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/options.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/options.c Fri Jul 30 19:27:01 2010
@@ -472,12 +472,9 @@ svn_ra_serf__create_options_req(svn_ra_s
 
 /** Capabilities exchange. */
 
-/* Exchange capabilities with the server, by sending an OPTIONS
-   request announcing the client's capabilities, and by filling
-   SERF_SESS->capabilities with the server's capabilities as read
-   from the response headers.  Use POOL only for temporary allocation. */
 svn_error_t *
 svn_ra_serf__exchange_capabilities(svn_ra_serf__session_t *serf_sess,
+                                   const char **corrected_url,
                                    apr_pool_t *pool)
 {
   svn_ra_serf__options_context_t *opt_ctx;
@@ -490,6 +487,18 @@ svn_ra_serf__exchange_capabilities(svn_r
   err = svn_ra_serf__context_run_wait(
             svn_ra_serf__get_options_done_ptr(opt_ctx), serf_sess, pool);
 
+  /* If our caller cares about server redirections, and our response
+     carries such a thing, report as much.  We'll disregard ERR --
+     it's most likely just a complaint about the response body not
+     successfully parsing as XML or somesuch. */
+  if (corrected_url && ((opt_ctx->status_code == 301) ||
+                        (opt_ctx->status_code == 302)))
+    {
+      svn_error_clear(err);
+      *corrected_url = opt_ctx->parser_ctx->location;
+      return SVN_NO_ERROR;
+    }
+                        
   return svn_error_compose_create(
              svn_ra_serf__error_on_status(opt_ctx->status_code,
                                           serf_sess->repos_url.path,
@@ -520,7 +529,7 @@ svn_ra_serf__has_capability(svn_ra_sessi
 
   /* If any capability is unknown, they're all unknown, so ask. */
   if (cap_result == NULL)
-    SVN_ERR(svn_ra_serf__exchange_capabilities(serf_sess, pool));
+    SVN_ERR(svn_ra_serf__exchange_capabilities(serf_sess, NULL, pool));
 
   /* Try again, now that we've fetched the capabilities. */
   cap_result = apr_hash_get(serf_sess->capabilities,

Modified: subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/ra_serf.h
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/ra_serf.h?rev=980931&r1=980930&r2=980931&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/ra_serf.h (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/ra_serf.h Fri Jul 30 19:27:01 2010
@@ -1374,11 +1374,20 @@ svn_error_t * svn_ra_serf__get_mergeinfo
                                          apr_pool_t *pool);
 
 /* Exchange capabilities with the server, by sending an OPTIONS
-   request announcing the client's capabilities, and by filling
-   SERF_SESS->capabilities with the server's capabilities as read
-   from the response headers.  Use POOL only for temporary allocation. */
+ * request announcing the client's capabilities, and by filling
+ * SERF_SESS->capabilities with the server's capabilities as read from
+ * the response headers.  Use POOL only for temporary allocation.
+ *
+ * If the CORRECTED_URL is non-NULL, allow the OPTIONS response to
+ * report a server-dictated redirect or relocation (HTTP 301 or 302
+ * error codes), setting *CORRECTED_URL to the value of the corrected
+ * repository URL.  Otherwise, such responses from the server will
+ * generate an error.  (In either case, no capabilities are exchanged
+ * if there is, in fact, such a response from the server.)
+ */
 svn_error_t *
 svn_ra_serf__exchange_capabilities(svn_ra_serf__session_t *serf_sess,
+                                   const char **corrected_url,
                                    apr_pool_t *pool);
 
 /* Implements the has_capability RA layer function. */

Modified: subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/serf.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/serf.c?rev=980931&r1=980930&r2=980931&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/serf.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/serf.c Fri Jul 30 19:27:01 2010
@@ -343,7 +343,6 @@ svn_ra_serf__open(svn_ra_session_t *sess
   apr_uri_t url;
   const char *client_string = NULL;
 
-  /* We don't support server-prescribed redirections yet. */
   if (corrected_url)
     *corrected_url = NULL;
 
@@ -457,7 +456,7 @@ svn_ra_serf__open(svn_ra_session_t *sess
 
   session->priv = serf_sess;
 
-  return svn_ra_serf__exchange_capabilities(serf_sess, pool);
+  return svn_ra_serf__exchange_capabilities(serf_sess, corrected_url, pool);
 }
 
 static svn_error_t *