aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2000-11-22 12:53:56 +0000
committerDaniel Stenberg <daniel@haxx.se>2000-11-22 12:53:56 +0000
commit39abde5db5b095bc20b9203d8c0174e4f047fee2 (patch)
tree6ac063641acd99b8add8613bd3b19f270cddf470
parentfb962a281e97c517814a473763c3f9d3115b3964 (diff)
Added the client_write() function
-rw-r--r--lib/sendf.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/sendf.c b/lib/sendf.c
index 447a47390..11914d5e8 100644
--- a/lib/sendf.c
+++ b/lib/sendf.c
@@ -180,6 +180,40 @@ size_t ssend(int fd, struct connectdata *conn, void *mem, size_t len)
return bytes_written;
}
+/* client_write() sends data to the write callback(s)
+
+ The bit pattern defines to what "streams" to write to. Body and/or header.
+ The defines are in sendf.h of course.
+ */
+CURLcode client_write(struct UrlData *data,
+ int type,
+ char *ptr,
+ size_t len)
+{
+ size_t wrote;
+
+ if(0 == len)
+ len = strlen(ptr);
+
+ if(type & CLIENTWRITE_BODY) {
+ wrote = data->fwrite(ptr, 1, len, data->out);
+ if(wrote != len) {
+ failf (data, "Failed writing body");
+ return CURLE_WRITE_ERROR;
+ }
+ }
+ if((type & CLIENTWRITE_HEADER) && data->writeheader) {
+ wrote = data->fwrite(ptr, 1, len, data->writeheader);
+ if(wrote != len) {
+ failf (data, "Failed writing header");
+ return CURLE_WRITE_ERROR;
+ }
+ }
+
+ return CURLE_OK;
+}
+
+
/*
* add_buffer_init() returns a fine buffer struct
*/