Skip to content

Feature/post handler#68

Merged
iboukhss merged 1 commit intodevfrom
feature/PostHandler
Dec 5, 2025
Merged

Feature/post handler#68
iboukhss merged 1 commit intodevfrom
feature/PostHandler

Conversation

@StokesAsselborn
Copy link
Collaborator

@StokesAsselborn StokesAsselborn commented Dec 1, 2025

First version of the UploadHandler

Closes #45

@StokesAsselborn StokesAsselborn marked this pull request as ready for review December 5, 2025 07:38
@StokesAsselborn
Copy link
Collaborator Author

This is a first working version + some tests.

To be improved, cleaned up later

@iboukhss iboukhss self-requested a review December 5, 2025 08:00
Copy link
Owner

@iboukhss iboukhss left a comment

Choose a reason for hiding this comment

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

LGTM

My only worry is on uploading binary data, I think it will fail? I didn't test it

Otherwise well done on this

Comment on lines +85 to +95
if (bytes == -1) {
// error occured
eob_reached_ = true;
if (headers_.empty()) {
HttpResponse res;
res.code = HttpResponse::kStatusDiskFull;
res.inline_body = "<h1> 507 Disk Full </h1>"; // to display a message during testing
headers_ = res.to_string();
bytes_written_ = content_length_; // to ensure needs_input returns false
}
return 0;
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think this is valid without checking errno but it's probably fine

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I noticed the same especially as bytes is of size_t. I will create an issue.

Handler* handler = new UploadHandler(upload_path, content.size());
ASSERT_TRUE(handler->needs_input());
delete (handler);
remove(upload_path.c_str());
Copy link
Owner

Choose a reason for hiding this comment

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

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just testing that needs_input returns true after init.

remove(upload_path.c_str());
}

UTEST(UploadHandlerTest, return_201)
Copy link
Owner

Choose a reason for hiding this comment

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

return_201 was not a clear name (for me)

same for return_401

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok let's change as you propose

@StokesAsselborn
Copy link
Collaborator Author

Closes #45

@iboukhss iboukhss force-pushed the feature/PostHandler branch from 281f01f to 4eeaa74 Compare December 5, 2025 09:35
@iboukhss iboukhss merged commit 4eeaa74 into dev Dec 5, 2025
1 check passed
@iboukhss iboukhss deleted the feature/PostHandler branch December 5, 2025 09:37
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.

Create UploadHandler

2 participants