Skip to content

HTTP Request Parser #13

@CodyNault

Description

@CodyNault

Currently there is a factory method in server/src/http_request.C
with the signature
HTTP_Request HTTP_Request::buildRequestFromBuffer(unsigned const char const data).
I was thinking that I would like to change this to be a constructor since only a singe HTTP_Request object is to be made, but given that this can the parser can fail we should leave it as a factory method that can throw some sort of failure exception.The input "data" is a pre-sized buffer that should contain the entire HTTP header. The buffer will be larger than the contents of the header so we need to detect the end of the header. I suppose the constructor should also take the buffer size as an argument to the code knows when to stop looking for the end if it cant find it.

A typical header looks something like this:

Factory method that constructs HTTPrequest from following string format:
GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Version: 13
Origin: http://example.com

Whoever works on this one needs to do research on HTTP headers. Currently it is just extracting a single field from a HTTP 1.1 header (I am not sure what it will take to support other versions of HTTP but this is something that you can research). We need to extract additional essential header information such as request method and host but also Websocket specific information such as origin, Sec-WebSocket-Key, Sec-WebSocket-Version, Sec-WebSocket-Protocol, Sec-WebSocket-Extensions

We need to extract these fields from the header and store them in their own as class data members. Getters and setters should be made for the datamembers as well
We need to extract relevant WebSocket information from the header and store them in their own as class data members. Getters and setters should be made for the datamembers as well

Be sure to read section "4.2.2. Sending the Server's Opening Handshake" of rfc6455 it will be useful information to you

If no end ("/r/n/r/n") is detected then we need to throw an exception. If the HTTP data seems malformed in any way, we need to throw an exception. We may want to add a special malformed http exception class.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions