Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/mod_dav_svn/repos.c view on Meta::CPAN
{
apr_array_header_t *accept_recs;
if (!accept_line)
return NULL;
accept_recs = apr_array_make(p, 10, sizeof(accept_rec));
while (*accept_line)
{
accept_rec *prefs = (accept_rec *) apr_array_push(accept_recs);
accept_line = get_entry(p, prefs, accept_line);
}
return accept_recs;
}
/* ---------------------------------------------------------------------- */
/* qsort comparison function for the quality field of the accept_rec
structure */
static int sort_encoding_pref(const void *accept_rec1, const void *accept_rec2)
{
float diff = ((const accept_rec *) accept_rec1)->quality -
((const accept_rec *) accept_rec2)->quality;
return (diff == 0 ? 0 : (diff > 0 ? -1 : 1));
}
/* Parse and handle any possible Accept-Encoding header that has been
sent as part of the request. */
static void
negotiate_encoding_prefs(request_rec *r, int *svndiff_version)
{
/* It would be nice if mod_negotiation
<http://httpd.apache.org/docs-2.1/mod/mod_negotiation.html> could
handle the Accept-Encoding header parsing for us. Sadly, it
looks like its data structures and routines are private (see
httpd/modules/mappers/mod_negotiation.c). Thus, we duplicate the
necessary ones in this file. */
int i;
const apr_array_header_t *encoding_prefs;
encoding_prefs = do_header_line(r->pool,
apr_table_get(r->headers_in,
"Accept-Encoding"));
if (!encoding_prefs || apr_is_empty_array(encoding_prefs))
{
*svndiff_version = 0;
return;
}
*svndiff_version = 0;
qsort(encoding_prefs->elts, (size_t) encoding_prefs->nelts,
sizeof(accept_rec), sort_encoding_pref);
for (i = 0; i < encoding_prefs->nelts; i++)
{
struct accept_rec rec = APR_ARRAY_IDX(encoding_prefs, i,
struct accept_rec);
if (strcmp(rec.name, "svndiff1") == 0)
{
*svndiff_version = 1;
break;
}
else if (strcmp(rec.name, "svndiff") == 0)
{
*svndiff_version = 0;
break;
src/subversion/subversion/mod_dav_svn/repos.c view on Meta::CPAN
/* ### ugly hack to carry over Content-Type data to the open_stream, which
### does not have access to the request headers. */
{
const char *ct = apr_table_get(r->headers_in, "content-type");
comb->priv.is_svndiff =
ct != NULL
&& strcmp(ct, SVN_SVNDIFF_MIME_TYPE) == 0;
}
negotiate_encoding_prefs(r, &comb->priv.svndiff_version);
/* ### and another hack for computing diffs to send to the client */
comb->priv.delta_base = apr_table_get(r->headers_in,
SVN_DAV_DELTA_BASE_HEADER);
/* Gather any options requested by an svn client. */
comb->priv.svn_client_options = apr_table_get(r->headers_in,
SVN_DAV_OPTIONS_HEADER);
/* See if the client sent a custom 'version name' request header. */
( run in 0.864 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )