MEDIUM: conn-stream: Pre-allocate endpoint to create CS from muxes and applets

It is a transient commit to prepare next changes. Now, when a conn-stream is
created from an applet or a multiplexer, an endpoint is always provided. In
addition, the API to create a conn-stream was specialized to have one
function per type.

The next step will be to share the endpoint structure.
diff --git a/src/mux_h1.c b/src/mux_h1.c
index 669b411..9ebd0ff 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -717,9 +717,9 @@
 {
 	struct h1c *h1c = h1s->h1c;
 	struct cs_endpoint *endp;
-	struct conn_stream *cs;
 
 	TRACE_ENTER(H1_EV_STRM_NEW, h1c->conn, h1s);
+
 	endp = cs_endpoint_new();
 	if (!endp) {
 		TRACE_ERROR("CS endp allocation failure", H1_EV_STRM_NEW|H1_EV_STRM_END|H1_EV_STRM_ERR, h1c->conn, h1s);
@@ -727,36 +727,27 @@
 	}
 	endp->target = h1s;
 	endp->ctx = h1c->conn;
+	endp->flags |= CS_EP_T_MUX;
 	if (h1s->flags & H1S_F_NOT_FIRST)
 		endp->flags |= CS_EP_NOT_FIRST;
 	if (h1s->req.flags & H1_MF_UPG_WEBSOCKET)
 		endp->flags |= CS_EP_WEBSOCKET;
 
-	cs = cs_new(endp);
-	if (!cs) {
+	h1s->cs = cs_new_from_mux(endp, h1c->conn->owner, input);
+	if (!h1s->cs) {
 		TRACE_ERROR("CS allocation failure", H1_EV_STRM_NEW|H1_EV_STRM_END|H1_EV_STRM_ERR, h1c->conn, h1s);
 		cs_endpoint_free(endp);
 		goto err;
 	}
-	cs_attach_endp_mux(cs, h1s, h1c->conn);
-	h1s->cs = cs;
-
-	if (!stream_new(h1c->conn->owner, cs, input)) {
-		TRACE_DEVEL("leaving on stream creation failure", H1_EV_STRM_NEW|H1_EV_STRM_END|H1_EV_STRM_ERR, h1c->conn, h1s);
-		goto err_cs;
-	}
 
 	HA_ATOMIC_INC(&h1c->px_counters->open_streams);
 	HA_ATOMIC_INC(&h1c->px_counters->total_streams);
 
 	h1c->flags = (h1c->flags & ~H1C_F_ST_EMBRYONIC) | H1C_F_ST_ATTACHED | H1C_F_ST_READY;
 	TRACE_LEAVE(H1_EV_STRM_NEW, h1c->conn, h1s);
-	return cs;
+	return h1s->cs;
 
-  err_cs:
-	cs_free(cs);
   err:
-	h1s->cs = NULL;
 	TRACE_DEVEL("leaving on error", H1_EV_STRM_NEW|H1_EV_STRM_ERR, h1c->conn, h1s);
 	return NULL;
 }
@@ -856,7 +847,7 @@
 	if (!h1s)
 		goto fail;
 
-	cs_attach_endp_mux(cs, h1s, h1c->conn);
+	cs_attach_mux(cs, h1s, h1c->conn);
 	h1s->flags |= H1S_F_RX_BLK;
 	h1s->cs = cs;
 	h1s->sess = sess;
@@ -1004,7 +995,7 @@
 		if (!h1c_frt_stream_new(h1c))
 			goto fail;
 		h1c->h1s->cs = cs;
-		cs_attach_endp_mux(cs, h1c->h1s, conn);
+		cs_attach_mux(cs, h1c->h1s, conn);
 
 		/* Attach the CS but Not ready yet */
 		h1c->flags = (h1c->flags & ~H1C_F_ST_EMBRYONIC) | H1C_F_ST_ATTACHED;