You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by lg...@apache.org on 2012/10/08 23:05:16 UTC

svn commit: r1395777 - in /subversion/trunk/subversion/libsvn_ra_serf: serf.c util.c

Author: lgo
Date: Mon Oct  8 21:05:15 2012
New Revision: 1395777

URL: http://svn.apache.org/viewvc?rev=1395777&view=rev
Log:
Enable support for proxies that don't support HTTP/1.1 (or partially): 
assume the server supports HTTP/1.1, fall back if needed.
This fixes issue #3979.

* subversion/libsvn_ra_serf/serf.c
  (svn_ra_serf__open): Enabled http1.1 by default (as-is).

* subversion/libsvn_ra_serf/util.c
  (setup_serf_req): Add Connection:keep-alive header to a request on a known
   HTTP/1.0 connection.
  (handle_response): If either "411 Length Required" or a successfull response
   with HTTP/1.0 version in the status line, fall back to HTTP/1.0.

Modified:
    subversion/trunk/subversion/libsvn_ra_serf/serf.c
    subversion/trunk/subversion/libsvn_ra_serf/util.c

Modified: subversion/trunk/subversion/libsvn_ra_serf/serf.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/serf.c?rev=1395777&r1=1395776&r2=1395777&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/serf.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/serf.c Mon Oct  8 21:05:15 2012
@@ -399,8 +399,10 @@ svn_ra_serf__open(svn_ra_session_t *sess
 
   serf_sess->capabilities = apr_hash_make(serf_sess->pool);
 
-  serf_sess->http10 = TRUE;  /* until we confirm HTTP/1.1  */
-  serf_sess->http10 = FALSE; /* ### don't change behavior yet  */
+  /* Assume HTTP/1.1 is supported. When the server responds HTTP/1.0, switch
+     from chunked encoding to Content-Length, and set Connection:keep-alive
+     header to try and keep the pipeline open. */
+  serf_sess->http10 = FALSE;
 
   SVN_ERR(load_config(serf_sess, config, serf_sess->pool));
 

Modified: subversion/trunk/subversion/libsvn_ra_serf/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/util.c?rev=1395777&r1=1395776&r2=1395777&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/util.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/util.c Mon Oct  8 21:05:15 2012
@@ -691,6 +691,11 @@ 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
+
   /* These headers need to be sent with every request; see issue #3255
      ("mod_dav_svn does not pass client capabilities to start-commit
      hooks") for why. */
@@ -1796,9 +1801,9 @@ handle_response(serf_request_t *request,
       handler->sline = sl;
       handler->sline.reason = apr_pstrdup(handler->handler_pool, sl.reason);
 
-      /* HTTP/1.1? (or later)  */
-      if (sl.version != SERF_HTTP_10)
-        handler->session->http10 = FALSE;
+      /* Fall back to HTTP/1.0 needed? */
+      if (sl.version == SERF_HTTP_10)
+        handler->session->http10 = TRUE;
     }
 
   /* Keep reading from the network until we've read all the headers.  */
@@ -1909,6 +1914,14 @@ handle_response(serf_request_t *request,
         }
     }
 
+  /* 411 Length Required: server or proxy does not support HTTP/1.1, fall back
+     to HTTP/1.0. */
+  if (handler->sline.code == 411)
+    {
+      handler->discard_body = TRUE;
+      handler->session->http10 = TRUE;
+    }
+
   /* Stop processing the above, on every packet arrival.  */
   handler->reading_body = TRUE;