subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject svn commit: r1351138 - in /subversion/trunk/subversion/libsvn_ra_serf: ra_serf.h update.c util.c
Date Sun, 17 Jun 2012 18:41:45 GMT
Author: gstein
Date: Sun Jun 17 18:41:44 2012
New Revision: 1351138

URL: http://svn.apache.org/viewvc?rev=1351138&view=rev
Log:
When we're parsing the Location header, ignore the scheme, host, and
port. It turns out that code.google.com returns http: when we checkout
the baseline (from an https: repository, of course) which then causes
the revprop PROPPATCH to fail against the normal http: resource.

By using just the path portion of the URL, later request handling will
put on the (default) values for scheme/host/port which is https:

At the same time, the update process doesn't need to use the
response_get_location() helper since the proper value is in HANDLER,
which then means we can make the Location header parsing private.

* subversion/libsvn_ra_serf/ra_serf.h:
  (svn_ra_serf__response_get_location): removed. made private.

* subversion/libsvn_ra_serf/util.c:
  (svn_ra_serf__response_get_location): renamed to ...
  (response_get_location): ... this. added docstring. parse the URI
    and extract just the path portion.
  (handle_response): track rename of response_get_location()

* libsvn_ra_serf/update.c:
  (handle_stream): get the location from the handler.

Modified:
    subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h
    subversion/trunk/subversion/libsvn_ra_serf/update.c
    subversion/trunk/subversion/libsvn_ra_serf/util.c

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=1351138&r1=1351137&r2=1351138&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h Sun Jun 17 18:41:44 2012
@@ -931,12 +931,6 @@ svn_ra_serf__response_discard_handler(se
                                       void *baton,
                                       apr_pool_t *pool);
 
-/* Return the value of the RESPONSE's Location header if any, or NULL
- * otherwise.  All allocations will be made in POOL.
- */
-const char *
-svn_ra_serf__response_get_location(serf_bucket_t *response,
-                                   apr_pool_t *pool);
 
 /** XML helper functions. **/
 

Modified: subversion/trunk/subversion/libsvn_ra_serf/update.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/update.c?rev=1351138&r1=1351137&r2=1351138&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/update.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/update.c Sun Jun 17 18:41:44 2012
@@ -1079,19 +1079,15 @@ handle_stream(serf_request_t *request,
               apr_pool_t *pool)
 {
   report_fetch_t *fetch_ctx = handler_baton;
-  const char *location;
   svn_error_t *err;
   apr_status_t status;
 
   /* ### new field. make sure we didn't miss some initialization.  */
   SVN_ERR_ASSERT(fetch_ctx->handler != NULL);
 
-  /* Woo-hoo.  Nothing here to see.  */
-  location = svn_ra_serf__response_get_location(response, pool);
-
   err = svn_ra_serf__error_on_status(fetch_ctx->handler->sline.code,
                                      fetch_ctx->info->name,
-                                     location);
+                                     fetch_ctx->handler->location);
   if (err)
     {
       fetch_ctx->handler->done = TRUE;

Modified: subversion/trunk/subversion/libsvn_ra_serf/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/util.c?rev=1351138&r1=1351137&r2=1351138&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/util.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/util.c Sun Jun 17 18:41:44 2012
@@ -941,16 +941,29 @@ svn_ra_serf__response_discard_handler(se
   return drain_bucket(response);
 }
 
-const char *
-svn_ra_serf__response_get_location(serf_bucket_t *response,
-                                   apr_pool_t *pool)
+
+/* Return the value of the RESPONSE's Location header if any, or NULL
+   otherwise.  All allocations will be made in POOL.  */
+static const char *
+response_get_location(serf_bucket_t *response,
+                      apr_pool_t *pool)
 {
   serf_bucket_t *headers;
-  const char *val;
+  const char *location;
+  apr_status_t status;
+  apr_uri_t uri;
 
   headers = serf_bucket_response_get_headers(response);
-  val = serf_bucket_headers_get(headers, "Location");
-  return val ? svn_urlpath__canonicalize(val, pool) : NULL;
+  location = serf_bucket_headers_get(headers, "Location");
+  if (location == NULL)
+    return NULL;
+
+  /* Ignore the scheme/host/port. Or just return as-is if we can't parse.  */
+  status = apr_uri_parse(pool, location, &uri);
+  if (!status)
+    location = uri.path;
+
+  return svn_urlpath__canonicalize(location, pool);
 }
 
 
@@ -1812,8 +1825,7 @@ handle_response(serf_request_t *request,
     }
 
   /* ... and set up the header fields in HANDLER.  */
-  handler->location = svn_ra_serf__response_get_location(
-                          response, handler->handler_pool);
+  handler->location = response_get_location(response, handler->handler_pool);
 
   /* On the last request, we failed authentication. We succeeded this time,
      so let's save away these credentials.  */



Mime
View raw message