aboutsummaryrefslogtreecommitdiff
path: root/http.c
diff options
context:
space:
mode:
Diffstat (limited to 'http.c')
-rw-r--r--http.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/http.c b/http.c
index 0960d85..22b45d9 100644
--- a/http.c
+++ b/http.c
@@ -2,6 +2,7 @@
#include "slweb/http.h"
#include <dynstr.h>
+#include <pthread.h>
#include <sys/types.h>
#include <unistd.h>
#include <ctype.h>
@@ -909,12 +910,15 @@ static int process_payload(struct http_ctx *const h, const char *const line)
{
struct ctx *const c = &h->ctx;
const struct http_payload p = ctx_to_payload(c);
- const int ret = h->cfg.payload(&p, &h->wctx.r, h->cfg.user);
+ struct http_future f = {0};
+ const int ret = h->cfg.payload(&p, &h->wctx.r, &f, h->cfg.user);
ctx_free(c);
if (ret)
return ret;
+ else if (f.f)
+ return h->cfg.async(&f, h->cfg.user);
return start_response(h);
}
@@ -950,6 +954,7 @@ static int expect(struct http_ctx *const h, const char *const value)
if (!strcmp(value, "100-continue"))
{
struct ctx *const c = &h->ctx;
+ struct http_future f = {0};
const struct http_payload p =
{
.u.post.expect_continue = true,
@@ -963,10 +968,12 @@ static int expect(struct http_ctx *const h, const char *const value)
.resource = c->resource
};
- const int ret = h->cfg.payload(&p, &h->wctx.r, h->cfg.user);
+ const int ret = h->cfg.payload(&p, &h->wctx.r, &f, h->cfg.user);
if (ret)
return ret;
+ else if (f.f)
+ return h->cfg.async(&f, h->cfg.user);
return start_response(h);
}
@@ -1075,12 +1082,15 @@ static int send_payload(struct http_ctx *const h,
const struct http_payload *const p)
{
struct ctx *const c = &h->ctx;
- const int ret = h->cfg.payload(p, &h->wctx.r, h->cfg.user);
+ struct http_future f = {0};
+ const int ret = h->cfg.payload(p, &h->wctx.r, &f, h->cfg.user);
ctx_free(c);
if (ret)
return ret;
+ else if (f.f)
+ return h->cfg.async(&f, h->cfg.user);
return start_response(h);
}