mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-26 04:48:03 +00:00
MINOR: h1: make h1_skip_chunk_crlf() not depend on b_ptr() anymore
It now takes offsets relative to the buffer's head. It's up to the callers to add this offset which corresponds to the buffer's output size.
This commit is contained in:
parent
5dd17353d5
commit
c0973c6742
@ -143,16 +143,16 @@ static inline const char *h1_msg_state_str(enum h1_state msg_state)
|
|||||||
/* This function may be called only in HTTP_MSG_CHUNK_CRLF. It reads the CRLF or
|
/* 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. The caller should adjust msg->next
|
* a possible LF alone at the end of a chunk. The caller should adjust msg->next
|
||||||
* in order to include this part into the next forwarding phase. Note that the
|
* 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 returns
|
* caller must ensure that head+start points to the first byte to parse. It
|
||||||
* the number of bytes parsed on success, so the caller can set msg_state to
|
* returns the number of bytes parsed on success, so the caller can set msg_state
|
||||||
* HTTP_MSG_CHUNK_SIZE. If not enough data are available, the function does not
|
* to HTTP_MSG_CHUNK_SIZE. If not enough data are available, the function does not
|
||||||
* change anything and returns zero. Otherwise it returns a negative value
|
* change anything and returns zero. Otherwise it returns a negative value
|
||||||
* indicating the error positionn relative to <stop>. Note: this function is
|
* indicating the error positionn relative to <stop>. Note: this function is
|
||||||
* designed to parse wrapped CRLF at the end of the buffer.
|
* designed to parse wrapped CRLF at the end of the buffer.
|
||||||
*/
|
*/
|
||||||
static inline int h1_skip_chunk_crlf(const struct buffer *buf, int start, int stop)
|
static inline int h1_skip_chunk_crlf(const struct buffer *buf, int start, int stop)
|
||||||
{
|
{
|
||||||
const char *ptr = b_ptr(buf, start);
|
const char *ptr = b_peek(buf, start);
|
||||||
int bytes = 1;
|
int bytes = 1;
|
||||||
|
|
||||||
/* NB: we'll check data availabilty at the end. It's not a
|
/* NB: we'll check data availabilty at the end. It's not a
|
||||||
@ -162,15 +162,15 @@ static inline int h1_skip_chunk_crlf(const struct buffer *buf, int start, int st
|
|||||||
if (*ptr == '\r') {
|
if (*ptr == '\r') {
|
||||||
bytes++;
|
bytes++;
|
||||||
ptr++;
|
ptr++;
|
||||||
if (ptr >= buf->data + buf->size)
|
if (ptr >= b_wrap(buf))
|
||||||
ptr = buf->data;
|
ptr = buf->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bytes > stop - start)
|
if (bytes > stop - start)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (*ptr != '\n')
|
if (*ptr != '\n') // negative position to stop
|
||||||
return -buffer_count(buf, ptr, b_ptr(buf, stop));
|
return ptr - __b_peek(buf, stop);
|
||||||
|
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
@ -3179,8 +3179,7 @@ static size_t h2s_frt_make_resp_data(struct h2s *h2s, struct buffer *buf, size_t
|
|||||||
break;
|
break;
|
||||||
default: /* te:chunked : parse chunks */
|
default: /* te:chunked : parse chunks */
|
||||||
if (h1m->state == HTTP_MSG_CHUNK_CRLF) {
|
if (h1m->state == HTTP_MSG_CHUNK_CRLF) {
|
||||||
// FIXME: this one still uses the old buffer API and ignores <ofs>
|
ret = h1_skip_chunk_crlf(buf, ofs, ofs + max);
|
||||||
ret = h1_skip_chunk_crlf(buf, -max, 0);
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
|
@ -6353,7 +6353,7 @@ http_msg_forward_chunked_body(struct stream *s, struct http_msg *msg)
|
|||||||
|
|
||||||
case HTTP_MSG_CHUNK_CRLF:
|
case HTTP_MSG_CHUNK_CRLF:
|
||||||
/* we want the CRLF after the data */
|
/* we want the CRLF after the data */
|
||||||
ret = h1_skip_chunk_crlf(chn->buf, msg->next, chn->buf->i);
|
ret = h1_skip_chunk_crlf(chn->buf, co_data(chn) + msg->next, b_data(chn->buf));
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
goto missing_data_or_waiting;
|
goto missing_data_or_waiting;
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user