*/
msg->sov += ptr - buf->lr;
buf->lr = ptr;
- msg->hdr_content_len = chunk;
+ msg->chunk_len = chunk;
+ msg->body_len += chunk;
msg->msg_state = chunk ? HTTP_MSG_DATA : HTTP_MSG_TRAILERS;
return 1;
error:
if (cl < 0)
goto return_bad_req;
- if ((txn->flags & TX_REQ_CNT_LEN) && (msg->hdr_content_len != cl))
+ if ((txn->flags & TX_REQ_CNT_LEN) && (msg->chunk_len != cl))
goto return_bad_req; /* already specified, was different */
txn->flags |= TX_REQ_CNT_LEN | TX_REQ_XFER_LEN;
- msg->hdr_content_len = cl;
+ msg->body_len = msg->chunk_len = cl;
}
/* bodyless requests have a known length */
char *first_param, *cur_param, *next_param, *end_params;
first_param = req->data + txn->req.eoh + 2;
- end_params = first_param + txn->req.hdr_content_len;
+ end_params = first_param + txn->req.body_len;
cur_param = next_param = end_params;
if (rule->rdr_len >= 1 && *rule->rdr_str == '/' &&
(txn->flags & TX_REQ_XFER_LEN) &&
- !(txn->flags & TX_REQ_TE_CHNK) && !txn->req.hdr_content_len &&
+ !(txn->flags & TX_REQ_TE_CHNK) && !txn->req.body_len &&
((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_SCL ||
(txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_KAL)) {
/* keep-alive possible */
}
if (msg->msg_state == HTTP_MSG_CHUNK_SIZE) {
- /* read the chunk size and assign it to ->hdr_content_len, then
+ /* read the chunk size and assign it to ->chunk_len, then
* set ->sov and ->lr to point to the body and switch to DATA or
* TRAILERS state.
*/
* We're waiting for at least <url_param_post_limit> bytes after msg->sov.
*/
- if (msg->hdr_content_len < limit)
- limit = msg->hdr_content_len;
+ if (msg->body_len < limit)
+ limit = msg->body_len;
if (req->l - (msg->sov - msg->som) >= limit) /* we have enough bytes now */
goto http_end;
* remaining data and to resync after end of body. It expects the msg_state to
* be between MSG_BODY and MSG_DONE (inclusive). It returns zero if it needs to
* read more data, or 1 once we can go on with next request or end the session.
- * When in MSG_DATA or MSG_TRAILERS, it will automatically forward hdr_content_len
+ * When in MSG_DATA or MSG_TRAILERS, it will automatically forward chunk_len
* bytes of pending data + the headers if not already done (between som and sov).
* It eventually adjusts som to match sov after the data in between have been sent.
*/
while (1) {
http_silent_debug(__LINE__, s);
/* we may have some data pending */
- if (msg->hdr_content_len || msg->som != msg->sov) {
+ if (msg->chunk_len || msg->som != msg->sov) {
int bytes = msg->sov - msg->som;
if (bytes < 0) /* sov may have wrapped at the end */
bytes += req->size;
- buffer_forward(req, bytes + msg->hdr_content_len);
- msg->hdr_content_len = 0; /* don't forward that again */
+ buffer_forward(req, bytes + msg->chunk_len);
+ msg->chunk_len = 0; /* don't forward that again */
msg->som = msg->sov;
}
msg->msg_state = HTTP_MSG_DONE;
}
else if (msg->msg_state == HTTP_MSG_CHUNK_SIZE) {
- /* read the chunk size and assign it to ->hdr_content_len, then
+ /* read the chunk size and assign it to ->chunk_len, then
* set ->sov and ->lr to point to the body and switch to DATA or
* TRAILERS state.
*/
*/
/* Skip parsing if no content length is possible. The response flags
- * remain 0 as well as the hdr_content_len, which may or may not mirror
+ * remain 0 as well as the chunk_len, which may or may not mirror
* the real header value, and we note that we know the response's length.
* FIXME: should we parse anyway and return an error on chunked encoding ?
*/
if (cl < 0)
goto hdr_response_bad;
- if ((txn->flags & TX_RES_CNT_LEN) && (msg->hdr_content_len != cl))
+ if ((txn->flags & TX_RES_CNT_LEN) && (msg->chunk_len != cl))
goto hdr_response_bad; /* already specified, was different */
txn->flags |= TX_RES_CNT_LEN | TX_RES_XFER_LEN;
- msg->hdr_content_len = cl;
+ msg->body_len = msg->chunk_len = cl;
}
/* FIXME: we should also implement the multipart/byterange method.
* remaining data and to resync after end of body. It expects the msg_state to
* be between MSG_BODY and MSG_DONE (inclusive). It returns zero if it needs to
* read more data, or 1 once we can go on with next request or end the session.
- * When in MSG_DATA or MSG_TRAILERS, it will automatically forward hdr_content_len
+ * When in MSG_DATA or MSG_TRAILERS, it will automatically forward chunk_len
* bytes of pending data + the headers if not already done (between som and sov).
* It eventually adjusts som to match sov after the data in between have been sent.
*/
while (1) {
http_silent_debug(__LINE__, s);
/* we may have some data pending */
- if (msg->hdr_content_len || msg->som != msg->sov) {
+ if (msg->chunk_len || msg->som != msg->sov) {
int bytes = msg->sov - msg->som;
if (bytes < 0) /* sov may have wrapped at the end */
bytes += res->size;
- buffer_forward(res, bytes + msg->hdr_content_len);
- msg->hdr_content_len = 0; /* don't forward that again */
+ buffer_forward(res, bytes + msg->chunk_len);
+ msg->chunk_len = 0; /* don't forward that again */
msg->som = msg->sov;
}
msg->msg_state = HTTP_MSG_DONE;
}
else if (msg->msg_state == HTTP_MSG_CHUNK_SIZE) {
- /* read the chunk size and assign it to ->hdr_content_len, then
+ /* read the chunk size and assign it to ->chunk_len, then
* set ->sov to point to the body and switch to DATA or TRAILERS state.
*/
int ret = http_parse_chunk_size(res, msg);
goto return_bad_res;
/* forward the chunk size as well as any pending data */
- if (msg->hdr_content_len || msg->som != msg->sov) {
+ if (msg->chunk_len || msg->som != msg->sov) {
int bytes = msg->sov - msg->som;
if (bytes < 0) /* sov may have wrapped at the end */
bytes += res->size;
- buffer_forward(res, msg->sov - msg->som + msg->hdr_content_len);
- msg->hdr_content_len = 0; /* don't forward that again */
+ buffer_forward(res, msg->sov - msg->som + msg->chunk_len);
+ msg->chunk_len = 0; /* don't forward that again */
msg->som = msg->sov;
}
txn->req.som = txn->req.eoh = 0; /* relative to the buffer */
txn->rsp.sol = txn->rsp.eol = NULL;
txn->rsp.som = txn->rsp.eoh = 0; /* relative to the buffer */
- txn->req.hdr_content_len = 0LL;
- txn->rsp.hdr_content_len = 0LL;
+ txn->req.chunk_len = 0LL;
+ txn->req.body_len = 0LL;
+ txn->rsp.chunk_len = 0LL;
+ txn->rsp.body_len = 0LL;
txn->req.msg_state = HTTP_MSG_RQBEFORE; /* at the very beginning of the request */
txn->rsp.msg_state = HTTP_MSG_RPBEFORE; /* at the very beginning of the response */