[k2] add support http multipart content-type#1545
Open
astrophysik wants to merge 26 commits intomasterfrom
Open
[k2] add support http multipart content-type#1545astrophysik wants to merge 26 commits intomasterfrom
astrophysik wants to merge 26 commits intomasterfrom
Conversation
apolyakov
requested changes
Mar 6, 2026
runtime-light/server/http/multipart/details/parts-processing.cpp
Outdated
Show resolved
Hide resolved
runtime-light/server/http/multipart/details/parts-processing.cpp
Outdated
Show resolved
Hide resolved
apolyakov
reviewed
Mar 12, 2026
runtime-light/server/http/multipart/details/parts-processing.cpp
Outdated
Show resolved
Hide resolved
|
|
||
| auto tmp_name_opt{generate_temporary_name()}; | ||
| if (!tmp_name_opt.has_value()) { | ||
| kphp::log::warning("cannot generate unique name for multipart temporary file"); |
Contributor
There was a problem hiding this comment.
Isn't it dangerous that we can't create a file and just emit a warning? It looks like this may lead to some state corruption
runtime-light/server/http/multipart/details/parts-processing.cpp
Outdated
Show resolved
Hide resolved
apolyakov
reviewed
Mar 23, 2026
|
|
||
| inline auto parse_multipart_parts(std::string_view body, std::string_view boundary) noexcept { | ||
| return std::views::split(body, std::views::join(std::array{std::string_view{"--"}, boundary})) | | ||
| std::views::filter([](auto raw_part) noexcept { return !std::string_view(raw_part).empty(); }) | |
Contributor
There was a problem hiding this comment.
Is it OK to return view that contains temporary array?
| auto tmp_name_opt{generate_temporary_name()}; | ||
| kphp::log::assertion(tmp_name_opt.has_value()); | ||
| auto tmp_name{*tmp_name_opt}; | ||
| auto write_res{write_temporary_file(tmp_name, {reinterpret_cast<const std::byte*>(part.body.data()), part.body.size()})}; |
Contributor
There was a problem hiding this comment.
nit: span_of_char.as_bytes() is better here imho
| auto tmp_name{*tmp_name_opt}; | ||
| auto write_res{write_temporary_file(tmp_name, {reinterpret_cast<const std::byte*>(part.body.data()), part.body.size()})}; | ||
|
|
||
| if (write_res.has_value() || write_res.error() != UPLOAD_ERR_NO_FILE) { |
Contributor
There was a problem hiding this comment.
Should we keep files that've been uploaded partially?
| boundary_end = content_type.size(); | ||
| } | ||
|
|
||
| std::string_view boundary_view{ |
Contributor
There was a problem hiding this comment.
Please, take a look at runtime/interface.cpp:1307. It looks like you forgot some validation steps
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.