mirror of
https://github.com/yhirose/cpp-httplib
synced 2026-06-08 18:30:49 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e61a8bcec7 | |||
| 33dbe00cce |
@@ -8,8 +8,8 @@
|
||||
#ifndef CPPHTTPLIB_HTTPLIB_H
|
||||
#define CPPHTTPLIB_HTTPLIB_H
|
||||
|
||||
#define CPPHTTPLIB_VERSION "0.33.0"
|
||||
#define CPPHTTPLIB_VERSION_NUM "0x002100"
|
||||
#define CPPHTTPLIB_VERSION "0.33.1"
|
||||
#define CPPHTTPLIB_VERSION_NUM "0x002101"
|
||||
|
||||
/*
|
||||
* Platform compatibility check
|
||||
@@ -7951,10 +7951,19 @@ make_multipart_content_provider(const UploadFormDataItems &items,
|
||||
}
|
||||
segs.push_back({owned.back().data(), owned.back().size()});
|
||||
|
||||
return [owned = std::move(owned), segs = std::move(segs)](
|
||||
size_t offset, size_t length, DataSink &sink) -> bool {
|
||||
struct MultipartState {
|
||||
std::vector<std::string> owned;
|
||||
std::vector<MultipartSegment> segs;
|
||||
};
|
||||
auto state = std::make_shared<MultipartState>();
|
||||
state->owned = std::move(owned);
|
||||
// `segs` holds raw pointers into owned strings; std::string move preserves
|
||||
// the data pointer, so these pointers remain valid after the move above.
|
||||
state->segs = std::move(segs);
|
||||
|
||||
return [state](size_t offset, size_t length, DataSink &sink) -> bool {
|
||||
size_t pos = 0;
|
||||
for (const auto &seg : segs) {
|
||||
for (const auto &seg : state->segs) {
|
||||
// Loop invariant: pos <= offset (proven by advancing pos only when
|
||||
// offset - pos >= seg.size, i.e., the segment doesn't contain offset)
|
||||
if (seg.size > 0 && offset - pos < seg.size) {
|
||||
|
||||
Reference in New Issue
Block a user