mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-15 09:18:27 +00:00
Fixed #33
This commit is contained in:
parent
c76d0e4ab3
commit
7e5db48bdf
3 changed files with 189 additions and 51 deletions
19
README.md
19
README.md
|
@ -126,15 +126,28 @@ auto res = cli.post("/post", params);
|
|||
httplib::Client client(url, port);
|
||||
|
||||
// prints: 0 / 000 bytes => 50% complete
|
||||
std::shared_ptr<httplib::Response> res =
|
||||
cli.get("/", [](int64_t len, int64_t total) {
|
||||
printf("%lld / %lld bytes => %d%% complete\n",
|
||||
std::shared_ptr<httplib::Response> res =
|
||||
cli.get("/", [](uint64_t len, uint64_t total) {
|
||||
printf("%lld / %lld bytes => %d%% complete\n",
|
||||
len, total,
|
||||
(int)((len/total)*100));
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
### Range (HTTP/1.1)
|
||||
|
||||
```cpp
|
||||
httplib::Client cli("httpbin.org", 80, httplib::HttpVersion::v1_1);
|
||||
|
||||
// 'Range: bytes=1-10'
|
||||
httplib::Headers headers = { httplib::make_range_header(1, 10) };
|
||||
|
||||
auto res = cli.get("/range/32", headers);
|
||||
// res->status should be 206.
|
||||
// res->body should be "bcdefghijk".
|
||||
```
|
||||
|
||||

|
||||
|
||||
This feature was contributed by [underscorediscovery](https://github.com/yhirose/cpp-httplib/pull/23).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue