4 // Various routines that deal with parsing; both HTTP requests and more generic text.
10 // Split a line on whitespace, e.g. "foo bar baz" -> {"foo", "bar", "baz"}.
11 std::vector<std::string> split_tokens(const std::string &line);
13 // Split a string on \n or \r\n, e.g. "foo\nbar\r\n\nbaz\r\n\r\n" -> {"foo", "bar", "baz"}.
14 std::vector<std::string> split_lines(const std::string &str);
16 // Add the new data to an existing string, looking for \r\n\r\n
17 // (typical of HTTP requests and/or responses). Will return one
18 // of the given statuses.
20 // Note that if you give too much data in new_data_size, you could
21 // get an RP_OUT_OF_SPACE even if you expected RP_EXTRA_DATA.
22 // Be careful about how large reads you give in.
23 enum RequestParseStatus {
24 RP_OUT_OF_SPACE, // If larger than 16 kB.
25 RP_NOT_FINISHED_YET, // Did not get \r\n\r\n yet.
26 RP_EXTRA_DATA, // Got \r\n\r\n, but there was extra data behind it.
27 RP_FINISHED, // Ended exactly in \r\n\r\n.
29 RequestParseStatus wait_for_double_newline(std::string *existing_data, const char *new_data, size_t new_data_size);
31 #endif // !defined(_PARSE_H)