Commit b5d07794 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make discarding the request body a dedicated function, since

we may be able to orderly terminate/prevent the transmission
in future protocols.
parent 12085db8
......@@ -778,6 +778,7 @@ void VBO_Free(struct busyobj **vbo);
/* cache_http1_fsm.c [HTTP1] */
ssize_t HTTP1_GetReqBody(struct req *, void *buf, ssize_t len);
int HTTP1_DiscardReqBody(struct req *req);
void HTTP1_Session(struct worker *, struct req *);
/* cache_req_fsm.c [CNT] */
......@@ -815,7 +816,6 @@ int FetchError(struct busyobj *, const char *error);
int FetchError2(struct busyobj *, const char *error, const char *more);
int FetchHdr(struct req *req, int need_host_hdr, int sendbody);
void FetchBody(struct worker *w, void *bo);
int FetchReqBody(struct req *, int sendbody);
void Fetch_Init(void);
/* cache_gzip.c */
......
......@@ -44,6 +44,8 @@
static unsigned fetchfrag;
static int fetchReqBody(struct req *req, int sendbody);
/*--------------------------------------------------------------------
* We want to issue the first error we encounter on fetching and
* supress the rest. This function does that.
......@@ -377,8 +379,8 @@ fetch_eof(struct busyobj *bo, struct http_conn *htc)
* to contain the complexity when we start handling chunked encoding.
*/
int
FetchReqBody(struct req *req, int sendbody)
static int
fetchReqBody(struct req *req, int sendbody)
{
char buf[8192];
ssize_t l = 1234;
......@@ -467,7 +469,7 @@ FetchHdr(struct req *req, int need_host_hdr, int sendbody)
(void)http_Write(wrk, hp, 0); /* XXX: stats ? */
/* Deal with any message-body the request might have */
i = FetchReqBody(req, sendbody);
i = fetchReqBody(req, sendbody);
if (sendbody && req->req_body_status == REQ_BODY_DONE)
retry = -1;
if (WRW_FlushRelease(wrk) || i > 0) {
......
......@@ -375,6 +375,27 @@ HTTP1_Session(struct worker *wrk, struct req *req)
}
}
/*
* XXX: DiscardReqBody() is a dedicated function, because we might
* XXX: be able to disuade or terminate its transmission in some protocols.
*/
int
HTTP1_DiscardReqBody(struct req *req)
{
char buf[8192];
ssize_t l;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
while (req->req_body_status != REQ_BODY_DONE &&
req->req_body_status != REQ_BODY_NONE) {
l = HTTP1_GetReqBody(req, buf, sizeof buf);
if (l < 0)
return (-1);
}
return (0);
}
ssize_t
HTTP1_GetReqBody(struct req *req, void *buf, ssize_t len)
{
......
......@@ -727,7 +727,7 @@ cnt_hit(struct worker *wrk, struct req *req)
if (req->handling == VCL_RET_DELIVER) {
//AZ(req->busyobj->bereq->ws);
//AZ(req->busyobj->beresp->ws);
(void)FetchReqBody(req, 0);
(void)HTTP1_DiscardReqBody(req); // XXX: handle err
req->req_step = R_STP_PREPRESP;
return (0);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment