diff --git a/src/hlua.c b/src/hlua.c index 94f656234..08735374a 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -7201,6 +7201,7 @@ __LJMP static int hlua_httpclient_snd_yield(lua_State *L, int status, lua_KConte lua_pushstring(L, "body"); luaL_buffinit(L, &hlua_hc->b); + task_wakeup(hlua->task, TASK_WOKEN_MSG); MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_httpclient_rcv_yield, TICK_ETERNITY, 0)); return 1; diff --git a/src/http_client.c b/src/http_client.c index 35de71af7..a289206eb 100644 --- a/src/http_client.c +++ b/src/http_client.c @@ -557,6 +557,7 @@ static void httpclient_applet_io_handler(struct appctx *appctx) struct htx_sl *sl = NULL; int32_t pos; uint32_t hdr_num; + int ret; while (1) { @@ -569,19 +570,27 @@ static void httpclient_applet_io_handler(struct appctx *appctx) case HTTPCLIENT_S_REQ: /* copy the request from the hc->req.buf buffer */ - htx = htx_from_buf(&req->buf); /* We now that it fits the content of a buffer so can * just push this entirely */ - b_xfer(&req->buf, &hc->req.buf, b_data(&hc->req.buf)); - channel_add_input(req, b_data(&req->buf)); - appctx->st0 = HTTPCLIENT_S_REQ_BODY; + ret = b_xfer(&req->buf, &hc->req.buf, b_data(&hc->req.buf)); + if (ret) + channel_add_input(req, b_data(&req->buf)); + + htx = htxbuf(&req->buf); + if (!htx) + goto more; + + if (htx->flags & HTX_FL_EOM) /* check if a body need to be added */ + appctx->st0 = HTTPCLIENT_S_RES_STLINE; + else + appctx->st0 = HTTPCLIENT_S_REQ_BODY; + goto more; /* we need to leave the IO handler once we wrote the request */ break; case HTTPCLIENT_S_REQ_BODY: /* call the payload callback */ { if (hc->ops.req_payload) { - int ret; ret = b_xfer(&req->buf, &hc->req.buf, b_data(&hc->req.buf)); if (ret)