MINOR: stream: Use stream type instead of proxy mode when appropriate

We now use the stream instead of the proxy to know if we are processing HTTP
data or not. If the stream is an HTX stream, it means we are dealing with
HTTP data. It is more accurate than the proxy mode because when an HTTP
upgrade is performed, the proxy is not changed and only the stream may be
used.

Note that it was not a problem to rely on the proxy because HTTP upgrades
may only happen when an HTTP backend was set. But, we will add the support
of HTTP upgrades on the frontend side, after te tcp-request rules
evaluation.  In this context, we cannot rely on the proxy mode.
diff --git a/src/backend.c b/src/backend.c
index 96ff656..62be510 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -1340,7 +1340,7 @@
 	si_release_endpoint(&s->si[1]);
 
 	/* do not reuse if mode is not http */
-	if (s->be->mode != PR_MODE_HTTP)
+	if (!IS_HTX_STRM(s))
 		goto skip_reuse;
 
 	/* first, search for a matching connection in the session's idle conns */
@@ -1576,7 +1576,7 @@
 #if defined(USE_OPENSSL) && defined(TLSEXT_TYPE_application_layer_protocol_negotiation)
 		if (!srv ||
 		    (srv->use_ssl != 1 || (!(srv->ssl_ctx.alpn_str) && !(srv->ssl_ctx.npn_str)) ||
-		     srv->mux_proto || s->be->mode != PR_MODE_HTTP))
+		     srv->mux_proto || !IS_HTX_STRM(s)))
 #endif
 			init_mux = 1;
 
@@ -1656,7 +1656,7 @@
 			conn_full_close(srv_conn);
 			return SF_ERR_INTERNAL;
 		}
-		if (s->be->mode == PR_MODE_HTTP) {
+		if (IS_HTX_STRM(s)) {
 			/* If we're doing http-reuse always, and the connection
 			 * is not private with available streams (an http2
 			 * connection), add it to the available list, so that
diff --git a/src/hlua.c b/src/hlua.c
index c162c84..a61809e 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -2952,7 +2952,7 @@
 
 	chn = MAY_LJMP(hlua_checkchannel(L, 1));
 
-	if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
+	if (IS_HTX_STRM(chn_strm(chn))) {
 		lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
 		WILL_LJMP(lua_error(L));
 	}
@@ -2982,7 +2982,7 @@
 
 	chn = MAY_LJMP(hlua_checkchannel(L, 1));
 
-	if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
+	if (IS_HTX_STRM(chn_strm(chn))) {
 		lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
 		WILL_LJMP(lua_error(L));
 	}
@@ -3024,7 +3024,7 @@
 
 	chn = MAY_LJMP(hlua_checkchannel(L, 1));
 
-	if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
+	if (IS_HTX_STRM(chn_strm(chn))) {
 		lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
 		WILL_LJMP(lua_error(L));
 	}
@@ -3074,7 +3074,7 @@
 	int ret;
 	int max;
 
-	if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
+	if (IS_HTX_STRM(chn_strm(chn))) {
 		lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
 		WILL_LJMP(lua_error(L));
 	}
@@ -3148,7 +3148,7 @@
 	chn = MAY_LJMP(hlua_checkchannel(L, 1));
 	lua_pushinteger(L, 0);
 
-	if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
+	if (IS_HTX_STRM(chn_strm(chn))) {
 		lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
 		WILL_LJMP(lua_error(L));
 	}
@@ -3179,7 +3179,7 @@
 		return 1;
 	}
 
-	if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
+	if (IS_HTX_STRM(chn_strm(chn))) {
 		lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
 		WILL_LJMP(lua_error(L));
 	}
@@ -3290,7 +3290,7 @@
 
 	chn = MAY_LJMP(hlua_checkchannel(L, 1));
 
-	if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
+	if (IS_HTX_STRM(chn_strm(chn))) {
 		lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
 		WILL_LJMP(lua_error(L));
 	}
@@ -5505,7 +5505,7 @@
 
 	/* Creates the HTTP object is the current proxy allows http. */
 	lua_pushstring(L, "http");
-	if (p->mode == PR_MODE_HTTP) {
+	if (IS_HTX_STRM(s)) {
 		if (!hlua_http_new(L, htxn))
 			return 0;
 	}
diff --git a/src/stream.c b/src/stream.c
index 58fd571..c1ba905 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -918,7 +918,7 @@
 	if (objt_server(s->target))
 		health_adjust(objt_server(s->target), HANA_STATUS_L4_OK);
 
-	if (s->be->mode == PR_MODE_TCP) { /* let's allow immediate data connection in this case */
+	if (!IS_HTX_STRM(s)) { /* let's allow immediate data connection in this case */
 		/* if the user wants to log as soon as possible, without counting
 		 * bytes from the server, then this is the right moment. */
 		if (!LIST_ISEMPTY(&strm_fe(s)->logformat) && !(s->logs.logwait & LW_BYTES)) {
@@ -935,7 +935,7 @@
 
 	/* Be sure to filter response headers if the backend is an HTTP proxy
 	 * and if there are filters attached to the stream. */
-	if (s->be->mode == PR_MODE_HTTP && HAS_FILTERS(s))
+	if (IS_HTX_STRM(s) && HAS_FILTERS(s))
 		rep->analysers |= AN_RES_FLT_HTTP_HDRS;
 
 	si_rx_endp_more(si);