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.
diff --git a/include/proto/h1.h b/include/proto/h1.h
index 05d1877..d8b90cb 100644
--- a/include/proto/h1.h
+++ b/include/proto/h1.h
@@ -143,16 +143,16 @@
/* 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
* 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
- * the number of bytes parsed on success, so the caller can set msg_state to
- * HTTP_MSG_CHUNK_SIZE. If not enough data are available, the function does not
+ * caller must ensure that head+start points to the first byte to parse. It
+ * returns the number of bytes parsed on success, so the caller can set msg_state
+ * 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
* indicating the error positionn relative to <stop>. Note: this function is
* 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)
{
- const char *ptr = b_ptr(buf, start);
+ const char *ptr = b_peek(buf, start);
int bytes = 1;
/* NB: we'll check data availabilty at the end. It's not a
@@ -162,15 +162,15 @@
if (*ptr == '\r') {
bytes++;
ptr++;
- if (ptr >= buf->data + buf->size)
+ if (ptr >= b_wrap(buf))
ptr = buf->data;
}
if (bytes > stop - start)
return 0;
- if (*ptr != '\n')
- return -buffer_count(buf, ptr, b_ptr(buf, stop));
+ if (*ptr != '\n') // negative position to stop
+ return ptr - __b_peek(buf, stop);
return bytes;
}