MINOR: htx: Replace the function http_find_stline() by http_get_stline()

Now, we only return the start-line. If not found, NULL is returned. No lookup is
performed and the HTX message is no more updated. It is now the caller
responsibility to update the position of the start-line to the right value. So
when it is not found, i.e sl_pos is set to -1, it means the last start-line has
been already processed and the next one has not been inserted yet.

It is mandatory to rely on this kind of warranty to store 1xx informational
responses and final reponse in the same HTX message.
diff --git a/include/proto/http_htx.h b/include/proto/http_htx.h
index 6028292..a134052 100644
--- a/include/proto/http_htx.h
+++ b/include/proto/http_htx.h
@@ -30,7 +30,7 @@
 
 extern struct buffer htx_err_chunks[HTTP_ERR_SIZE];
 
-struct htx_sl *http_find_stline(struct htx *htx);
+struct htx_sl *http_get_stline(struct htx *htx);
 int http_find_header(const struct htx *htx, const struct ist name, struct http_hdr_ctx *ctx, int full);
 int http_add_header(struct htx *htx, const struct ist n, const struct ist v);
 int http_replace_stline(struct htx *htx, const struct ist p1, const struct ist p2, const struct ist p3);
diff --git a/src/backend.c b/src/backend.c
index 4dff185..fc00666 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -743,7 +743,7 @@
 				else {
 					struct ist uri;
 
-					uri = htx_sl_req_uri(http_find_stline(htxbuf(&s->req.buf)));
+					uri = htx_sl_req_uri(http_get_stline(htxbuf(&s->req.buf)));
 					srv = get_server_uh(s->be, uri.ptr, uri.len, prev_srv);
 				}
 				break;
@@ -760,7 +760,7 @@
 				else {
 					struct ist uri;
 
-					uri = htx_sl_req_uri(http_find_stline(htxbuf(&s->req.buf)));
+					uri = htx_sl_req_uri(http_get_stline(htxbuf(&s->req.buf)));
 					srv = get_server_ph(s->be, uri.ptr, uri.len, prev_srv);
 				}
 
diff --git a/src/cache.c b/src/cache.c
index 7402e5e..188efea 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -1351,7 +1351,7 @@
 			return 0;
 		chunk_memcat(trash, ctx.value.ptr, ctx.value.len);
 
-		sl = http_find_stline(htx);
+		sl = http_get_stline(htx);
                 path = http_get_path(htx_sl_req_uri(sl));
                 if (!path.ptr)
                         return 0;
diff --git a/src/flt_trace.c b/src/flt_trace.c
index 3cfd842..ed159e8 100644
--- a/src/flt_trace.c
+++ b/src/flt_trace.c
@@ -414,7 +414,7 @@
 
 	if (IS_HTX_STRM(s)) {
 		struct htx *htx = htxbuf(&msg->chn->buf);
-		struct htx_sl *sl = http_find_stline(htx);
+		struct htx_sl *sl = http_get_stline(htx);
 		int32_t pos;
 
 		STRM_TRACE(conf, s, "\t%.*s %.*s %.*s",
diff --git a/src/hlua.c b/src/hlua.c
index f8e481c..72ce6ba 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -3944,7 +3944,7 @@
 	if (IS_HTX_STRM(s)) {
 		/* HTX version */
 		struct htx *htx = htxbuf(&s->req.buf);
-		struct htx_sl *sl = http_find_stline(htx);
+		struct htx_sl *sl = http_get_stline(htx);
 		struct ist path;
 		unsigned long long len = 0;
 		int32_t pos;
diff --git a/src/http_fetch.c b/src/http_fetch.c
index e16d7bf..0a5a2f9 100644
--- a/src/http_fetch.c
+++ b/src/http_fetch.c
@@ -209,7 +209,7 @@
 				return NULL;
 			}
 		}
-		sl = http_find_stline(htx);
+		sl = http_get_stline(htx);
 		if (vol && !sl) {
 			/* The start-line was already forwarded, it is too late to fetch anything */
 			return NULL;
@@ -434,7 +434,7 @@
 				/* ensure the indexes are not affected */
 				return 0;
 			}
-			sl = http_find_stline(htx);
+			sl = http_get_stline(htx);
 			smp->flags |= SMP_F_CONST;
 			smp->data.u.meth.str.area = HTX_SL_REQ_MPTR(sl);
 			smp->data.u.meth.str.data = HTX_SL_REQ_MLEN(sl);
@@ -478,7 +478,7 @@
 		if (!htx)
 			return 0;
 
-		sl = http_find_stline(htx);
+		sl = http_get_stline(htx);
 		len = HTX_SL_REQ_VLEN(sl);
 		ptr = HTX_SL_REQ_VPTR(sl);
 	}
