[prev in list] [next in list] [prev in thread] [next in thread] 

List:       subversion-cvs
Subject:    svn commit: r35616 - trunk/subversion/libsvn_ra_neon
From:       "C. Michael Pilato" <cmpilato () collab ! net>
Date:       2009-01-31 4:52:02
Message-ID: 200901310452.n0V4q2D1006738 () svn2 ! sjc ! collab ! net
[Download RAW message or body]

Author: cmpilato
Date: Fri Jan 30 20:52:02 2009
New Revision: 35616

Log:
Do all libsvn_ra_neon OPTIONS stuff -- capabilities exchange and
activity collection querying -- in one foul swoop.

* subversion/libsvn_ra_neon/ra_neon.h
  (svn_ra_neon__session_t): Add 'act_coll' member.
  (svn_ra_neon__get_activity_collection): Lose unnecessary 'url' parameter.
  (svn_ra_neon__exchange_capabilities): Flesh out the docstring a
    little better.

* subversion/libsvn_ra_neon/commit.c
  (get_activity_collection): Update call to
    svn_ra_neon__get_activity_collection().

* subversion/libsvn_ra_neon/options.c
  (svn_ra_neon__exchange_capabilities): Essentially merge in the
    body-sending and response-body-handling bits of
    svn_ra_neon__get_activity_collection() so this thing can be a
    one-stop OPTIONS shop.
  (svn_ra_neon__get_activity_collection): Rework as a thin wrapper
    around svn_ra_neon__exchange_capabilities(), and one that can use
    refer to the session's cache of the path of interest.

Modified:
   trunk/subversion/libsvn_ra_neon/commit.c
   trunk/subversion/libsvn_ra_neon/options.c
   trunk/subversion/libsvn_ra_neon/ra_neon.h

Modified: trunk/subversion/libsvn_ra_neon/commit.c
URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_ra_neon/commit.c?pathrev=35616&r1=35615&r2=35616
 ==============================================================================
--- trunk/subversion/libsvn_ra_neon/commit.c	Fri Jan 30 19:16:54 2009	(r35615)
+++ trunk/subversion/libsvn_ra_neon/commit.c	Fri Jan 30 20:52:02 2009	(r35616)
@@ -292,7 +292,6 @@ static svn_error_t * get_activity_collec
   /* use our utility function to fetch the activity URL */
   SVN_ERR(svn_ra_neon__get_activity_collection(collection,
                                                cc->ras,
-                                               cc->ras->root.path,
                                                pool));
 
   if (cc->push_func != NULL)

Modified: trunk/subversion/libsvn_ra_neon/options.c
URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_ra_neon/options.c?pathrev=35616&r1=35615&r2=35616
 ==============================================================================
--- trunk/subversion/libsvn_ra_neon/options.c	Fri Jan 30 19:16:54 2009	(r35615)
+++ trunk/subversion/libsvn_ra_neon/options.c	Fri Jan 30 20:52:02 2009	(r35616)
@@ -107,48 +107,6 @@ end_element(void *baton, int state,
   return SVN_NO_ERROR;
 }
 
-svn_error_t *
-svn_ra_neon__get_activity_collection(const svn_string_t **activity_coll,
-                                     svn_ra_neon__session_t *ras,
-                                     const char *url,
-                                     apr_pool_t *pool)
-{
-  options_ctx_t oc = { 0 };
-
-#if 0
-  ne_add_response_header_handler(req, "dav",
-                                 ne_duplicate_header, &dav_header);
-#endif
-
-  oc.pool = pool;
-  oc.cdata = svn_stringbuf_create("", pool);
-
-  SVN_ERR(svn_ra_neon__parsed_request(ras, "OPTIONS", url,
-                                      "<?xml version=\"1.0\" "
-                                      "encoding=\"utf-8\"?>"
-                                      "<D:options xmlns:D=\"DAV:\">"
-                                      "<D:activity-collection-set/>"
-                                      "</D:options>", 0, NULL,
-                                      start_element,
-                                      svn_ra_neon__xml_collect_cdata,
-                                      end_element, &oc,
-                                      NULL, NULL, FALSE, pool));
-
-  if (oc.activity_coll == NULL)
-    {
-      /* ### error */
-      return svn_error_create(SVN_ERR_RA_DAV_OPTIONS_REQ_FAILED, NULL,
-                              _("The OPTIONS response did not include the "
-                                "requested activity-collection-set; "
-                                "this often means that "
-                                "the URL is not WebDAV-enabled"));
-    }
-
-  *activity_coll = oc.activity_coll;
-
-  return SVN_NO_ERROR;
-}
-
 
 /** Capabilities exchange. */
 
