X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=parse.h;h=a56b1f4230edce227ff616603c8a9550d8b70c55;hp=6912dd9a5c314ca41494aed2a6be41ba5094ab44;hb=6544fa0ec3f3a501bcb89ea977756911bd7f3ebd;hpb=32d84e70aa1f1c9cd8334aceac0a617b4a7b4b40 diff --git a/parse.h b/parse.h index 6912dd9..a56b1f4 100644 --- a/parse.h +++ b/parse.h @@ -3,8 +3,10 @@ // Various routines that deal with parsing; both HTTP requests and more generic text. -#include +#include +#include #include +#include // Split a line on whitespace, e.g. "foo bar baz" -> {"foo", "bar", "baz"}. std::vector split_tokens(const std::string &line); @@ -12,6 +14,11 @@ std::vector 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 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 extract_headers( + const std::vector &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.