@@ -518,7 +518,7 @@
 		if (!htx)
 			return 0;
 
-		sl = http_find_stline(htx);
+		sl = http_get_stline(htx);
 		len = HTX_SL_RES_VLEN(sl);
 		ptr = HTX_SL_RES_VPTR(sl);
 	}
@@ -559,7 +559,7 @@
 		if (!htx)
 			return 0;
 
-		sl = http_find_stline(htx);
+		sl = http_get_stline(htx);
 		len = HTX_SL_RES_CLEN(sl);
 		ptr = HTX_SL_RES_CPTR(sl);
 	}
@@ -1009,7 +1009,7 @@
 
 		if (!htx)
 			return 0;
-		sl = http_find_stline(htx);
+		sl = http_get_stline(htx);
 		smp->data.type = SMP_T_STR;
 		smp->data.u.str.area = HTX_SL_REQ_UPTR(sl);
 		smp->data.u.str.data = HTX_SL_REQ_ULEN(sl);
@@ -1041,7 +1041,7 @@
 
 		if (!htx)
 			return 0;
-		sl = http_find_stline(htx);
+		sl = http_get_stline(htx);
 		url2sa(HTX_SL_REQ_UPTR(sl), HTX_SL_REQ_ULEN(sl), &addr, NULL);
 	}
 	else {
@@ -1074,7 +1074,7 @@
 
 		if (!htx)
 			return 0;
-		sl = http_find_stline(htx);
+		sl = http_get_stline(htx);
 		url2sa(HTX_SL_REQ_UPTR(sl), HTX_SL_REQ_ULEN(sl), &addr, NULL);
 	}
 	else {
@@ -1573,7 +1573,7 @@
 		if (!htx)
 			return 0;
 
-		sl = http_find_stline(htx);
+		sl = http_get_stline(htx);
 		path = http_get_path(htx_sl_req_uri(sl));
 		if (!path.ptr)
 			return 0;
@@ -1643,7 +1643,7 @@
 		chunk_memcat(temp, ctx.value.ptr, ctx.value.len);
 
 		/* now retrieve the path */
-		sl = http_find_stline(htx);
+		sl = http_get_stline(htx);
 		path = http_get_path(htx_sl_req_uri(sl));
 		if (path.ptr) {
 			size_t len;
@@ -1728,7 +1728,7 @@
 		}
 
 		/* now retrieve the path */
-		sl = http_find_stline(htx);
+		sl = http_get_stline(htx);
 		path = http_get_path(htx_sl_req_uri(sl));
 		if (path.ptr) {
 			size_t len;
@@ -1844,7 +1844,7 @@
 		if (!htx)
 			return 0;
 
-		sl = http_find_stline(htx);
+		sl = http_get_stline(htx);
 		ptr = HTX_SL_REQ_UPTR(sl);
 		end = HTX_SL_REQ_UPTR(sl) + HTX_SL_REQ_ULEN(sl);
 	}
@@ -2523,7 +2523,7 @@
 			if (!htx)
 				return 0;
 
-			sl = http_find_stline(htx);
+			sl = http_get_stline(htx);
 			smp->ctx.a[0] = http_find_param_list(HTX_SL_REQ_UPTR(sl), HTX_SL_REQ_ULEN(sl), delim);
 			if (!smp->ctx.a[0])
 				return 0;
@@ -2701,7 +2701,7 @@
 		}
 
 		/* now retrieve the path */
-		sl = http_find_stline(htx);
+		sl = http_get_stline(htx);
 		path = http_get_path(htx_sl_req_uri(sl));
 		while (path.len > 0 && *(path.ptr) != '?') {
 			path.ptr++;
diff --git a/src/http_htx.c b/src/http_htx.c
index e6332f7..e55420c 100644
--- a/src/http_htx.c
+++ b/src/http_htx.c
@@ -20,35 +20,21 @@
 
 struct buffer htx_err_chunks[HTTP_ERR_SIZE];
 
-/* Finds the start line in the HTX message stopping at the first
- * end-of-message. It returns NULL when not found, otherwise, it returns the
- * pointer on the htx_sl structure. The HTX message may be updated if the
- * start-line is returned following a lookup.
+/* Returns the next unporocessed start line in the HTX message. It returns NULL
+ * is the start-line is undefined (sl_pos == 1). Otherwise, it returns the
+ * pointer on the htx_sl structure.
  */
-struct htx_sl *http_find_stline(struct htx *htx)
+struct htx_sl *http_get_stline(struct htx *htx)
 {
-	struct htx_sl *sl = NULL;
-	int32_t pos;
-
-	sl = htx_get_stline(htx);
-	if (sl)
-		return sl;
-
-	for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) {
-		struct htx_blk    *blk  = htx_get_blk(htx, pos);
-		enum htx_blk_type  type = htx_get_blk_type(blk);
-
-		if (type == HTX_BLK_REQ_SL || type == HTX_BLK_RES_SL) {
-			sl = htx_get_blk_ptr(htx, blk);
-			htx->sl_pos = pos;
-			break;
-		}
+	struct htx_blk *blk;
 
-		if (type == HTX_BLK_EOH || type == HTX_BLK_EOM)
-			break;
-	}
+	if (htx->sl_pos == -1)
+		return NULL;
 
-	return sl;
+	blk = htx_get_blk(htx, htx->sl_pos);
+	if (!blk)
+		return NULL;
+	return htx_get_blk_ptr(htx, blk);
 }
 
 /* Finds the first or next occurrence of header <name> in the HTX message <htx>
@@ -213,7 +199,7 @@
 int http_replace_req_meth(struct htx *htx, const struct ist meth)
 {
 	struct buffer *temp = get_trash_chunk();
-	struct htx_sl *sl = http_find_stline(htx);
+	struct htx_sl *sl = http_get_stline(htx);
 	struct ist uri, vsn;
 
 	if (!sl)
@@ -237,7 +223,7 @@
 int http_replace_req_uri(struct htx *htx, const struct ist uri)
 {
 	struct buffer *temp = get_trash_chunk();
-	struct htx_sl *sl = http_find_stline(htx);
+	struct htx_sl *sl = http_get_stline(htx);
 	struct ist meth, vsn;
 
 	if (!sl)
@@ -260,7 +246,7 @@
 int http_replace_req_path(struct htx *htx, const struct ist path)
 {
 	struct buffer *temp = get_trash_chunk();
-	struct htx_sl *sl = http_find_stline(htx);
+	struct htx_sl *sl = http_get_stline(htx);
 	struct ist meth, uri, vsn, p;
 	size_t plen = 0;
 
@@ -297,7 +283,7 @@
 int http_replace_req_query(struct htx *htx, const struct ist query)
 {
 	struct buffer *temp = get_trash_chunk();
-	struct htx_sl *sl = http_find_stline(htx);
+	struct htx_sl *sl = http_get_stline(htx);
 	struct ist meth, uri, vsn, q;
 	int offset = 1;
 
@@ -342,7 +328,7 @@
 int http_replace_res_status(struct htx *htx, const struct ist status)
 {
 	struct buffer *temp = get_trash_chunk();
-	struct htx_sl *sl = http_find_stline(htx);
+	struct htx_sl *sl = http_get_stline(htx);
 	struct ist vsn, reason;
 
 	if (!sl)
@@ -366,7 +352,7 @@
 int http_replace_res_reason(struct htx *htx, const struct ist reason)
 {
 	struct buffer *temp = get_trash_chunk();
-	struct htx_sl *sl = http_find_stline(htx);
+	struct htx_sl *sl = http_get_stline(htx);
 	struct ist vsn, status;
 
 	if (!sl)
diff --git a/src/proto_htx.c b/src/proto_htx.c
index 8838fd7..35039fc 100644
--- a/src/proto_htx.c
+++ b/src/proto_htx.c
@@ -291,7 +291,7 @@
 	txn->flags &= ~TX_WAIT_NEXT_RQ;
 	req->analyse_exp = TICK_ETERNITY;
 
-	sl = http_find_stline(htx);
+	sl = http_get_stline(htx);
 
 	/* 0: we might have to print this header in debug mode */
 	if (unlikely((global.mode & MODE_DEBUG) &&
@@ -801,7 +801,7 @@
 
 			return 0;
 		}
-		sl = http_find_stline(htx);
+		sl = http_get_stline(htx);
 		uri = htx_sl_req_uri(sl);
 		path = http_get_path(uri);
 		if (url2sa(uri.ptr, uri.len - path.len, &conn->addr.to, NULL) == -1)
@@ -1646,7 +1646,7 @@
 	 */
 
 	msg->msg_state = HTTP_MSG_BODY;
-	sl = http_find_stline(htx);
+	sl = http_get_stline(htx);
 
 	/* 0: we might have to print this header in debug mode */
 	if (unlikely((global.mode & MODE_DEBUG) &&
@@ -2414,7 +2414,7 @@
 			if (http_find_header(htx, ist("Host"), &ctx, 0))
 				host = ctx.value;
 
-			sl = http_find_stline(htx);
+			sl = http_get_stline(htx);
 			path = http_get_path(htx_sl_req_uri(sl));
 			/* build message using path */
 			if (path.ptr) {
@@ -2462,7 +2462,7 @@
 		case REDIRECT_TYPE_PREFIX: {
 			struct ist path;
 
-			sl = http_find_stline(htx);
+			sl = http_get_stline(htx);
 			path = http_get_path(htx_sl_req_uri(sl));
 			/* build message using path */
 			if (path.ptr) {
@@ -3639,11 +3639,11 @@
 
 	done = 0;
 
-	reqline->data = htx_fmt_req_line(http_find_stline(htx), reqline->area, reqline->size);
+	reqline->data = htx_fmt_req_line(http_get_stline(htx), reqline->area, reqline->size);
 
 	/* Now we have the request line between cur_ptr and cur_end */
 	if (regex_exec_match2(exp->preg, reqline->area, reqline->data, MAX_MATCH, pmatch, 0)) {
-		struct htx_sl *sl = http_find_stline(htx);
+		struct htx_sl *sl = http_get_stline(htx);
 		struct ist meth, uri, vsn;
 		int len;
 
@@ -3850,11 +3850,11 @@
 		return 0;
 
 	done = 0;
-	resline->data = htx_fmt_res_line(http_find_stline(htx), resline->area, resline->size);
+	resline->data = htx_fmt_res_line(http_get_stline(htx), resline->area, resline->size);
 
 	/* Now we have the status line between cur_ptr and cur_end */
 	if (regex_exec_match2(exp->preg, resline->area, resline->data, MAX_MATCH, pmatch, 0)) {
-		struct htx_sl *sl = http_find_stline(htx);
+		struct htx_sl *sl = http_get_stline(htx);
 		struct ist vsn, code, reason;
 		int len;
 
@@ -4847,7 +4847,7 @@
 		return 0;
 
 	htx = htxbuf(&s->req.buf);
-	sl = http_find_stline(htx);
+	sl = http_get_stline(htx);
 	uri = htx_sl_req_uri(sl);
 
 	/* check URI size */
@@ -4890,7 +4890,7 @@
 		appctx->ctx.stats.flags |= STAT_CHUNKED;
 
 	htx = htxbuf(&req->buf);
-	sl = http_find_stline(htx);
+	sl = http_get_stline(htx);
 	lookup = HTX_SL_REQ_UPTR(sl) + uri_auth->uri_len;
 	end = HTX_SL_REQ_UPTR(sl) + HTX_SL_REQ_ULEN(sl);
 
@@ -5043,7 +5043,7 @@
 
 	/* 2: add the request Path */
 	htx = htxbuf(&req->buf);
-	sl = http_find_stline(htx);
+	sl = http_get_stline(htx);
 	path = http_get_path(htx_sl_req_uri(sl));
 	if (!path.ptr)
 		return;
diff --git a/src/stats.c b/src/stats.c
index de7f856..7d9a8a3 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -277,7 +277,7 @@
 	if (IS_HTX_STRM(si_strm(si))) {
 		struct channel *req = si_oc(si);
 		struct htx *htx = htxbuf(&req->buf);
-		struct ist uri = htx_sl_req_uri(http_find_stline(htx));
+		struct ist uri = htx_sl_req_uri(http_get_stline(htx));
 
 		p = uri.ptr;
 	}
diff --git a/src/stream_interface.c b/src/stream_interface.c
index 071a765..b12d50b 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -1305,7 +1305,7 @@
 
 			htx = htxbuf(&ic->buf);
 			if (htx) {
-				sl = http_find_stline(htx);
+				sl = http_get_stline(htx);
 				if (sl && l7_status_match(si_strm(si)->be,
 				    sl->info.res.status)) {
 					/* If we got a status for which we would