@@ -231,49 +189,85 @@ parse_capabilities(ne_request *req,
 }
 
 
-/* Exchange capabilities with the server, by sending an OPTIONS
-   request announcing the client's capabilities, and by filling
-   RAS->capabilities with the server's capabilities as read from the
-   response headers.  Use POOL only for temporary allocation. */
 svn_error_t *
-svn_ra_neon__exchange_capabilities(svn_ra_neon__session_t *ras, 
+svn_ra_neon__exchange_capabilities(svn_ra_neon__session_t *ras,
                                    apr_pool_t *pool)
 {
-  int http_ret_code;
-  svn_ra_neon__request_t *rar;
+  svn_ra_neon__request_t* req;
   svn_error_t *err = SVN_NO_ERROR;
+  ne_xml_parser *parser = NULL;
+  options_ctx_t oc = { 0 };
+  const char *msg;
+  int status_code;
+
+  oc.pool = pool;
+  oc.cdata = svn_stringbuf_create("", pool);
 
-  rar = svn_ra_neon__request_create(ras, "OPTIONS", ras->url->data, pool);
+  req = svn_ra_neon__request_create(ras, "OPTIONS", ras->url->data, pool);
 
-  /* Client capabilities are sent with every request.
-     See issue #3255 for more details. */
-  err = svn_ra_neon__request_dispatch(&http_ret_code, rar,
-                                      NULL, NULL, 200, 0, pool);
-  if (err)
+  /* ### Use a symbolic name somewhere for this MIME type? */
+  ne_add_request_header(req->ne_req, "Content-Type", "text/xml");
+
+  /* Create a parser to read the normal response body */
+  parser = svn_ra_neon__xml_parser_create(req, ne_accept_2xx, start_element, 
+                                          svn_ra_neon__xml_collect_cdata, 
+                                          end_element, &oc);
+
+  /* Run the request and get the resulting status code. */
+  if ((err = svn_ra_neon__request_dispatch(&status_code, req, NULL, 
+                                           "<?xml version=\"1.0\" "
+                                           "encoding=\"utf-8\"?>"
+                                           "<D:options xmlns:D=\"DAV:\">" 
+                                           "<D:activity-collection-set/>"
+                                           "</D:options>",
+                                           200, 0, pool)))
     goto cleanup;
 
-  if (http_ret_code == 200)
+  /* Was there an XML parse error somewhere? */
+  msg = ne_xml_get_error(parser);
+  if (msg && *msg)
     {
-      parse_capabilities(rar->ne_req, ras, pool);
+      err = svn_error_createf(SVN_ERR_RA_DAV_REQUEST_FAILED, NULL,
+                              _("The OPTIONS request returned invalid XML "
+                                "in the response: %s (%s)"),
+                              msg, ras->url->data);
+      goto cleanup;
     }
-  else
+  
+  /* We asked for, and therefore expect, to have found an activity
+     collection in the response.  */
+  if (oc.activity_coll == NULL)
     {
-      /* "can't happen", because svn_ra_neon__request_dispatch()
-         itself should have returned error if response code != 200. */
-      return svn_error_createf
-        (SVN_ERR_RA_DAV_OPTIONS_REQ_FAILED, NULL,
-         _("OPTIONS request (for capabilities) got HTTP response code %d"),
-         http_ret_code);
+      err = svn_error_create(SVN_ERR_RA_DAV_OPTIONS_REQ_FAILED, NULL,
+                             _("The OPTIONS response did not include the "
+                               "requested activity-collection-set; this often "
+                               "means that the URL is not WebDAV-enabled"));
+      goto cleanup;
     }
 
+  ras->act_coll = apr_pstrdup(ras->pool, oc.activity_coll->data);
+  parse_capabilities(req->ne_req, ras, pool);
+
  cleanup:
-  svn_ra_neon__request_destroy(rar);
+  svn_ra_neon__request_destroy(req);
 
   return err;
 }
 
 
 svn_error_t *
+svn_ra_neon__get_activity_collection(const svn_string_t **activity_coll,
+                                     svn_ra_neon__session_t *ras,
+                                     apr_pool_t *pool)
+{
+  if (! ras->act_coll)
+    SVN_ERR(svn_ra_neon__exchange_capabilities(ras, pool));
+  *activity_coll = svn_string_create(ras->act_coll, pool);
+  return SVN_NO_ERROR;
+}  
+
+
+svn_error_t *
 svn_ra_neon__has_capability(svn_ra_session_t *session,
                             svn_boolean_t *has,
                             const char *capability,

Modified: trunk/subversion/libsvn_ra_neon/ra_neon.h
URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_ra_neon/ra_neon.h?pathrev=35616&r1=35615&r2=35616
 ==============================================================================
--- trunk/subversion/libsvn_ra_neon/ra_neon.h	Fri Jan 30 19:16:54 2009	(r35615)
+++ trunk/subversion/libsvn_ra_neon/ra_neon.h	Fri Jan 30 20:52:02 2009	(r35616)
@@ -99,11 +99,12 @@ typedef struct {
 
   svn_boolean_t compression;            /* should we use http compression? */
 
-  /* Both of these function as caches, and are NULL when uninitialized
+  /* Each of these function as caches, and are NULL when uninitialized
      or cleared: */
   const char *vcc;                      /* version-controlled-configuration */
   const char *uuid;                     /* repository UUID */
-
+  const char *act_coll;                 /* activity collection set */
+  
   svn_ra_progress_notify_func_t progress_func;
   void *progress_baton;
 
@@ -544,14 +545,11 @@ extern const ne_propname svn_ra_neon__vc
 extern const ne_propname svn_ra_neon__checked_in_prop;
 
 
-
-
 /* send an OPTIONS request to fetch the activity-collection-set */
-svn_error_t * svn_ra_neon__get_activity_collection
-  (const svn_string_t **activity_coll,
-   svn_ra_neon__session_t *ras,
-   const char *url,
-   apr_pool_t *pool);
+svn_error_t *
+svn_ra_neon__get_activity_collection(const svn_string_t **activity_coll,
+                                     svn_ra_neon__session_t *ras,
+                                     apr_pool_t *pool);
 
 
 /* Call ne_set_request_body_pdovider on REQ with a provider function
@@ -1053,8 +1051,13 @@ svn_ra_neon__has_capability(svn_ra_sessi
                             const char *capability,
                             apr_pool_t *pool);
 
-/* 
- * Do a capabilities exchange with the server. */
+/* Exchange capabilities with the server, by sending an OPTIONS
+   request announcing the client's capabilities, and by filling
+   RAS->capabilities with the server's capabilities as read from the
+   response headers.  Use POOL only for temporary allocation.
+
+   NOTE:  This function also expects the server to announce the
+   activity collection.  */
 svn_error_t *
 svn_ra_neon__exchange_capabilities(svn_ra_neon__session_t *ras, 
                                    apr_pool_t *pool);

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=495&dsMessageId=1078309


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic