subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject svn commit: r1334365 - in /subversion/trunk/subversion/libsvn_ra_serf: ra_serf.h util.c
Date Sat, 05 May 2012 09:42:02 GMT
Author: gstein
Date: Sat May  5 09:42:02 2012
New Revision: 1334365

URL: http://svn.apache.org/viewvc?rev=1334365&view=rev
Log:
Provide for capturing the Status-Line and Location within the handler.
This has been captured within the XML parsing context and in the
simple request context, but it really belongs in the standard
requesting handling context for all requests.

* subversion/libsvn_ra_serf/ra_serf.h:
  (svn_ra_serf__handler_t): add SLINE and LOCATION fields to capture
    information from the response header. add READING_BODY for the
    response handler to skip initial processing and just perform the
    body handling. and add HANDLER_POOL as an indicator and pool for
    allocating the SLINE/LOCATION information.

* subversion/libsvn_ra_serf/util.c:
  (handle_response): manage the new fields

Modified:
    subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h
    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=1334365&r1=1334364&r2=1334365&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h Sat May  5 09:42:02 2012
@@ -406,6 +406,11 @@ typedef struct svn_ra_serf__handler_t {
   svn_ra_serf__response_handler_t response_handler;
   void *response_baton;
 
+  /* When REPONSE_HANDLER is invoked, the following fields will be set
+     based on the response header.  */
+  serf_status_line sline;  /* The parsed Status-Line  */
+  const char *location;  /* The Location: header, if any  */
+
   /* The handler and baton pair to be executed when a non-recoverable error
    * is detected.  If it is NULL in the presence of an error, an abort() may
    * be triggered.
@@ -437,6 +442,14 @@ typedef struct svn_ra_serf__handler_t {
   /* The connection and session to be used for this request. */
   svn_ra_serf__connection_t *conn;
   svn_ra_serf__session_t *session;
+
+  /* Internal flag to indicate we've parsed the headers.  */
+  svn_boolean_t reading_body;
+
+  /* Pool for allocating SLINE.REASON and LOCATION. If this pool is NULL,
+     then the requestor does not care about SLINE and LOCATION.  */
+  apr_pool_t *handler_pool;
+
 } svn_ra_serf__handler_t;
 
 /*

Modified: subversion/trunk/subversion/libsvn_ra_serf/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/util.c?rev=1334365&r1=1334364&r2=1334365&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/util.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/util.c Sat May  5 09:42:02 2012
@@ -1692,6 +1692,10 @@ handle_response(serf_request_t *request,
       return APR_SUCCESS;
     }
 
+  /* If we're reading the body, then skip all this preparation.  */
+  if (handler->reading_body)
+    goto process_body;
+
   status = serf_bucket_response_status(response, &sl);
   if (SERF_BUCKET_READ_ERROR(status))
     {
@@ -1774,6 +1778,21 @@ handle_response(serf_request_t *request,
       return SVN_NO_ERROR; /* Error is set in caller */
     }
 
+  /* Stop processing the above, on every packet arrival.  */
+  handler->reading_body = TRUE;
+
+  /* ... and set up the header fields in HANDLER if the caller is
+     interested.  */
+  if (handler->handler_pool != NULL)
+    {
+      handler->sline = sl;
+      handler->sline.reason = apr_pstrdup(handler->handler_pool,
+                                          handler->sline.reason);
+      handler->location = svn_ra_serf__response_get_location(
+                              response, handler->handler_pool);
+    }
+
+ process_body:
   err = handler->response_handler(request, response,
                                   handler->response_baton,
                                   pool);



Mime
View raw message