Don't use switch for single conditional http2

This code was copied from one of the nghttp2 examples, and makes things
more complicated than they should be.  We only handle one case here, so
a pattern of returning early is easier.

Also, this resolves a possible clang-tidy bugprone warning (that we
don't yet enable).

Tested: Http2 unit tests pass (good coverage for this case).

Change-Id: Ie8606872f3a96f1bb0329bf22a4f7429f431bbef
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/http/http2_connection.hpp b/http/http2_connection.hpp
index a698d9e..7903ec9 100644
--- a/http/http2_connection.hpp
+++ b/http/http2_connection.hpp
@@ -396,49 +396,47 @@
 
         BMCWEB_LOG_DEBUG("on_header_callback name: {} value {}", nameSv,
                          valueSv);
-
-        switch (frame.hd.type)
+        if (frame.hd.type != NGHTTP2_HEADERS)
         {
-            case NGHTTP2_HEADERS:
-                if (frame.headers.cat != NGHTTP2_HCAT_REQUEST)
-                {
-                    break;
-                }
-                auto thisStream = streams.find(frame.hd.stream_id);
-                if (thisStream == streams.end())
-                {
-                    BMCWEB_LOG_ERROR("Unknown stream{}", frame.hd.stream_id);
-                    close();
-                    return -1;
-                }
+            return 0;
+        }
+        if (frame.headers.cat != NGHTTP2_HCAT_REQUEST)
+        {
+            return 0;
+        }
+        auto thisStream = streams.find(frame.hd.stream_id);
+        if (thisStream == streams.end())
+        {
+            BMCWEB_LOG_ERROR("Unknown stream{}", frame.hd.stream_id);
+            close();
+            return -1;
+        }
 
-                crow::Request& thisReq = thisStream->second.req;
+        crow::Request& thisReq = thisStream->second.req;
 
-                if (nameSv == ":path")
-                {
-                    thisReq.target(valueSv);
-                }
-                else if (nameSv == ":method")
-                {
-                    boost::beast::http::verb verb =
-                        boost::beast::http::string_to_verb(valueSv);
-                    if (verb == boost::beast::http::verb::unknown)
-                    {
-                        BMCWEB_LOG_ERROR("Unknown http verb {}", valueSv);
-                        close();
-                        return -1;
-                    }
-                    thisReq.req.method(verb);
-                }
-                else if (nameSv == ":scheme")
-                {
-                    // Nothing to check on scheme
-                }
-                else
-                {
-                    thisReq.req.set(nameSv, valueSv);
-                }
-                break;
+        if (nameSv == ":path")
+        {
+            thisReq.target(valueSv);
+        }
+        else if (nameSv == ":method")
+        {
+            boost::beast::http::verb verb =
+                boost::beast::http::string_to_verb(valueSv);
+            if (verb == boost::beast::http::verb::unknown)
+            {
+                BMCWEB_LOG_ERROR("Unknown http verb {}", valueSv);
+                close();
+                return -1;
+            }
+            thisReq.req.method(verb);
+        }
+        else if (nameSv == ":scheme")
+        {
+            // Nothing to check on scheme
+        }
+        else
+        {
+            thisReq.req.set(nameSv, valueSv);
         }
         return 0;
     }