diff options
author | joe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845> | 2006-01-02 11:43:19 +0000 |
---|---|---|
committer | joe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845> | 2006-01-02 11:43:19 +0000 |
commit | 851026e7ae9703a12615179cec861216b500929c (patch) | |
tree | bf0651afa342549c7aa756f56b568808cf61ab7f /src/ne_207.c | |
parent | 9dd0e9ae6d6532ef963098758c271650ca682586 (diff) | |
download | neon-851026e7ae9703a12615179cec861216b500929c.tar.gz |
* src/ne_207.h (ne_207_create): Take a base URI argument.
(ne_207_start_response): Give parsed URI structure rather than raw
string.
* src/ne_207.c (struct ne_207_parser_s): Add URI base member.
(end_element): Parse and resolve the href URI; pass resolved URI
to start_response callback.
(ne_207_create): Take a copy of given base URI.
(ne_207_destroy): ... and free it.
(start_response): Unparse the given URI.
(ne_simple_request): Mock up a base URI.
* src/ne_props.h (ne_props_result, ne_props_create_complex): Take URI
structure rather than raw string.
* src/ne_props.c (ne_prop_result_set_s): Store URI structure.
(start_response): Take a copy of passed-in URI in propset; pass it
back to creator callback.
(free_propset): Free stored URI.
(end_response): Pass stored URI to results callback.
(ne_propfind_create): Create base URI to pass to ne_207_create.
* src/ne_locks.h (ne_lock_result): Take a URI structure rather than
raw string.
* src/ne_locks.c (struct discover_ctx): Remove session member.
(discover_results): Use given URI structure throughout.
(ld_create): Copy URI structure directly to lock.
(ne_lock_discover): No need to take a reference to the session.
* src/Makefile.in: Update dependencies.
* test/props.c (dummy_results, simple_results, tos_startresp): Adjust
to take URI structure.
(run_207_response): Initialize base URI to pass to ne_207_create.
(pfind_simple): Only use URI path in result strings.
* test/lock.c (discover_result, dummy_discover): Adjust to take URI
structure.
git-svn-id: http://svn.webdav.org/repos/projects/neon/trunk@825 61a7d7f5-40b7-0310-9c16-bb0ea8cb1845
Diffstat (limited to 'src/ne_207.c')
-rw-r--r-- | src/ne_207.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/ne_207.c b/src/ne_207.c index cd107ba..b9cc9e8 100644 --- a/src/ne_207.c +++ b/src/ne_207.c @@ -1,6 +1,6 @@ /* WebDAV 207 multi-status response handling - Copyright (C) 1999-2005, Joe Orton <joe@manyfish.co.uk> + Copyright (C) 1999-2006, Joe Orton <joe@manyfish.co.uk> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -44,6 +44,8 @@ struct ne_207_parser_s { ne_xml_parser *parser; void *userdata; + ne_uri base; + ne_buffer *cdata; /* remember whether we are in a response: the validation @@ -174,8 +176,16 @@ end_element(void *userdata, int state, const char *nspace, const char *name) case ELM_href: /* Now we have the href, begin the response */ if (p->start_response && HAVE_CDATA(p)) { - p->response = p->start_response(p->userdata, cdata); - p->in_response = 1; + ne_uri ref, resolved; + + if (ne_uri_parse(cdata, &ref) == 0) { + ne_uri_resolve(&p->base, &ref, &resolved); + + p->response = p->start_response(p->userdata, &resolved); + p->in_response = 1; + ne_uri_free(&resolved); + } + ne_uri_free(&ref); } break; case ELM_status: @@ -219,7 +229,8 @@ end_element(void *userdata, int state, const char *nspace, const char *name) return 0; } -ne_207_parser *ne_207_create(ne_xml_parser *parser, void *userdata) +ne_207_parser *ne_207_create(ne_xml_parser *parser, const ne_uri *base, + void *userdata) { ne_207_parser *p = ne_calloc(sizeof *p); @@ -227,6 +238,8 @@ ne_207_parser *ne_207_create(ne_xml_parser *parser, void *userdata) p->userdata = userdata; p->cdata = ne_buffer_create(); + ne_uri_copy(&p->base, base); + /* Add handler for the standard 207 elements */ ne_xml_push_handler(parser, start_element, cdata_207, end_element, p); @@ -237,6 +250,7 @@ void ne_207_destroy(ne_207_parser *p) { if (p->status.reason_phrase) ne_free(p->status.reason_phrase); ne_buffer_destroy(p->cdata); + ne_uri_free(&p->base); ne_free(p); } @@ -259,11 +273,11 @@ struct context { unsigned int is_error; }; -static void *start_response(void *userdata, const char *href) +static void *start_response(void *userdata, const ne_uri *uri) { struct context *ctx = userdata; if (ctx->href) ne_free(ctx->href); - ctx->href = ne_strdup(href); + ctx->href = ne_uri_unparse(uri); return NULL; } @@ -307,10 +321,16 @@ int ne_simple_request(ne_session *sess, ne_request *req) int ret; struct context ctx = {0}; ne_207_parser *p207; - ne_xml_parser *p; - - p = ne_xml_create(); - p207 = ne_207_create(p, &ctx); + ne_xml_parser *p = ne_xml_create(); + ne_uri base = {0}; + + /* Mock up a base URI; it should really be retrieved from the + * request object. */ + ne_fill_server_uri(sess, &base); + base.path = ne_strdup("/"); + p207 = ne_207_create(p, &base, &ctx); + ne_uri_free(&base); + /* The error string is progressively written into the * ne_buffer by the element callbacks */ ctx.buf = ne_buffer_create(); |