Skip to content

Feature HTTP parser#54

Merged
iboukhss merged 4 commits intodevfrom
feature/http-parser
Nov 26, 2025
Merged

Feature HTTP parser#54
iboukhss merged 4 commits intodevfrom
feature/http-parser

Conversation

@iboukhss
Copy link
Owner

Closes #10, closes #18, closes #20

Lot of work here, trying to do the right thing

@iboukhss iboukhss marked this pull request as ready for review November 25, 2025 15:42
@iboukhss
Copy link
Owner Author

I added a new HttpParser class

The interface is as follows:

class HttpParser {
    void feed_data(const char* buf, size_t n);
    size_t slurp_data(char* buf, size_t n);
};

The basic idea is to "feed" all data we receive from sockets to the parser, once enough data has been "fed" to the parser, we can retreive either a full HttpRequest or an error.

The parser will also be able to decode chunked encoding in the future, this is why all data must pass through it.

When we need to, we can retreive data from the parser with the function slurp_data() which is basically just like another read/write abstraction.

I added some basic unit tests for request line parsing, like this: GET /index.html HTTP/1.1\r\n

The main logic has alson been changed quite a bit. I will clean it up later or maybe add comments to explain in more detail.

@StokesAsselborn
Copy link
Collaborator

Webserver crashes when running and you visit http://localhost:8080

Copy link
Collaborator

@StokesAsselborn StokesAsselborn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, the router needs to be fixed in order to test this PR.

The overall logic of the parser looks ok. Refinement can be done later.

@iboukhss iboukhss force-pushed the feature/http-parser branch from 3fe7c5d to 2de7f06 Compare November 26, 2025 16:32
@iboukhss
Copy link
Owner Author

Merging, I think this is good for now..

@iboukhss iboukhss merged commit 2de7f06 into dev Nov 26, 2025
1 check passed
@iboukhss iboukhss deleted the feature/http-parser branch November 26, 2025 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write basic unit tests for HTTP requests parsing Handle partial recv and send Basic HTTP header parsing

2 participants