Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/libsvn_ra_serf/util.c view on Meta::CPAN
server_err.cdata = svn_stringbuf_create_empty(scratch_pool);
server_err.collect_cdata = FALSE;
server_err.parser.pool = server_err.error->pool;
server_err.parser.user_data = &server_err;
server_err.parser.start = start_error;
server_err.parser.end = end_error;
server_err.parser.cdata = cdata_error;
server_err.parser.done = &server_err.done;
server_err.parser.ignore_errors = TRUE;
/* We don't care about any errors except for SERVER_ERR.ERROR */
svn_error_clear(svn_ra_serf__handle_xml_parser(request,
response,
&server_err.parser,
scratch_pool));
/* ### checking DONE is silly. the above only parses whatever has
### been received at the network interface. totally wrong. but
### it is what we have for now (maintaining historical code),
### until we fully migrate. */
if (server_err.done && server_err.error->apr_err == APR_SUCCESS)
{
svn_error_clear(server_err.error);
server_err.error = SVN_NO_ERROR;
}
return svn_error_trace(server_err.error);
}
/* The only error that we will return is from the XML response body.
Otherwise, ignore the entire body but allow SUCCESS/EOF/EAGAIN to
surface. */
err = drain_bucket(response);
if (err && !SERF_BUCKET_READ_ERROR(err))
return svn_ra_serf__wrap_err(err, NULL);
return SVN_NO_ERROR;
}
/* Implements svn_ra_serf__response_handler_t */
svn_error_t *
svn_ra_serf__handle_xml_parser(serf_request_t *request,
serf_bucket_t *response,
void *baton,
apr_pool_t *pool)
{
serf_status_line sl;
apr_status_t status;
svn_ra_serf__xml_parser_t *ctx = baton;
svn_error_t *err;
/* ### get the HANDLER rather than fetching this. */
status = serf_bucket_response_status(response, &sl);
if (SERF_BUCKET_READ_ERROR(status))
{
return svn_ra_serf__wrap_err(status, NULL);
}
/* Woo-hoo. Nothing here to see. */
if (sl.code == 404 && !ctx->ignore_errors)
{
err = handle_server_error(request, response, pool);
if (err && APR_STATUS_IS_EOF(err->apr_err))
add_done_item(ctx);
return svn_error_trace(err);
}
if (!ctx->xmlp)
{
ctx->xmlp = XML_ParserCreate(NULL);
apr_pool_cleanup_register(ctx->pool, &ctx->xmlp, xml_parser_cleanup,
apr_pool_cleanup_null);
XML_SetUserData(ctx->xmlp, ctx);
XML_SetElementHandler(ctx->xmlp, start_xml, end_xml);
if (ctx->cdata)
{
XML_SetCharacterDataHandler(ctx->xmlp, cdata_xml);
}
}
while (1)
{
const char *data;
apr_size_t len;
status = serf_bucket_read(response, PARSE_CHUNK_SIZE, &data, &len);
if (SERF_BUCKET_READ_ERROR(status))
{
return svn_ra_serf__wrap_err(status, NULL);
}
/* Note: once the callbacks invoked by inject_to_parser() sets the
PAUSED flag, then it will not be cleared. write_to_pending() will
only save the content. Logic outside of serf_context_run() will
clear that flag, as appropriate, along with processing the
content that we have placed into the PENDING buffer.
We want to save arriving content into the PENDING structures if
the parser has been paused, or we already have data in there (so
the arriving data is appended, rather than injected out of order) */
if (ctx->paused || HAS_PENDING_DATA(ctx->pending))
{
err = write_to_pending(ctx, data, len, pool);
}
else
{
err = inject_to_parser(ctx, data, len, &sl);
if (err)
{
/* Should have no errors if IGNORE_ERRORS is set. */
SVN_ERR_ASSERT(!ctx->ignore_errors);
}
}
if (err)
{
SVN_ERR_ASSERT(ctx->xmlp != NULL);
apr_pool_cleanup_run(ctx->pool, &ctx->xmlp, xml_parser_cleanup);
src/subversion/subversion/libsvn_ra_serf/util.c view on Meta::CPAN
{
const char *vcc_url;
/* This should only happen if we haven't detected HTTP v2
support from the server. */
assert(! SVN_RA_SERF__HAVE_HTTPV2_SUPPORT(session));
/* We don't actually care about the VCC_URL, but this API
promises to populate the session's root-url cache, and that's
what we really want. */
SVN_ERR(svn_ra_serf__discover_vcc(&vcc_url, session,
conn ? conn : session->conns[0],
pool));
}
decoded_root = svn_path_uri_decode(session->repos_root.path, pool);
decoded_orig = svn_path_uri_decode(orig_path, pool);
*rel_path = svn_urlpath__skip_ancestor(decoded_root, decoded_orig);
SVN_ERR_ASSERT(*rel_path != NULL);
return SVN_NO_ERROR;
}
svn_error_t *
svn_ra_serf__report_resource(const char **report_target,
svn_ra_serf__session_t *session,
svn_ra_serf__connection_t *conn,
apr_pool_t *pool)
{
/* If we have HTTP v2 support, we want to report against the 'me'
resource. */
if (SVN_RA_SERF__HAVE_HTTPV2_SUPPORT(session))
*report_target = apr_pstrdup(pool, session->me_resource);
/* Otherwise, we'll use the default VCC. */
else
SVN_ERR(svn_ra_serf__discover_vcc(report_target, session, conn, pool));
return SVN_NO_ERROR;
}
svn_error_t *
svn_ra_serf__error_on_status(serf_status_line sline,
const char *path,
const char *location)
{
switch(sline.code)
{
case 301:
case 302:
case 307:
return svn_error_createf(SVN_ERR_RA_DAV_RELOCATED, NULL,
(sline.code == 301)
? _("Repository moved permanently to '%s';"
" please relocate")
: _("Repository moved temporarily to '%s';"
" please relocate"), location);
case 403:
return svn_error_createf(SVN_ERR_RA_DAV_FORBIDDEN, NULL,
_("Access to '%s' forbidden"), path);
case 404:
return svn_error_createf(SVN_ERR_FS_NOT_FOUND, NULL,
_("'%s' path not found"), path);
case 423:
return svn_error_createf(SVN_ERR_FS_NO_LOCK_TOKEN, NULL,
_("'%s': no lock token available"), path);
case 411:
return svn_error_createf(SVN_ERR_RA_DAV_REQUEST_FAILED, NULL,
_("DAV request failed: 411 Content length required. The "
"server or an intermediate proxy does not accept "
"chunked encoding. Try setting 'http-chunked-requests' "
"to 'auto' or 'no' in your client configuration."));
case 501:
return svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
_("The requested feature is not supported by "
"'%s'"), path);
}
if (sline.code >= 300)
return svn_error_createf(SVN_ERR_RA_DAV_REQUEST_FAILED, NULL,
_("Unexpected HTTP status %d '%s' on '%s'\n"),
sline.code, sline.reason, path);
return SVN_NO_ERROR;
}
svn_error_t *
svn_ra_serf__register_editor_shim_callbacks(svn_ra_session_t *ra_session,
svn_delta_shim_callbacks_t *callbacks)
{
svn_ra_serf__session_t *session = ra_session->priv;
session->shim_callbacks = callbacks;
return SVN_NO_ERROR;
}
/* Conforms to Expat's XML_StartElementHandler */
static void
expat_start(void *userData, const char *raw_name, const char **attrs)
{
struct expat_ctx_t *ectx = userData;
if (ectx->inner_error != NULL)
return;
ectx->inner_error = svn_error_trace(
svn_ra_serf__xml_cb_start(ectx->xmlctx,
raw_name, attrs));
#ifdef EXPAT_HAS_STOPPARSER
if (ectx->inner_error)
(void) XML_StopParser(ectx->parser, 0 /* resumable */);
#endif
}
/* Conforms to Expat's XML_EndElementHandler */
static void
expat_end(void *userData, const char *raw_name)
( run in 0.947 second using v1.01-cache-2.11-cpan-39bf76dae61 )