subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject svn commit: r1499223 - in /subversion/branches/1.8.x-busted-proxy: ./ subversion/include/ subversion/libsvn_ra_serf/ subversion/libsvn_subr/
Date Wed, 03 Jul 2013 06:36:39 GMT
Author: gstein
Date: Wed Jul  3 06:36:39 2013
New Revision: 1499223

URL: http://svn.apache.org/r1499223
Log:
On the 1.8.x-busted-proxy branch:

Merge (cleanly) r1489117, r1496470, r1497975, r1497980, r1498012.

Modified:
    subversion/branches/1.8.x-busted-proxy/   (props changed)
    subversion/branches/1.8.x-busted-proxy/subversion/include/svn_config.h
    subversion/branches/1.8.x-busted-proxy/subversion/libsvn_ra_serf/options.c
    subversion/branches/1.8.x-busted-proxy/subversion/libsvn_ra_serf/ra_serf.h
    subversion/branches/1.8.x-busted-proxy/subversion/libsvn_ra_serf/serf.c
    subversion/branches/1.8.x-busted-proxy/subversion/libsvn_ra_serf/util.c
    subversion/branches/1.8.x-busted-proxy/subversion/libsvn_subr/config_file.c

Propchange: subversion/branches/1.8.x-busted-proxy/
------------------------------------------------------------------------------
  Merged /subversion/trunk:r1489117,1496470,1497975,1497980,1498012

Modified: subversion/branches/1.8.x-busted-proxy/subversion/include/svn_config.h
URL: http://svn.apache.org/viewvc/subversion/branches/1.8.x-busted-proxy/subversion/include/svn_config.h?rev=1499223&r1=1499222&r2=1499223&view=diff
==============================================================================
--- subversion/branches/1.8.x-busted-proxy/subversion/include/svn_config.h (original)
+++ subversion/branches/1.8.x-busted-proxy/subversion/include/svn_config.h Wed Jul  3 06:36:39
2013
@@ -95,6 +95,8 @@ typedef struct svn_config_t svn_config_t
 #define SVN_CONFIG_OPTION_HTTP_BULK_UPDATES         "http-bulk-updates"
 /** @since New in 1.8. */
 #define SVN_CONFIG_OPTION_HTTP_MAX_CONNECTIONS      "http-max-connections"
+/** @since New in 1.9. */
+#define SVN_CONFIG_OPTION_BUSTED_PROXY              "busted-proxy"
 
 #define SVN_CONFIG_CATEGORY_CONFIG          "config"
 #define SVN_CONFIG_SECTION_AUTH                 "auth"

Modified: subversion/branches/1.8.x-busted-proxy/subversion/libsvn_ra_serf/options.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.8.x-busted-proxy/subversion/libsvn_ra_serf/options.c?rev=1499223&r1=1499222&r2=1499223&view=diff
==============================================================================
--- subversion/branches/1.8.x-busted-proxy/subversion/libsvn_ra_serf/options.c (original)
+++ subversion/branches/1.8.x-busted-proxy/subversion/libsvn_ra_serf/options.c Wed Jul  3
06:36:39 2013
@@ -520,6 +520,74 @@ svn_ra_serf__exchange_capabilities(svn_r
 }
 
 
