@@ -577,8 +577,8 @@ using Headers =
577
577
using Params = std::multimap<std::string, std::string>;
578
578
using Match = std::smatch;
579
579
580
- using DownloadProgress = std::function<bool (uint64_t current, uint64_t total)>;
581
- using UploadProgress = std::function<bool (uint64_t current, uint64_t total)>;
580
+ using DownloadProgress = std::function<bool (size_t current, size_t total)>;
581
+ using UploadProgress = std::function<bool (size_t current, size_t total)>;
582
582
583
583
struct Response ;
584
584
using ResponseHandler = std::function<bool (const Response &response)>;
@@ -674,9 +674,8 @@ struct FormDataProvider {
674
674
};
675
675
using FormDataProviderItems = std::vector<FormDataProvider>;
676
676
677
- using ContentReceiverWithProgress =
678
- std::function<bool (const char *data, size_t data_length, uint64_t offset,
679
- uint64_t total_length)>;
677
+ using ContentReceiverWithProgress = std::function<bool (
678
+ const char *data, size_t data_length, size_t offset, size_t total_length)>;
680
679
681
680
using ContentReceiver =
682
681
std::function<bool (const char *data, size_t data_length)>;
@@ -744,8 +743,8 @@ struct Request {
744
743
bool has_header (const std::string &key) const ;
745
744
std::string get_header_value (const std::string &key, const char *def = " " ,
746
745
size_t id = 0 ) const ;
747
- uint64_t get_header_value_u64 (const std::string &key, uint64_t def = 0 ,
748
- size_t id = 0 ) const ;
746
+ size_t get_header_value_u64 (const std::string &key, size_t def = 0 ,
747
+ size_t id = 0 ) const ;
749
748
size_t get_header_value_count (const std::string &key) const ;
750
749
void set_header (const std::string &key, const std::string &val);
751
750
@@ -781,8 +780,8 @@ struct Response {
781
780
bool has_header (const std::string &key) const ;
782
781
std::string get_header_value (const std::string &key, const char *def = " " ,
783
782
size_t id = 0 ) const ;
784
- uint64_t get_header_value_u64 (const std::string &key, uint64_t def = 0 ,
785
- size_t id = 0 ) const ;
783
+ size_t get_header_value_u64 (const std::string &key, size_t def = 0 ,
784
+ size_t id = 0 ) const ;
786
785
size_t get_header_value_count (const std::string &key) const ;
787
786
void set_header (const std::string &key, const std::string &val);
788
787
@@ -1334,8 +1333,8 @@ class Result {
1334
1333
std::string get_request_header_value (const std::string &key,
1335
1334
const char *def = " " ,
1336
1335
size_t id = 0 ) const ;
1337
- uint64_t get_request_header_value_u64 (const std::string &key,
1338
- uint64_t def = 0 , size_t id = 0 ) const ;
1336
+ size_t get_request_header_value_u64 (const std::string &key, size_t def = 0 ,
1337
+ size_t id = 0 ) const ;
1339
1338
size_t get_request_header_value_count (const std::string &key) const ;
1340
1339
1341
1340
private:
@@ -2010,9 +2009,9 @@ inline bool is_numeric(const std::string &str) {
2010
2009
[](unsigned char c) { return std::isdigit (c); });
2011
2010
}
2012
2011
2013
- inline uint64_t get_header_value_u64 (const Headers &headers,
2014
- const std::string &key, uint64_t def,
2015
- size_t id, bool &is_invalid_value) {
2012
+ inline size_t get_header_value_u64 (const Headers &headers,
2013
+ const std::string &key, size_t def,
2014
+ size_t id, bool &is_invalid_value) {
2016
2015
is_invalid_value = false ;
2017
2016
auto rng = headers.equal_range (key);
2018
2017
auto it = rng.first ;
@@ -2027,22 +2026,22 @@ inline uint64_t get_header_value_u64(const Headers &headers,
2027
2026
return def;
2028
2027
}
2029
2028
2030
- inline uint64_t get_header_value_u64 (const Headers &headers,
2031
- const std::string &key, uint64_t def,
2032
- size_t id) {
2029
+ inline size_t get_header_value_u64 (const Headers &headers,
2030
+ const std::string &key, size_t def,
2031
+ size_t id) {
2033
2032
bool dummy = false ;
2034
2033
return get_header_value_u64 (headers, key, def, id, dummy);
2035
2034
}
2036
2035
2037
2036
} // namespace detail
2038
2037
2039
- inline uint64_t Request::get_header_value_u64 (const std::string &key,
2040
- uint64_t def, size_t id) const {
2038
+ inline size_t Request::get_header_value_u64 (const std::string &key, size_t def ,
2039
+ size_t id) const {
2041
2040
return detail::get_header_value_u64 (headers, key, def, id);
2042
2041
}
2043
2042
2044
- inline uint64_t Response::get_header_value_u64 (const std::string &key,
2045
- uint64_t def, size_t id) const {
2043
+ inline size_t Response::get_header_value_u64 (const std::string &key, size_t def ,
2044
+ size_t id) const {
2046
2045
return detail::get_header_value_u64 (headers, key, def, id);
2047
2046
}
2048
2047
@@ -2228,9 +2227,9 @@ inline std::ostream &operator<<(std::ostream &os, const Error &obj) {
2228
2227
return os;
2229
2228
}
2230
2229
2231
- inline uint64_t Result::get_request_header_value_u64 (const std::string &key,
2232
- uint64_t def,
2233
- size_t id) const {
2230
+ inline size_t Result::get_request_header_value_u64 (const std::string &key,
2231
+ size_t def,
2232
+ size_t id) const {
2234
2233
return detail::get_header_value_u64 (request_headers_, key, def, id);
2235
2234
}
2236
2235
@@ -4617,19 +4616,19 @@ inline bool read_headers(Stream &strm, Headers &headers) {
4617
4616
return true ;
4618
4617
}
4619
4618
4620
- inline bool read_content_with_length (Stream &strm, uint64_t len,
4619
+ inline bool read_content_with_length (Stream &strm, size_t len,
4621
4620
DownloadProgress progress,
4622
4621
ContentReceiverWithProgress out) {
4623
4622
char buf[CPPHTTPLIB_RECV_BUFSIZ];
4624
4623
4625
- uint64_t r = 0 ;
4624
+ size_t r = 0 ;
4626
4625
while (r < len) {
4627
4626
auto read_len = static_cast <size_t >(len - r);
4628
4627
auto n = strm.read (buf, (std::min)(read_len, CPPHTTPLIB_RECV_BUFSIZ));
4629
4628
if (n <= 0 ) { return false ; }
4630
4629
4631
4630
if (!out (buf, static_cast <size_t >(n), r, len)) { return false ; }
4632
- r += static_cast <uint64_t >(n);
4631
+ r += static_cast <size_t >(n);
4633
4632
4634
4633
if (progress) {
4635
4634
if (!progress (r, len)) { return false ; }
@@ -4639,14 +4638,14 @@ inline bool read_content_with_length(Stream &strm, uint64_t len,
4639
4638
return true ;
4640
4639
}
4641
4640
4642
- inline void skip_content_with_length (Stream &strm, uint64_t len) {
4641
+ inline void skip_content_with_length (Stream &strm, size_t len) {
4643
4642
char buf[CPPHTTPLIB_RECV_BUFSIZ];
4644
- uint64_t r = 0 ;
4643
+ size_t r = 0 ;
4645
4644
while (r < len) {
4646
4645
auto read_len = static_cast <size_t >(len - r);
4647
4646
auto n = strm.read (buf, (std::min)(read_len, CPPHTTPLIB_RECV_BUFSIZ));
4648
4647
if (n <= 0 ) { return ; }
4649
- r += static_cast <uint64_t >(n);
4648
+ r += static_cast <size_t >(n);
4650
4649
}
4651
4650
}
4652
4651
@@ -4660,22 +4659,22 @@ inline ReadContentResult
4660
4659
read_content_without_length (Stream &strm, size_t payload_max_length,
4661
4660
ContentReceiverWithProgress out) {
4662
4661
char buf[CPPHTTPLIB_RECV_BUFSIZ];
4663
- uint64_t r = 0 ;
4662
+ size_t r = 0 ;
4664
4663
for (;;) {
4665
4664
auto n = strm.read (buf, CPPHTTPLIB_RECV_BUFSIZ);
4666
4665
if (n == 0 ) { return ReadContentResult::Success; }
4667
4666
if (n < 0 ) { return ReadContentResult::Error; }
4668
4667
4669
4668
// Check if adding this data would exceed the payload limit
4670
4669
if (r > payload_max_length ||
4671
- payload_max_length - r < static_cast <uint64_t >(n)) {
4670
+ payload_max_length - r < static_cast <size_t >(n)) {
4672
4671
return ReadContentResult::PayloadTooLarge;
4673
4672
}
4674
4673
4675
4674
if (!out (buf, static_cast <size_t >(n), r, 0 )) {
4676
4675
return ReadContentResult::Error;
4677
4676
}
4678
- r += static_cast <uint64_t >(n);
4677
+ r += static_cast <size_t >(n);
4679
4678
}
4680
4679
4681
4680
return ReadContentResult::Success;
@@ -4693,7 +4692,7 @@ inline ReadContentResult read_content_chunked(Stream &strm, T &x,
4693
4692
if (!line_reader.getline ()) { return ReadContentResult::Error; }
4694
4693
4695
4694
unsigned long chunk_len;
4696
- uint64_t total_len = 0 ;
4695
+ size_t total_len = 0 ;
4697
4696
while (true ) {
4698
4697
char *end_ptr;
4699
4698
@@ -4845,7 +4844,7 @@ bool prepare_content_receiver(T &x, int &status,
4845
4844
if (decompressor) {
4846
4845
if (decompressor->is_valid ()) {
4847
4846
ContentReceiverWithProgress out = [&](const char *buf, size_t n,
4848
- uint64_t off, uint64_t len) {
4847
+ size_t off, size_t len) {
4849
4848
return decompressor->decompress (buf, n,
4850
4849
[&](const char *buf2, size_t n2) {
4851
4850
return receiver (buf2, n2, off, len);
@@ -4859,8 +4858,8 @@ bool prepare_content_receiver(T &x, int &status,
4859
4858
}
4860
4859
}
4861
4860
4862
- ContentReceiverWithProgress out = [&](const char *buf, size_t n, uint64_t off,
4863
- uint64_t len) {
4861
+ ContentReceiverWithProgress out = [&](const char *buf, size_t n, size_t off,
4862
+ size_t len) {
4864
4863
return receiver (buf, n, off, len);
4865
4864
};
4866
4865
return callback (std::move (out));
@@ -4899,9 +4898,9 @@ bool read_content(Stream &strm, T &x, size_t payload_max_length, int &status,
4899
4898
}
4900
4899
} else {
4901
4900
auto is_invalid_value = false ;
4902
- auto len = get_header_value_u64 (
4903
- x. headers , " Content-Length " ,
4904
- (std::numeric_limits< uint64_t >::max)(), 0 , is_invalid_value);
4901
+ auto len = get_header_value_u64 (x. headers , " Content-Length " ,
4902
+ (std::numeric_limits< size_t >::max)() ,
4903
+ 0 , is_invalid_value);
4905
4904
4906
4905
if (is_invalid_value) {
4907
4906
ret = false ;
@@ -7568,13 +7567,13 @@ inline bool Server::read_content_core(
7568
7567
}
7569
7568
7570
7569
multipart_form_data_parser.set_boundary (std::move (boundary));
7571
- out = [&](const char *buf, size_t n, uint64_t /* off*/ , uint64_t /* len*/ ) {
7570
+ out = [&](const char *buf, size_t n, size_t /* off*/ , size_t /* len*/ ) {
7572
7571
return multipart_form_data_parser.parse (buf, n, multipart_header,
7573
7572
multipart_receiver);
7574
7573
};
7575
7574
} else {
7576
- out = [receiver](const char *buf, size_t n, uint64_t /* off*/ ,
7577
- uint64_t /* len*/ ) { return receiver (buf, n); };
7575
+ out = [receiver](const char *buf, size_t n, size_t /* off*/ ,
7576
+ size_t /* len*/ ) { return receiver (buf, n); };
7578
7577
}
7579
7578
7580
7579
if (req.method == " DELETE" && !req.has_header (" Content-Length" )) {
@@ -9093,21 +9092,21 @@ inline bool ClientImpl::process_request(Stream &strm, Request &req,
9093
9092
auto out =
9094
9093
req.content_receiver
9095
9094
? static_cast <ContentReceiverWithProgress>(
9096
- [&](const char *buf, size_t n, uint64_t off, uint64_t len) {
9095
+ [&](const char *buf, size_t n, size_t off, size_t len) {
9097
9096
if (redirect) { return true ; }
9098
9097
auto ret = req.content_receiver (buf, n, off, len);
9099
9098
if (!ret) { error = Error::Canceled; }
9100
9099
return ret;
9101
9100
})
9102
9101
: static_cast <ContentReceiverWithProgress>(
9103
- [&](const char *buf, size_t n, uint64_t /* off*/ ,
9104
- uint64_t /* len*/ ) {
9102
+ [&](const char *buf, size_t n, size_t /* off*/ ,
9103
+ size_t /* len*/ ) {
9105
9104
assert (res.body .size () + n <= res.body .max_size ());
9106
9105
res.body .append (buf, n);
9107
9106
return true ;
9108
9107
});
9109
9108
9110
- auto progress = [&](uint64_t current, uint64_t total) {
9109
+ auto progress = [&](size_t current, size_t total) {
9111
9110
if (!req.download_progress || redirect) { return true ; }
9112
9111
auto ret = req.download_progress (current, total);
9113
9112
if (!ret) { error = Error::Canceled; }
@@ -9258,7 +9257,7 @@ inline Result ClientImpl::Get(const std::string &path, const Headers &headers,
9258
9257
req.response_handler = std::move (response_handler);
9259
9258
req.content_receiver =
9260
9259
[content_receiver](const char *data, size_t data_length,
9261
- uint64_t /* offset*/ , uint64_t /* total_length*/ ) {
9260
+ size_t /* offset*/ , size_t /* total_length*/ ) {
9262
9261
return content_receiver (data, data_length);
9263
9262
};
9264
9263
req.download_progress = std::move (progress);
@@ -9448,7 +9447,7 @@ inline Result ClientImpl::Post(const std::string &path, const Headers &headers,
9448
9447
req.body = body;
9449
9448
req.content_receiver =
9450
9449
[content_receiver](const char *data, size_t data_length,
9451
- uint64_t /* offset*/ , uint64_t /* total_length*/ ) {
9450
+ size_t /* offset*/ , size_t /* total_length*/ ) {
9452
9451
return content_receiver (data, data_length);
9453
9452
};
9454
9453
req.download_progress = std::move (progress);
@@ -9600,7 +9599,7 @@ inline Result ClientImpl::Put(const std::string &path, const Headers &headers,
9600
9599
req.body = body;
9601
9600
req.content_receiver =
9602
9601
[content_receiver](const char *data, size_t data_length,
9603
- uint64_t /* offset*/ , uint64_t /* total_length*/ ) {
9602
+ size_t /* offset*/ , size_t /* total_length*/ ) {
9604
9603
return content_receiver (data, data_length);
9605
9604
};
9606
9605
req.download_progress = std::move (progress);
@@ -9755,7 +9754,7 @@ inline Result ClientImpl::Patch(const std::string &path, const Headers &headers,
9755
9754
req.body = body;
9756
9755
req.content_receiver =
9757
9756
[content_receiver](const char *data, size_t data_length,
9758
- uint64_t /* offset*/ , uint64_t /* total_length*/ ) {
9757
+ size_t /* offset*/ , size_t /* total_length*/ ) {
9759
9758
return content_receiver (data, data_length);
9760
9759
};
9761
9760
req.download_progress = std::move (progress);
0 commit comments