]> git.sesse.net Git - cubemap/blobdiff - parse.h
Split HTTP header parsing into a common function.
[cubemap] / parse.h
diff --git a/parse.h b/parse.h
index de260640f56ebc4a0cbe0f6b06a39ead8d6bcbc0..a56b1f4230edce227ff616603c8a9550d8b70c55 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -4,6 +4,7 @@
 // Various routines that deal with parsing; both HTTP requests and more generic text.
 
 #include <stddef.h>
+#include <map>
 #include <string>
 #include <vector>
 
@@ -13,6 +14,11 @@ std::vector<std::string> split_tokens(const std::string &line);
 // Split a string on \n or \r\n, e.g. "foo\nbar\r\n\nbaz\r\n\r\n" -> {"foo", "bar", "baz"}.
 std::vector<std::string> split_lines(const std::string &str);
 
+// Extract HTTP headers from a request or response. Ignores the first line,
+// where the verb or the return code is.
+std::multimap<std::string, std::string> extract_headers(
+       const std::vector<std::string> &lines, const std::string &log_context);
+
 // Add the new data to an existing string, looking for \r\n\r\n
 // (typical of HTTP requests and/or responses). Will return one
 // of the given statuses.