aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/man7/libweb_http.718
-rw-r--r--http.c2
2 files changed, 18 insertions, 2 deletions
diff --git a/doc/man7/libweb_http.7 b/doc/man7/libweb_http.7
index 0963828..39fd4a5 100644
--- a/doc/man7/libweb_http.7
+++ b/doc/man7/libweb_http.7
@@ -675,9 +675,14 @@ object accordingly.
.I free
is a pointer to a function that frees the memory used by
.I rw
+or
+.I args
.B only if
.I rw
-is a valid pointer. Otherwise,
+or
+.I args
+are valid pointers.
+Otherwise,
.I free
must be a null pointer.
@@ -710,6 +715,12 @@ pointed to by
.I done
to
.IR true .
+If not null,
+.I free
+shall be called when either all chunks have been transferred
+or whenever an error occurs, with
+.I args
+as its argument.
.I step
allows implementations to deal with responses asynchronously
@@ -723,6 +734,11 @@ must be assigned to a function that can generate it later.
.I libweb
shall then call this function immediately later,
without blocking other clients.
+If not null,
+.I free
+shall be called whenever an error occurs, with
+.I args
+as its argument.
Do not confuse
.I step
with
diff --git a/http.c b/http.c
index 21966bc..6410192 100644
--- a/http.c
+++ b/http.c
@@ -792,7 +792,7 @@ static int write_ctx_free(struct write_ctx *const w)
const struct http_response *const r = &w->r;
if (r->free)
- r->free(r->buf.rw);
+ r->free(r->args ? r->args : r->buf.rw);
if (r->f && (ret = fclose(r->f)))
fprintf(stderr, "%s: fclose(3): %s\n", __func__, strerror(errno));