forked from glynos/cpp-netlib
-
Notifications
You must be signed in to change notification settings - Fork 426
Here's my attempt at properly handling the content length header #164
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d00836d
Take content length into account when reading body
joelreymont 78afee4
Qualify stoi and only catch exceptions thrown by it.
joelreymont a941fb1
Use optional member variable to keep track of content length.
joelreymont 3079bda
Use size_t to store content length.
joelreymont 4054936
Print a debug message if content length conversion to size_t fails.
joelreymont File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev
Previous commit
Print a debug message if content length conversion to size_t fails.
- Loading branch information
commit 4054936d0b0d8e9b775759e9bdd7f27cf1a47dde
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -741,7 +741,11 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this<http_async_c | |
content_length_ = std::stoul(it->second); | ||
NETWORK_MESSAGE("Content-Length: " << *content_length_); | ||
} catch(const std::invalid_argument&) { | ||
NETWORK_MESSAGE("invalid argument exception while interpreting " | ||
<< it->second << " as content length"); | ||
} catch(const std::out_of_range&) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you are referring to a message on exception. Fair enough, will add. |
||
NETWORK_MESSAGE("out of range exception while interpreting " | ||
<< it->second << " as content length"); | ||
} | ||
} | ||
headers_promise.set_value(headers); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest a NETWORK_MESSAGE here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What line number is here exactly? There's a NETWORK_MESSAGE printing the content length, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inside the catch, print out that you got an invalid content length value.