summaryrefslogtreecommitdiff
path: root/src/ne_basic.c
diff options
context:
space:
mode:
authorjoe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845>2004-10-11 19:59:58 +0000
committerjoe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845>2004-10-11 19:59:58 +0000
commit1ac419d11e26600ca9b28f216cabb5c77b27adaf (patch)
treed63c6233f5787ea62d294c4f892514b962572075 /src/ne_basic.c
parent39aabf2eb660abdc724a5c4b0629c3e360c2bff7 (diff)
downloadneon-1ac419d11e26600ca9b28f216cabb5c77b27adaf.tar.gz
Allow response body callbacks to return an error:
* src/ne_request.h (ne_block_reader): Return error code. * src/ne_request.c (ne_read_response_block): Fail with -1 if a reader callback returns an error. * src/ne_xml.c (ne_xml_parse_v): Return 0 (for the moment). * src/ne_basic.c (get_to_fd): Return error. * src/ne_compress.c (gz_reader): Return 0 (mostly), or pass through. * src/ne_auth.c (auth_body_reader): Return 0. * test/compress.c (reader): Return error. * test/request.c (collector): Return 0. (abortive_reader, abort_reader): New functions. git-svn-id: http://svn.webdav.org/repos/projects/neon/trunk@308 61a7d7f5-40b7-0310-9c16-bb0ea8cb1845
Diffstat (limited to 'src/ne_basic.c')
-rw-r--r--src/ne_basic.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/ne_basic.c b/src/ne_basic.c
index 1462ad4..0038778 100644
--- a/src/ne_basic.c
+++ b/src/ne_basic.c
@@ -121,27 +121,32 @@ struct get_context {
ne_content_range *range;
};
-static void get_to_fd(void *userdata, const char *block, size_t length)
+static int get_to_fd(void *userdata, const char *block, size_t length)
{
struct get_context *ctx = userdata;
ssize_t ret;
+ if (ctx->error) {
+ return -1;
+ }
+
if (!ctx->error) {
while (length > 0) {
ret = write(ctx->fd, block, length);
if (ret < 0) {
char err[200];
- ctx->error = 1;
ne_strerror(errno, err, sizeof err);
ne_set_error(ctx->session, _("Could not write to file: %s"),
err);
- break;
+ return -1;
} else {
length -= ret;
block += ret;
}
}
}
+
+ return 0;
}
static int accept_206(void *ud, ne_request *req, const ne_status *st)