Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test reading empty zero-length file #1931

Merged
merged 1 commit into from
Sep 9, 2024

Conversation

paulharris
Copy link
Contributor

I've also discovered mmap() will not map a zero byte file.
So current httplib cannot serve completely empty files.

I created a test case.

@yhirose yhirose merged commit 2d01e71 into yhirose:master Sep 9, 2024
0 of 4 checks passed
@yhirose
Copy link
Owner

yhirose commented Sep 9, 2024

Thanks!

@yhirose
Copy link
Owner

yhirose commented Sep 9, 2024

yhirose added a commit that referenced this pull request Sep 9, 2024
@paulharris
Copy link
Contributor Author

paulharris commented Sep 10, 2024 via email

@Tachi107
Copy link
Contributor

The test failed because it expected the wrong header (text/plain as opposed to application/octet-stream). So, is cpp-httplib unable to serve empty files or was Paul's conclusion wrong?

@yhirose
Copy link
Owner

yhirose commented Sep 17, 2024

The test failed because it expected the wrong header (text/plain as opposed to application/octet-stream). So, is cpp-httplib unable to serve empty files or was Paul's conclusion wrong?

You are correct. cpp-httplib serves an empty files with application/octet-stream.

EXPECT_EQ("application/octet-stream", res->get_header_value("Content-Type"));

@paulharris
Copy link
Contributor Author

The test was originally hard-crashing due to trying to mmap an empty file.
This was fixed after this test was added, in 9f8db2c
which was addressing #1933, a related issue.
So now the test was able to progress further to where you saw it fail for a different reason.

@paulharris paulharris deleted the test-get-empty-file branch September 18, 2024 01:54
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.

3 participants