Skip to content

Commit 91e33c7

Browse files
laxerhdCOM8
authored andcommitted
Fixed errors in advanced-usage.md
1 parent df51298 commit 91e33c7

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

advanced-usage.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ double elapsed; // The total time of the request in seconds
5252
Cookies cookies; // A vector-like collection of cookies returned in the request
5353
Error error; // An error object containing the error code and a message
5454
std::string raw_header; // The raw header string
55-
std::string status_line; // The status line of the respone
55+
std::string status_line; // The status line of the response
5656
std::string reason; // The reason for the status code
57-
cpr_off_t uploaded_bytes; // How many bytes have been send to the server
57+
cpr_off_t uploaded_bytes; // How many bytes have been sent to the server
5858
cpr_off_t downloaded_bytes; // How many bytes have been received from the server
5959
long redirect_count; // How many redirects occurred
6060
@@ -222,9 +222,9 @@ cpr::Response r = session.Get();
222222
```
223223
{% endraw %}
224224

225-
This is important so it bears emphasizing: *for each configuration option (like `Url`, `Parameters`), there's a corresponding method `Set<ObjectName>` and a `SetOption(<Object>)`*. The second interface is to facilitate the template metaprogramming magic that lets the API expose order-less methods.
225+
This is important, so it bears emphasizing: *for each configuration option (like `Url`, `Parameters`), there's a corresponding method `Set<ObjectName>` and a `SetOption(<Object>)`*. The second interface is to facilitate the template metaprogramming magic that lets the API expose order-less methods.
226226

227-
The key to all of this is actually the way [libcurl](http://curl.haxx.se/libcurl/) is designed. It uses a somewhat [policy-based design](https://en.wikipedia.org/wiki/Policy-based_design) that relies configuring a single library object (the `curl` handle). Each option configured into that object changes its behavior in mostly orthogonal ways.
227+
The key to all of this is actually the way [libcurl](http://curl.haxx.se/libcurl/) is designed. It uses a somewhat [policy-based design](https://en.wikipedia.org/wiki/Policy-based_design) that relies on configuring a single library object (the `curl` handle). Each option configured into that object changes its behavior in mostly orthogonal ways.
228228

229229
`Session` leverages that and exposes a more modern interface that's free of the macro-heavy hulkiness of libcurl. Understanding the policy-based design of libcurl is important for understanding the way the `Session` object behaves.
230230

@@ -423,7 +423,7 @@ if(responses.at(0).wait_for(std::chrono::milliseconds(10)) == std::future_status
423423

424424

425425
Asynchronous requests can also be performed using a `cpr::Session` object. It is important to note that the asynchronous request is performed directly on the session object, modifying it in the process.
426-
To ensure that the lifetime of the session is properly extended, the session object used **must be** managed by a `std::shared_ptr`. This restriction is necessary because the implementation uses `std::shared_from_this` to pass a pointer to the ansynchronous lambda function which would otherwise throw a `std::bad_weak_ptr` exception.
426+
To ensure that the lifetime of the session is properly extended, the session object used **must be** managed by a `std::shared_ptr`. This restriction is necessary because the implementation uses `std::shared_from_this` to pass a pointer to the asynchronous lambda function which would otherwise throw a `std::bad_weak_ptr` exception.
427427
Here is an example for an asynchronous get request which uses a session object:
428428

429429
{% raw %}
@@ -437,7 +437,7 @@ std::cout << r.text << std::endl;
437437
```
438438
{% endraw %}
439439
440-
An important note to make here is that arguments passed to an asynchronous call are copied. Under the hood, an asychronous call through the library's API is done with `std::async`. By default, for memory safety, all arguments are copied (or moved if temporary) because there's no syntax level guarantee that the arguments will live beyond the scope of the request.
440+
An important note to make here is that arguments passed to an asynchronous call are copied. Under the hood, an asynchronous call through the library's API is done with `std::async`. By default, for memory safety, all arguments are copied (or moved if temporary) because there's no syntax level guarantee that the arguments will live beyond the scope of the request.
441441
442442
It's possible to force `std::async` out of this default so that the arguments are passed by reference as opposed to value. Currently, however, `cpr::<method>Async` has no support for forced pass by reference, though this is planned for a future release.
443443
@@ -508,7 +508,7 @@ Setting the `Timeout` option sets the maximum allowed time the transfer operatio
508508

509509
## Setting Callbacks
510510

