class ugcs::vsm::Http_parser

Overview

This class implements limited HTTP parser according to RFC7230 Supports: More…

#include <http_parser.h>

class Http_parser
{
public:
    // structs

    struct string_compare_ignore_case;

    // fields

    std::string parser_error;

    // methods

    bool Parse(std::istream& in);
    bool Header_exists(const std::string& name) const;
    std::string Get_header_value(const std::string& name) const;
    std::string Get_method() const;
};

Detailed Documentation

This class implements limited HTTP parser according to RFC7230 Supports:

  • HTTP Method name

  • Header parsing in <name, value> pairs. name is case insensitive, value is trimmed. Does not support:

  • Header value folding.

  • URL and protocol string parsing from method/result line.

Methods

bool Parse(std::istream& in)

Parse http header from text stream.

Parameters:

stream

Input text stream.

bool Header_exists(const std::string& name) const

Check if the header field with the specified name exists.

std::string Get_header_value(const std::string& name) const

Get string value of header.

Parameters:

name

Header name, case insensitive.

Returns:

String value of header. “” if not present.

std::string Get_method() const

Get HTTP method name.