Add content-encoding parser

Similar to content-type, add an http content-encoding parser.

Tested: Unit tests pass.

Change-Id: Ic62809934f84804c910458184de19ca9a4207ce5
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/test/include/http_utility_test.cpp b/test/include/http_utility_test.cpp
index 72c4759..2a5e8a7 100644
--- a/test/include/http_utility_test.cpp
+++ b/test/include/http_utility_test.cpp
@@ -114,5 +114,32 @@
         getPreferredContentType("text/html, application/json", contentType),
         ContentType::NoMatch);
 }
+
+TEST(getPreferredEncoding, PositiveTest)
+{
+    std::array<Encoding, 1> encodingsGzip{Encoding::GZIP};
+    EXPECT_EQ(getPreferredEncoding("gzip", encodingsGzip), Encoding::GZIP);
+
+    std::array<Encoding, 2> encodingsGzipZstd{Encoding::GZIP, Encoding::ZSTD};
+    EXPECT_EQ(getPreferredEncoding("gzip", encodingsGzipZstd), Encoding::GZIP);
+    EXPECT_EQ(getPreferredEncoding("zstd", encodingsGzipZstd), Encoding::ZSTD);
+
+    EXPECT_EQ(getPreferredEncoding("*", encodingsGzipZstd), Encoding::GZIP);
+
+    EXPECT_EQ(getPreferredEncoding("zstd, gzip;q=1.0", encodingsGzipZstd),
+              Encoding::ZSTD);
+}
+
+TEST(getPreferredEncoding, NegativeTest)
+{
+    std::array<Encoding, 2> contentType{Encoding::GZIP,
+                                        Encoding::UnencodedBytes};
+    EXPECT_EQ(getPreferredEncoding("noexist", contentType),
+              Encoding::UnencodedBytes);
+
+    std::array<Encoding, 1> contentType2{Encoding::GZIP};
+    EXPECT_EQ(getPreferredEncoding("zstd", contentType2), Encoding::NoMatch);
+}
+
 } // namespace
 } // namespace http_helpers