summaryrefslogtreecommitdiff
path: root/subversion/libsvn_ra_serf/options.c
diff options
context:
space:
mode:
Diffstat (limited to 'subversion/libsvn_ra_serf/options.c')
-rw-r--r--subversion/libsvn_ra_serf/options.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/subversion/libsvn_ra_serf/options.c b/subversion/libsvn_ra_serf/options.c
index 9cb507c8f470..a3d321a64715 100644
--- a/subversion/libsvn_ra_serf/options.c
+++ b/subversion/libsvn_ra_serf/options.c
@@ -71,6 +71,9 @@ typedef struct options_context_t {
svn_ra_serf__response_handler_t inner_handler;
void *inner_baton;
+ /* Have we received any DAV headers at all? */
+ svn_boolean_t received_dav_header;
+
const char *activity_collection;
svn_revnum_t youngest_rev;
@@ -165,6 +168,8 @@ capabilities_headers_iterator_callback(void *baton,
apr_array_header_t *vals = svn_cstring_split(val, ",", TRUE,
opt_ctx->pool);
+ opt_ctx->received_dav_header = TRUE;
+
/* Right now we only have a few capabilities to detect, so just
seek for them directly. This could be written slightly more
efficiently, but that wouldn't be worth it until we have many
@@ -396,6 +401,19 @@ options_response_handler(serf_request_t *request,
serf_bucket_headers_do(hdrs, capabilities_headers_iterator_callback,
opt_ctx);
+ /* Bail out early if we're not talking to a DAV server.
+ Note that this check is only valid if we've received a success
+ response; redirects and errors don't count. */
+ if (opt_ctx->handler->sline.code >= 200
+ && opt_ctx->handler->sline.code < 300
+ && !opt_ctx->received_dav_header)
+ {
+ return svn_error_createf
+ (SVN_ERR_RA_DAV_OPTIONS_REQ_FAILED, NULL,
+ _("The server at '%s' does not support the HTTP/DAV protocol"),
+ session->session_url_str);
+ }
+
/* Assume mergeinfo capability unsupported, if didn't receive information
about server or repository mergeinfo capability. */
if (!svn_hash_gets(session->capabilities, SVN_RA_CAPABILITY_MERGEINFO))
@@ -528,6 +546,7 @@ svn_ra_serf__v1_get_activity_collection(const char **activity_url,
svn_error_t *
svn_ra_serf__exchange_capabilities(svn_ra_serf__session_t *serf_sess,
const char **corrected_url,
+ const char **redirect_url,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
@@ -535,6 +554,8 @@ svn_ra_serf__exchange_capabilities(svn_ra_serf__session_t *serf_sess,
if (corrected_url)
*corrected_url = NULL;
+ if (redirect_url)
+ *redirect_url = NULL;
/* This routine automatically fills in serf_sess->capabilities */
SVN_ERR(create_options_req(&opt_ctx, serf_sess, scratch_pool));
@@ -557,8 +578,11 @@ svn_ra_serf__exchange_capabilities(svn_ra_serf__session_t *serf_sess,
}
else if (svn_path_is_url(opt_ctx->handler->location))
{
- *corrected_url = svn_uri_canonicalize(opt_ctx->handler->location,
- result_pool);
+ SVN_ERR(svn_uri_canonicalize_safe(corrected_url, NULL,
+ opt_ctx->handler->location, result_pool, scratch_pool));
+ if (redirect_url)
+ *redirect_url = apr_pstrdup(result_pool,
+ opt_ctx->handler->location);
}
else
{
@@ -569,11 +593,14 @@ svn_ra_serf__exchange_capabilities(svn_ra_serf__session_t *serf_sess,
See issue #3775 for details. */
apr_uri_t corrected_URI = serf_sess->session_url;
+ char *absolute_uri;
corrected_URI.path = (char *)corrected_url;
- *corrected_url = svn_uri_canonicalize(
- apr_uri_unparse(scratch_pool, &corrected_URI, 0),
- result_pool);
+ absolute_uri = apr_uri_unparse(scratch_pool, &corrected_URI, 0);
+ SVN_ERR(svn_uri_canonicalize_safe(corrected_url, NULL,
+ absolute_uri, result_pool, scratch_pool));
+ if (redirect_url)
+ *redirect_url = apr_pstrdup(result_pool, absolute_uri);
}
return SVN_NO_ERROR;
@@ -681,7 +708,8 @@ svn_ra_serf__has_capability(svn_ra_session_t *ra_session,
/* If any capability is unknown, they're all unknown, so ask. */
if (cap_result == NULL)
- SVN_ERR(svn_ra_serf__exchange_capabilities(serf_sess, NULL, pool, pool));
+ SVN_ERR(svn_ra_serf__exchange_capabilities(serf_sess, NULL, NULL,
+ pool, pool));
/* Try again, now that we've fetched the capabilities. */
cap_result = svn_hash_gets(serf_sess->capabilities, capability);