svn_error_t * svn_ra_neon__simple_request(int *code, svn_ra_neon__session_t *ras, const char *method, const char *url, apr_hash_t *extra_headers, const char *body, int okay_1, int okay_2, apr_pool_t *pool) { svn_ra_neon__request_t *req; svn_error_t *err; SVN_ERR(svn_ra_neon__request_create(&req, ras, method, url, pool)); multistatus_parser_create(req); /* svn_ra_neon__request_dispatch() adds the custom error response reader. Neon will take care of the Content-Length calculation */ err = svn_ra_neon__request_dispatch(code, req, extra_headers, body ? body : "", okay_1, okay_2, pool); svn_ra_neon__request_destroy(req); return err; }
svn_error_t * svn_ra_neon__parsed_request(svn_ra_neon__session_t *sess, const char *method, const char *url, const char *body, apr_file_t *body_file, void set_parser(ne_xml_parser *parser, void *baton), svn_ra_neon__startelm_cb_t startelm_cb, svn_ra_neon__cdata_cb_t cdata_cb, svn_ra_neon__endelm_cb_t endelm_cb, void *baton, apr_hash_t *extra_headers, int *status_code, svn_boolean_t spool_response, apr_pool_t *pool) { /* create/prep the request */ svn_ra_neon__request_t* req; svn_error_t *err; SVN_ERR(svn_ra_neon__request_create(&req, sess, method, url, pool)); err = parsed_request(req, sess, method, url, body, body_file, set_parser, startelm_cb, cdata_cb, endelm_cb, baton, extra_headers, status_code, spool_response, pool); svn_ra_neon__request_destroy(req); return err; }
svn_error_t * svn_ra_neon__exchange_capabilities(svn_ra_neon__session_t *ras, apr_pool_t *pool) { 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); req = svn_ra_neon__request_create(ras, "OPTIONS", ras->url->data, pool); /* ### 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; /* Was there an XML parse error somewhere? */ msg = ne_xml_get_error(parser); if (msg && *msg) { err = svn_error_createf(SVN_ERR_RA_DAV_REQUEST_FAILED, NULL, _("The %s request returned invalid XML " "in the response: %s (%s)"), "OPTIONS", msg, ras->url->data); goto cleanup; } /* We asked for, and therefore expect, to have found an activity collection in the response. */ if (oc.activity_coll == NULL) { 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(req); return err; }