511-
You can optionally set callbacks for a request. Currently there is support for read, header, write, progress, and debug callbacks.
511+
You can optionally set callbacks for a request. Currently, there is support for read, header, write, progress, and debug callbacks.
512512

513513
### ReadCallback
514514

@@ -693,7 +693,7 @@ std::cout << another_r.text << std::endl;
693693
*/
694694
```
695695
696-
This is especially useful because `Cookies` often go from server to client and back to the server. Setting new `Cookies` should not look surprising at all:
696+
This is especially useful because `Cookies` often go from server to client and back to the server. Setting new `Cookies` should not look surprising at all:
697697
698698
{% raw %}
699699
```c++
@@ -712,7 +712,7 @@ std::cout << r.text << std::endl;
712712
{% endraw %}
713713

714714
By default `Cookies` and their values will be URL-encoded.
715-
Although this is recommend, it is not mandatory for `Cookies` to be URL-encoded.
715+
Although this is recommended, it is not mandatory for `Cookies` to be URL-encoded.
716716
{% raw %}
717717
```
718718
[...]
@@ -841,7 +841,7 @@ When downloading a small file, you might want to allocate enough memory to hold
841841
```c++
842842
struct File
843843
{
844-
void* file_buf; // file data will be save to
844+
void* file_buf; // file data will be saved to
845845
int64_t read_len; // file bytes
846846
};
847847
bool write_data(std::string data, intptr_t userdata)
@@ -1075,7 +1075,7 @@ X509v3 Authority Key Identifier:keyid:0A:BC:08:29:17:8C:A5:39:6D:7A:0E:CE:33:C7:
10751075
## Interface
10761076

10771077
It is also possible to specify the outgoing interface used by [libcurl](http://curl.haxx.se/libcurl/).
1078-
By default the TCP stack decides which interface to use for this request.
1078+
By default, the TCP stack decides which interface to use for this request.
10791079
You can change this behavior by passing the `cpr::Interface` option to your request.
10801080
Passing an empty string corresponds to passing a `nullptr` to `CURLOPT_INTERFACE`.
10811081
Further details: https://curl.se/libcurl/c/CURLOPT_INTERFACE.html
@@ -1099,7 +1099,7 @@ A `cpr::Interface` object can also be created via `std::string_view` instead of
10991099
## Local Port and Range
11001100

11011101
Sometimes it is necessary to specify the local port number for the socket used by [libcurl](http://curl.haxx.se/libcurl/).
1102-
By default the TCP stack decides which local port to use.
1102+
By default, the TCP stack decides which local port to use.
11031103
You can change this behaviour by passing the `cpr::LocalPort` option to your request or by calling `Session::SetLocalPort`.
11041104
When specifying a local port it is also recommended to specify a range if possible as the configured port might already be used.
11051105
This can be achieved by passing the `cpr::LocalPortRange` option to the request or by calling `Session::SetLocalPortRange`
@@ -1289,7 +1289,7 @@ Response response = session.Get();
12891289

12901290
It should be noted that interceptors can make changes to the session object that is later passed to the proceed function and can thus fundamentally change the request. Of course, the returned response object can also be modified.
12911291

1292-
In addition, interceptors can even change the http method of the request by passing the proceed method another parameter of the enum type `cpr::Interceptor::ProceedHttpMethod`. The parameter required for download requests is also simply passed to the proceed method. For example we can implement an interceptor which changes the request method to `HEAD`:
1292+
In addition, interceptors can even change the http method of the request by passing the proceed method another parameter of the enum type `cpr::Interceptor::ProceedHttpMethod`. The parameter required for download requests is also simply passed to the proceed method. For example, we can implement an interceptor which changes the request method to `HEAD`:
12931293

12941294
{% raw %}
12951295
```c++
@@ -1435,4 +1435,4 @@ cpr::Response getResponse = cpr::Get(cpr::Url{"https://www.example.com"},
14351435
```
14361436
{% endraw %}
14371437

1438-
It is also possible to use the ```setResolve``` and ```setResolves``` methods, however, it should be noted that each invocation clears any previous values set before. In other words, do not use multiple consecutive calls to ```setResolve``` to set multiple manual resolutions, instead create a vector of ```cpr::Resolve```-s and pass them to ```setResolves```.
1438+
It is also possible to use the ```setResolve``` and ```setResolves``` methods, however, it should be noted that each invocation clears any previous values set before. In other words, do not use multiple consecutive calls to ```setResolve``` to set multiple manual resolutions, instead create a vector of ```cpr::Resolve```-s and pass them to ```setResolves```.

0 commit comments

Comments
 (0)