BUG/MINOR: contrib/prometheus-exporter: Fix applet accordingly to recent changes

Since the flag EOI was added on channels, some hidden bugs in the prometheus
exporter now leads to error. the visible effect is that responses are
truncated.

So first of all, channel_add_input() must be called when the response headers
and the EOM block are added. To be sure to correctly update the response channel
(especially to_forward value). Then the request must really be fully
consumed. And finally, the return clause in the switch has been replaced by a
break. It was totally wrong to skip the end of the function in the states
PROMEX_DONE and PROMEX_ERROR. (Note that PROMEX_ERROR was never used, so it was
replaced by PROMEX_END just to ease reading the code).

No need to backport this patch, the Prometheus exporter does not exist in early
versions.
diff --git a/contrib/prometheus-exporter/service-prometheus.c b/contrib/prometheus-exporter/service-prometheus.c
index d61d94f..ed71acf 100644
--- a/contrib/prometheus-exporter/service-prometheus.c
+++ b/contrib/prometheus-exporter/service-prometheus.c
@@ -46,7 +46,7 @@
         PROMEX_ST_HEAD,      /* send headers before dump */
         PROMEX_ST_DUMP,      /* dumping stats */
         PROMEX_ST_DONE,      /* finished */
-        PROMEX_ST_ERROR,     /* unrecoverable error occurred */
+        PROMEX_ST_END,       /* treatment terminated */
 };
 
 /* Prometheus exporter dumper states (appctx->st1) */
@@ -2125,6 +2125,7 @@
  * full. */
 static int promex_send_headers(struct appctx *appctx, struct stream_interface *si, struct htx *htx)
 {
+	struct channel *chn = si_ic(appctx->owner);
 	struct htx_sl *sl;
 	unsigned int flags;
 
@@ -2140,6 +2141,7 @@
 	    !htx_add_endof(htx, HTX_BLK_EOH))
 		goto full;
 
+	channel_add_input(chn, htx->data);
 	return 1;
   full:
 	htx_reset(htx);
@@ -2206,33 +2208,25 @@
 				si_rx_room_blk(si);
 				goto out;
 			}
-			res->flags |= CF_READ_NULL;
-
-			/* eat the whole request */
-			req_htx = htxbuf(&req->buf);
-			htx_reset(req_htx);
-			htx_to_buf(req_htx, &req->buf);
-			co_set_data(req, 0);
-
-			/* Set SI flags */
-			if (!(s->flags & SF_ERR_MASK))      // this is not really an error but it is
-				s->flags |= SF_ERR_LOCAL;   // to mark that it comes from the proxy
-			if (!(s->flags & SF_FINST_MASK))
-				s->flags |= SF_FINST_R;
-
-			si_shutr(si);
+			channel_add_input(res, 1);
+			appctx->st0 = PROMEX_ST_END;
+			/* fall through */
 
-		case PROMEX_ST_ERROR:
-			return;
+		case PROMEX_ST_END:
+			if (!(res->flags & CF_SHUTR)) {
+				res->flags |= CF_READ_NULL;
+				si_shutr(si);
+			}
 	}
 
-	if ((res->flags & CF_SHUTR) && (si->state == SI_ST_EST))
-		si_shutw(si);
-
   out:
 	htx_to_buf(res_htx, &res->buf);
-	if (!channel_is_empty(res))
-		si_stop_get(si);
+
+	/* eat the whole request */
+	if (co_data(req)) {
+		req_htx = htx_from_buf(&req->buf);
+		co_htx_skip(req, req_htx, co_data(req));
+	}
 	return;
 
   error: