Skip to content

A HTTP requests/response parser. Given a string of HTTP request/response, it parses the string and makes a map of the headers and their corresponding values. It also gets the HTTP version, the method, machine name and relative path.

Notifications You must be signed in to change notification settings

chirag1992m/cppHttpHeadersParser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Given a string(std::string) and parses it stores the different headers given in a map of string (header name) and string (header value). It also stores the http version, method, machine name, machine port and the relative URI.

It validates the requests and returns the corresponding status of the request, 400 (Bad Request) 501 (Not Implemented) 200 (OK)

Just copy the files in your project root folder and incluse it using: #include "/path/to/file/http_requests_parser.hpp"

The puclic functions are:

  1. constructor() - Make a new and empty object of type HttpRequestsParser

  2. constructor(std::string) - Make a new object of type HttpRequestsParser and set the string that has to be parsed.

  3. void setRequest() - set the string to be parsed.

  4. int parse() - after setting the string, calling this function will start the parsing of the string and separate all the header and its values. The return values are: 400 (Bad Request) 501 (Not Implemented) 200 (OK)

    • std::string getFormattedRequest();
    • std::string getHostName();
    • std::string getStatusString();
    • std::string getVersionString();
    • std::string getMethodName();
    • std::string getFullURL();
    • std::string getMachinePort();

    get Methods to get the required part of http request.

About

A HTTP requests/response parser. Given a string of HTTP request/response, it parses the string and makes a map of the headers and their corresponding values. It also gets the HTTP version, the method, machine name and relative path.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages