/* Return the amount of bytes that need to be rewound before buf->p to access
* the current message's headers. The purpose is to be able to easily fetch
* the message's beginning before headers are forwarded, as well as after.
+ * The principle is that msg->eoh and msg->eol are immutable while msg->sov
+ * equals the sum of the two before forwarding and is zero after forwarding,
+ * so the difference cancels the rewinding.
*/
static inline int http_hdr_rewind(const struct http_msg *msg)
{
- return msg->chn->buf->o;
+ return msg->eoh + msg->eol - msg->sov;
}
/* Return the amount of bytes that need to be rewound before buf->p to access
{
int len;
- len = buffer_len(msg->chn->buf) - msg->sov - msg->sol;
+ len = msg->chn->buf->i - msg->sov - msg->sol;
if (len > msg->body_len)
len = msg->body_len;
return len;
msg->chunk_len += msg->next;
msg->chunk_len -= channel_forward(req, msg->chunk_len);
msg->next = 0;
+ msg->sov = 0;
}
if (msg->msg_state == HTTP_MSG_DATA) {
*/
channel_forward(res, msg->sov);
msg->next = 0;
+ msg->sov = 0;
if (msg->flags & HTTP_MSGF_TE_CHNK)
msg->msg_state = HTTP_MSG_CHUNK_SIZE;
msg->chunk_len += msg->next;
msg->chunk_len -= channel_forward(res, msg->chunk_len);
msg->next = 0;
+ msg->sov = 0;
}
}
/* forwarding trailers */
channel_forward(res, msg->next);
msg->next = 0;
+ msg->sov = 0;
}
/* we're in HTTP_MSG_DONE now, but we might still have
* some data pending, so let's loop over once.
msg->chunk_len += msg->next;
msg->chunk_len -= channel_forward(res, msg->chunk_len);
msg->next = 0;
+ msg->sov = 0;
}
}