+static svn_error_t *
+create_simple_options_body(serf_bucket_t **body_bkt,
+                           void *baton,
+                           serf_bucket_alloc_t *alloc,
+                           apr_pool_t *pool)
+{
+  serf_bucket_t *body;
+  serf_bucket_t *s;
+
+  body = serf_bucket_aggregate_create(alloc);
+  svn_ra_serf__add_xml_header_buckets(body, alloc);
+
+  s = SERF_BUCKET_SIMPLE_STRING("<D:options xmlns:D=\"DAV:\" />", alloc);
+  serf_bucket_aggregate_append(body, s);
+
+  *body_bkt = body;
+  return SVN_NO_ERROR;
+}
+
+
+svn_error_t *
+svn_ra_serf__probe_proxy(svn_ra_serf__session_t *serf_sess,
+                         apr_pool_t *scratch_pool)
+{
+  svn_ra_serf__handler_t *handler;
+  svn_error_t *err;
+
+  handler = apr_pcalloc(scratch_pool, sizeof(*handler));
+  handler->handler_pool = scratch_pool;
+  handler->method = "OPTIONS";
+  handler->path = serf_sess->session_url.path;
+  handler->conn = serf_sess->conns[0];
+  handler->session = serf_sess;
+
+  /* We don't care about the response body, so discard it.  */
+  handler->response_handler = svn_ra_serf__handle_discard_body;
+
+  /* We need a simple body, in order to send it in chunked format.  */
+  handler->body_delegate = create_simple_options_body;
+
+  /* No special headers.  */
+
+  err = svn_ra_serf__context_run_one(handler, scratch_pool);
+  if (err)
+    {
+      /* Some versions of nginx in reverse proxy mode will return 411. They want
+         a Content-Length header, rather than chunked requests. We can keep other
+         HTTP/1.1 features, but will disable the chunking.  */
+      if (handler->sline.code == 411)
+        {
+          serf_sess->using_chunked_requests = FALSE;
+
+          svn_error_clear(err);
+          return SVN_NO_ERROR;
+        }
+
+      return svn_error_trace(
+        svn_error_compose_create(
+          svn_ra_serf__error_on_status(handler->sline,
+                                       serf_sess->session_url.path,
+                                       handler->location),
+          err));
+    }
+
+  return SVN_NO_ERROR;
+}
+
+
 svn_error_t *
 svn_ra_serf__has_capability(svn_ra_session_t *ra_session,
                             svn_boolean_t *has,

Modified: subversion/branches/1.8.x-busted-proxy/subversion/libsvn_ra_serf/ra_serf.h
URL: http://svn.apache.org/viewvc/subversion/branches/1.8.x-busted-proxy/subversion/libsvn_ra_serf/ra_serf.h?rev=1499223&r1=1499222&r2=1499223&view=diff
==============================================================================
--- subversion/branches/1.8.x-busted-proxy/subversion/libsvn_ra_serf/ra_serf.h (original)
+++ subversion/branches/1.8.x-busted-proxy/subversion/libsvn_ra_serf/ra_serf.h Wed Jul  3
06:36:39 2013
@@ -144,6 +144,9 @@ struct svn_ra_serf__session_t {
      HTTP/1.0. Thus, we cannot send chunked requests.  */
   svn_boolean_t http10;
 
+  /* Should we use Transfer-Encoding: chunked for HTTP/1.1 servers. */
+  svn_boolean_t using_chunked_requests;
+
   /* Our Version-Controlled-Configuration; may be NULL until we know it. */
   const char *vcc_url;
 
@@ -186,7 +189,11 @@ struct svn_ra_serf__session_t {
   const char *activity_collection_url;
 
   /* Are we using a proxy? */
-  int using_proxy;
+  svn_boolean_t using_proxy;
+
+  /* Should we be careful with this proxy? (some have insufficient support that
+     we need to work around).  */
+  svn_boolean_t busted_proxy;
 
   const char *proxy_username;
   const char *proxy_password;
@@ -1334,6 +1341,14 @@ svn_ra_serf__run_merge(const svn_commit_
 
 /** OPTIONS-related functions **/
 
+/* When running with a proxy, we may need to detect and correct for problems.
+   This probing function will send a simple OPTIONS request to detect problems
+   with the connection.  */
+svn_error_t *
+svn_ra_serf__probe_proxy(svn_ra_serf__session_t *serf_sess,
+                         apr_pool_t *scratch_pool);
+
+
 /* On HTTPv2 connections, run an OPTIONS request over CONN to fetch the
    current youngest revnum, returning it in *YOUNGEST.
 

Modified: subversion/branches/1.8.x-busted-proxy/subversion/libsvn_ra_serf/serf.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.8.x-busted-proxy/subversion/libsvn_ra_serf/serf.c?rev=1499223&r1=1499222&r2=1499223&view=diff
==============================================================================
--- subversion/branches/1.8.x-busted-proxy/subversion/libsvn_ra_serf/serf.c (original)
+++ subversion/branches/1.8.x-busted-proxy/subversion/libsvn_ra_serf/serf.c Wed Jul  3 06:36:39
2013
@@ -225,6 +225,12 @@ load_config(svn_ra_serf__session_t *sess
                                SVN_CONFIG_OPTION_HTTP_MAX_CONNECTIONS,
                                SVN_CONFIG_DEFAULT_OPTION_HTTP_MAX_CONNECTIONS));
 
+  /* Is this proxy potentially busted? Do we need to take special care?  */
+  SVN_ERR(svn_config_get_bool(config, &session->busted_proxy,
+                              SVN_CONFIG_SECTION_GLOBAL,
+                              SVN_CONFIG_OPTION_BUSTED_PROXY,
+                              FALSE));
+
   if (config)
     server_group = svn_config_find_group(config,
                                          session->session_url.hostname,
@@ -281,6 +287,13 @@ load_config(svn_ra_serf__session_t *sess
                                    server_group,
                                    SVN_CONFIG_OPTION_HTTP_MAX_CONNECTIONS,
                                    session->max_connections));
+
+      /* Do we need to take care with this proxy?  */
+      SVN_ERR(svn_config_get_bool(
+               config, &session->busted_proxy,
+               server_group,
+               SVN_CONFIG_OPTION_BUSTED_PROXY,
+               session->busted_proxy));
     }
 
   /* Don't allow the http-max-connections value to be larger than our
@@ -442,6 +455,10 @@ svn_ra_serf__open(svn_ra_session_t *sess
      HTTP/1.1 is supported, we can upgrade. */
   serf_sess->http10 = TRUE;
 
+  /* If we switch to HTTP/1.1, then we will use chunked requests. We may disable
+     this, if we find an intervening proxy does not support chunked requests.  */
+  serf_sess->using_chunked_requests = TRUE;
+
   SVN_ERR(load_config(serf_sess, config, serf_sess->pool));
 
   serf_sess->conns[0] = apr_pcalloc(serf_sess->pool,
@@ -486,8 +503,15 @@ svn_ra_serf__open(svn_ra_session_t *sess
   if (err && err->apr_err == APR_EGENERAL)
     err = svn_error_createf(SVN_ERR_RA_DAV_REQUEST_FAILED, err,
                             _("Connection to '%s' failed"), session_URL);
+  SVN_ERR(err);
 
-  return svn_error_trace(err);
+  /* We have set up a useful connection. If we've been told there is possibly a
+     busted proxy in our path to the server AND we switched to HTTP/1.1 (chunked
+     requests), then probe for problems in any proxy.  */
+  if (serf_sess->busted_proxy && !serf_sess->http10)
+    SVN_ERR(svn_ra_serf__probe_proxy(serf_sess, pool));
+
+  return SVN_NO_ERROR;
 }
 
 /* Implements svn_ra__vtable_t.reparent(). */

Modified: subversion/branches/1.8.x-busted-proxy/subversion/libsvn_ra_serf/util.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.8.x-busted-proxy/subversion/libsvn_ra_serf/util.c?rev=1499223&r1=1499222&r2=1499223&view=diff
==============================================================================
--- subversion/branches/1.8.x-busted-proxy/subversion/libsvn_ra_serf/util.c (original)
+++ subversion/branches/1.8.x-busted-proxy/subversion/libsvn_ra_serf/util.c Wed Jul  3 06:36:39
2013
@@ -373,10 +373,8 @@ conn_setup(apr_socket_t *sock,
         {
           conn->ssl_context = serf_bucket_ssl_encrypt_context_get(*read_bkt);
 
-#if SERF_VERSION_AT_LEAST(1,0,0)
           serf_ssl_set_hostname(conn->ssl_context,
                                 conn->session->session_url.hostname);
-#endif
 
           serf_ssl_client_cert_provider_set(conn->ssl_context,
                                             svn_ra_serf__handle_client_cert,
@@ -642,10 +640,10 @@ setup_serf_req(serf_request_t *request,
 {
   serf_bucket_alloc_t *allocator = serf_request_get_alloc(request);
 
-#if SERF_VERSION_AT_LEAST(1, 1, 0)
   svn_spillbuf_t *buf;
+  svn_boolean_t set_CL = session->http10 || !session->using_chunked_requests;
 
-  if (session->http10 && body_bkt != NULL)
+  if (set_CL && body_bkt != NULL)
     {
       /* Ugh. Use HTTP/1.0 to talk to the server because we don't know if
          it speaks HTTP/1.1 (and thus, chunked requests), or because the
@@ -665,7 +663,6 @@ setup_serf_req(serf_request_t *request,
                                                request_pool,
                                                scratch_pool);
     }
-#endif
 
   /* Create a request bucket.  Note that this sucker is kind enough to
      add a "Host" header for us.  */
@@ -674,15 +671,13 @@ setup_serf_req(serf_request_t *request,
 
   /* Set the Content-Length value. This will also trigger an HTTP/1.0
      request (rather than the default chunked request).  */
-#if SERF_VERSION_AT_LEAST(1, 1, 0)
-  if (session->http10)
+  if (set_CL)
     {
       if (body_bkt == NULL)
         serf_bucket_request_set_CL(*req_bkt, 0);
       else
         serf_bucket_request_set_CL(*req_bkt, svn_spillbuf__get_size(buf));
     }
-#endif
 
   *hdrs_bkt = serf_bucket_request_get_headers(*req_bkt);
 
@@ -696,10 +691,10 @@ setup_serf_req(serf_request_t *request,
       serf_bucket_headers_setn(*hdrs_bkt, "Content-Type", content_type);
     }
 
-#if SERF_VERSION_AT_LEAST(1, 1, 0)
   if (session->http10)
+    {
       serf_bucket_headers_setn(*hdrs_bkt, "Connection", "keep-alive");
-#endif
+    }
 
   if (accept_encoding)
     {

Modified: subversion/branches/1.8.x-busted-proxy/subversion/libsvn_subr/config_file.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.8.x-busted-proxy/subversion/libsvn_subr/config_file.c?rev=1499223&r1=1499222&r2=1499223&view=diff
==============================================================================
--- subversion/branches/1.8.x-busted-proxy/subversion/libsvn_subr/config_file.c (original)
+++ subversion/branches/1.8.x-busted-proxy/subversion/libsvn_subr/config_file.c Wed Jul  3
06:36:39 2013
@@ -806,6 +806,9 @@ svn_config_ensure(const char *config_dir
         "###   http-max-connections       Maximum number of parallel server" NL
         "###                              connections to use for any given"  NL
         "###                              HTTP operation."                   NL
+        "###   busted-proxy               The proxy may have some protocol"  NL
+        "###                              issues that Subversion needs to"   NL
+        "###                              detect and work around."           NL
         "###   neon-debug-mask            Debug mask for Neon HTTP library"  NL
         "###   ssl-authority-files        List of files, each of a trusted CA"
                                                                              NL



Mime
View raw message