}
/* Parse the chunk size at msg->next. Once done, it adjusts ->next to point to the
- * first byte of body, and increments msg->sov by the number of bytes parsed,
- * so that we know we can forward between ->sol and ->sov.
+ * first byte of body, and increments msg->sov by the number of bytes parsed.
+ * so that we know we can forward ->sov bytes.
* Return >0 on success, 0 when some data is missing, <0 on error.
* Note: this function is designed to parse wrapped CRLF at the end of the buffer.
*/
* change anything except maybe msg->next and msg->sov. Note that the message
* must already be in HTTP_MSG_TRAILERS state before calling this function,
* which implies that all non-trailers data have already been scheduled for
- * forwarding, and that the difference between msg->sol and msg->sov exactly
- * matches the length of trailers already parsed and not forwarded. It is also
- * important to note that this function is designed to be able to parse wrapped
- * headers at end of buffer.
+ * forwarding, and that msg->sov exactly matches the length of trailers already
+ * parsed and not forwarded. It is also important to note that this function is
+ * designed to be able to parse wrapped headers at end of buffer.
*/
static int http_forward_trailers(struct http_msg *msg)
{
/* This function may be called only in HTTP_MSG_CHUNK_CRLF. It reads the CRLF or
* a possible LF alone at the end of a chunk. It automatically adjusts msg->sov,
- * ->sol, ->next in order to include this part into the next forwarding phase.
+ * and ->next in order to include this part into the next forwarding phase.
* Note that the caller must ensure that ->p points to the first byte to parse.
* It also sets msg_state to HTTP_MSG_CHUNK_SIZE and returns >0 on success. If
* not enough data are available, the function does not change anything and
ptr++;
if (unlikely(ptr >= buf->data + buf->size))
ptr = buf->data;
- /* prepare the CRLF to be forwarded (between ->sol and ->sov) */
- msg->sol = 0;
+ /* prepare the CRLF to be forwarded (->sov) */
msg->sov = msg->next = bytes;
msg->msg_state = HTTP_MSG_CHUNK_SIZE;
return 1;
* msg->next = first non-visited byte
*
* At end of parsing, we may perform a capture of the error (if any), and
- * we will set a few fields (msg->sol, txn->meth, sn->flags/SN_REDIRECTABLE).
+ * we will set a few fields (txn->meth, sn->flags/SN_REDIRECTABLE).
* We also check for monitor-uri, logging, HTTP/0.9 to 1.0 conversion, and
* finally headers capture.
*/
host = "";
hostlen = 0;
ctx.idx = 0;
- if (http_find_header2("Host", 4, txn->req.chn->buf->p + txn->req.sol, &txn->hdr_idx, &ctx)) {
+ if (http_find_header2("Host", 4, txn->req.chn->buf->p, &txn->hdr_idx, &ctx)) {
host = ctx.line + ctx.val;
hostlen = ctx.vlen;
}
}
/* we have msg->sov which points to the first byte of message body.
- * req->buf->p still points to the beginning of the message and msg->sol
- * is still null. We must save the body in msg->next because it
- * survives buffer re-alignments.
+ * req->buf->p still points to the beginning of the message. We
+ * must save the body in msg->next because it survives buffer
+ * re-alignments.
*/
msg->next = msg->sov;
if (old_o) {
/* The request was already skipped, let's restore it */
b_rew(chn->buf, old_o);
+ txn->req.next += old_o;
+ txn->req.sov += old_o;
}
old_i = chn->buf->i;
if (old_o) {
/* If this was a forwarded request, we must readjust the amount of
* data to be forwarded in order to take into account the size
- * variations. Note that if the request was already scheduled for
- * forwarding, it had its req->sol pointing to the body, which
- * must then be updated too.
+ * variations. Note that the current state is >= HTTP_MSG_BODY,
+ * so we don't have to adjust ->sol.
*/
- txn->req.sol += chn->buf->i - old_i;
- b_adv(chn->buf, old_o + chn->buf->i - old_i);
+ old_o += chn->buf->i - old_i;
+ b_adv(chn->buf, old_o);
+ txn->req.next -= old_o;
+ txn->req.sov -= old_o;
}
return 0;
if (msg->msg_state < HTTP_MSG_CHUNK_SIZE) {
/* we have msg->sov which points to the first byte of message body.
- * req->buf->p still points to the beginning of the message and msg->sol
- * is still null. We must save the body in msg->next because it
- * survives buffer re-alignments.
+ * req->buf->p still points to the beginning of the message. We
+ * must save the body in msg->next because it survives buffer
+ * re-alignments.
*/
msg->next = msg->sov;
channel_auto_close(req);
while (1) {
- unsigned int bytes;
-
http_silent_debug(__LINE__, s);
- /* we may have some data pending between sol and sov */
- bytes = msg->sov - msg->sol;
- if (msg->chunk_len || bytes) {
- msg->sol = msg->sov;
- msg->next -= bytes; /* will be forwarded */
- msg->chunk_len += bytes;
+
+ /* we may have some pending data starting at req->buf->p */
+ if (msg->chunk_len || msg->sov) {
+ msg->chunk_len += msg->sov;
msg->chunk_len -= channel_forward(req, msg->chunk_len);
+ msg->next -= msg->sov;
+ msg->sov = 0;
}
if (msg->msg_state == HTTP_MSG_DATA) {
{
struct http_txn *txn = &s->txn;
struct http_msg *msg = &s->txn.rsp;
- unsigned int bytes;
static struct buffer *tmpbuf = NULL;
int compressing = 0;
int consumed_data = 0;
if (msg->msg_state < HTTP_MSG_CHUNK_SIZE) {
/* we have msg->sov which points to the first byte of message body.
- * rep->buf.p still points to the beginning of the message and msg->sol
- * is still null. We forward the headers, we don't need them.
+ * res->buf.p still points to the beginning of the message. We
+ * forward the headers, we don't need them.
*/
channel_forward(res, msg->sov);
msg->next = 0;
while (1) {
http_silent_debug(__LINE__, s);
- /* we may have some data pending between sol and sov */
+
+ /* we may have some pending data starting at res->buf->p */
if (s->comp_algo == NULL) {
- bytes = msg->sov - msg->sol;
- if (msg->chunk_len || bytes) {
- msg->sol = msg->sov;
- msg->next -= bytes; /* will be forwarded */
- msg->chunk_len += bytes;
+ if (msg->chunk_len || msg->sov) {
+ msg->chunk_len += msg->sov;
msg->chunk_len -= channel_forward(res, msg->chunk_len);
+ msg->next -= msg->sov;
+ msg->sov = 0;
}
}
b_adv(res->buf, msg->next);
msg->next = 0;
msg->sov = 0;
- msg->sol = 0;
}
/* we're in MSG_CHUNK_SIZE now, fall through */
b_adv(res->buf, msg->next);
msg->next = 0;
msg->sov = 0;
- msg->sol = 0;
} else {
if (consumed_data) {
http_compression_buffer_end(s, &res->buf, &tmpbuf, 1);
if (!s->req->analysers)
goto return_bad_res;
- /* forward any data pending between sol and sov */
+ /* forward any pending data starting at res->buf->p */
if (s->comp_algo == NULL) {
- bytes = msg->sov - msg->sol;
- if (msg->chunk_len || bytes) {
- msg->sol = msg->sov;
- msg->next -= bytes; /* will be forwarded */
- msg->chunk_len += bytes;
+ if (msg->chunk_len || msg->sov) {
+ msg->chunk_len += msg->sov;
msg->chunk_len -= channel_forward(res, msg->chunk_len);
+ msg->next -= msg->sov;
+ msg->sov = 0;
}
}
CHECK_HTTP_MESSAGE_FIRST();
ctx.idx = 0;
- if (!http_find_header2("Host", 4, txn->req.chn->buf->p + txn->req.sol, &txn->hdr_idx, &ctx) ||
- !ctx.vlen)
+ if (!http_find_header2("Host", 4, txn->req.chn->buf->p, &txn->hdr_idx, &ctx) || !ctx.vlen)
return smp_fetch_path(px, l4, l7, opt, args, smp, kw);
/* OK we have the header value in ctx.line+ctx.val for ctx.vlen bytes */
smp->data.str.len = ctx.vlen;
/* now retrieve the path */
- end = txn->req.chn->buf->p + txn->req.sol + txn->req.sl.rq.u + txn->req.sl.rq.u_l;
+ end = txn->req.chn->buf->p + txn->req.sl.rq.u + txn->req.sl.rq.u_l;
beg = http_get_path(txn);
if (!beg)
beg = end;
CHECK_HTTP_MESSAGE_FIRST();
ctx.idx = 0;
- if (http_find_header2("Host", 4, txn->req.chn->buf->p + txn->req.sol, &txn->hdr_idx, &ctx)) {
+ if (http_find_header2("Host", 4, txn->req.chn->buf->p, &txn->hdr_idx, &ctx)) {
/* OK we have the header value in ctx.line+ctx.val for ctx.vlen bytes */
ptr = ctx.line + ctx.val;
len = ctx.vlen;
}
/* now retrieve the path */
- end = txn->req.chn->buf->p + txn->req.sol + txn->req.sl.rq.u + txn->req.sl.rq.u_l;
+ end = txn->req.chn->buf->p + txn->req.sl.rq.u + txn->req.sl.rq.u_l;
beg = http_get_path(txn);
if (!beg)
beg = end;
CHECK_HTTP_MESSAGE_FIRST();
ctx.idx = 0;
- if (http_find_header2("Host", 4, txn->req.chn->buf->p + txn->req.sol, &txn->hdr_idx, &ctx)) {
+ if (http_find_header2("Host", 4, txn->req.chn->buf->p, &txn->hdr_idx, &ctx)) {
/* OK we have the header value in ctx.line+ctx.val for ctx.vlen bytes */
ptr = ctx.line + ctx.val;
len = ctx.vlen;
}
/* now retrieve the path */
- end = txn->req.chn->buf->p + txn->req.sol + txn->req.sl.rq.u + txn->req.sl.rq.u_l;
+ end = txn->req.chn->buf->p + txn->req.sl.rq.u + txn->req.sl.rq.u_l;
beg = http_get_path(txn);
if (!beg)
beg = end;