BUG/MEDIUM: h2: don't switch the state to HREM before end of DATA frame

We used to switch the stream's state to HREM when seeing and ES bit on
the DATA frame before actually being able to process that frame, possibly
resulting in the DATA frame being processed after the stream was seen as
half-closed and possibly being rejected. The state must not change before
the frame is really processed.

Also fixes a harmless typo in the flag name which should have DATA and
not HEADERS in its name (but all values are equal).

Must be backported to 1.8.
diff --git a/src/mux_h2.c b/src/mux_h2.c
index 672bc8f..7731c94 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -1656,12 +1656,6 @@
 		goto strm_err;
 	}
 
-	/* last frame */
-	if (h2c->dff & H2_F_HEADERS_END_STREAM) {
-		h2s->st = H2_SS_HREM;
-		h2s->flags |= H2_SF_ES_RCVD;
-	}
-
 	/* call the upper layers to process the frame, then let the upper layer
 	 * notify the stream about any change.
 	 */
@@ -1692,6 +1686,13 @@
 	if (h2c->st0 == H2_CS_FRAME_P)
 		return 0;
 
+
+	/* last frame */
+	if (h2c->dff & H2_F_DATA_END_STREAM) {
+		h2s->st = H2_SS_HREM;
+		h2s->flags |= H2_SF_ES_RCVD;
+	}
+
 	return 1;
 
  conn_err: