@@ -59,7 +59,7 @@ target_link_libraries(myProject PRIVATE libcpp-http-client CURL::libcurl)
59
59
Below you can see the simplest use case sending QueryString parameters to an API via HTTP GET.
60
60
61
61
> [ !IMPORTANT]
62
- > Please do not use it this way, if more than one call will be made . You do not use the non-blocking
62
+ > Please do not use it this way, if more than one call will be made. You do not use the non-blocking
63
63
> feature in this way. Just keep reading...
64
64
65
65
``` cpp
@@ -155,7 +155,7 @@ int main() {
155
155
}
156
156
```
157
157
158
- All functions in the library return a future and allow the next line to run without blocking the flow.
158
+ ** "send" ** function in the library return a future and allow the next line to run without blocking the flow.
159
159
160
160
161
161
## What does exception free mean?
@@ -200,8 +200,7 @@ int main() {
200
200
In the examples so far, we have used the ** "textData"** property of the returning response object.
201
201
However, we need binary data for requests made to binary files such as images. In such cases,
202
202
we can ensure that the returned data is returned in ** "binaryData"** of type
203
- *** "std::vector< ; unsigned char> ; "*** instead of ** "textData"** by passing the value ** "true"**
204
- to the ** "returnAsBinary"** parameter.
203
+ *** "std::vector< ; unsigned char> ; "*** instead of ** "textData"** by calling ** "returnAsBinary()"** method before send as follow.
205
204
206
205
``` cpp
207
206
#include < fstream>
@@ -232,8 +231,7 @@ int main() {
232
231
233
232
## Sending custom HTTP headers
234
233
235
- If you need to send custom HTTP HEADERs during the request, you can send them in
236
- std::map<std::string, std::string> format.
234
+ If you need to send custom HTTP HEADERs during the request, you can add them to the request as key-value pairs with ** "addHeader()"** method.
237
235
238
236
``` cpp
239
237
#include < fstream>
@@ -243,7 +241,7 @@ using namespace lklibs;
243
241
244
242
int main () {
245
243
246
- HttpRequest httpRequest("https://api.myproject.com?param1=7¶m2=test ");
244
+ HttpRequest httpRequest("https://api.myproject.com");
247
245
248
246
// You can send custom headers as key-value pairs
249
247
auto response = httpRequest
@@ -261,8 +259,7 @@ int main() {
261
259
262
260
## POST request with form data
263
261
264
- Next is submitting form data via HTTP POST. All you have to do is use ** "postRequest"** instead
265
- of ** "getRequest"** . You can pass the form data to the ** "payload"** variable as seen in the sample code below.
262
+ Next is submitting form data via HTTP POST. All you have to do is use ** "setMethod"** to change HTTP method type. You can pass the form data with ** "setPaylod"** method as seen in the sample code below.
266
263
267
264
``` cpp
268
265
#include < fstream>
@@ -339,24 +336,21 @@ int main() {
339
336
auto future1 = httpRequest
340
337
.setMethod(HttpMethod::PUT)
341
338
.setPayload("param1=7¶m2=test")
342
- .send()
343
- .get();
339
+ .send();
344
340
345
341
HttpRequest httpRequest2("https://api.myproject.com");
346
342
347
343
auto future2 = httpRequest
348
344
.setMethod(HttpMethod::DELETE_)
349
345
.setPayload("param1=7¶m2=test")
350
- .send()
351
- .get();
346
+ .send();
352
347
353
348
HttpRequest httpRequest3("https://api.myproject.com");
354
349
355
350
auto future3 = httpRequest
356
351
.setMethod(HttpMethod::PATCH)
357
352
.setQueryString("param1=7¶m2=test")
358
- .send()
359
- .get();
353
+ .send();
360
354
361
355
auto response1 = future1.get();
362
356
auto response2 = future2.get();
@@ -369,9 +363,8 @@ int main() {
369
363
370
364
## How to ignore SSL certificate errors?
371
365
372
- If you need to ignore SSL certificate errors for any valid reason, you can continue
373
- working by passing ** "true"** value to the ** "ignoreSslErrors"** variable of the
374
- HttpRequest class.
366
+ If you need to ignore SSL certificate errors for any valid reason, you can call "ignoreSslErrors"
367
+ method before sending the request.
375
368
376
369
``` cpp
377
370
#include < fstream>
@@ -384,7 +377,10 @@ int main() {
384
377
HttpRequest httpRequest("https://api.myinvalidssl.com");
385
378
386
379
// If you need to ignore SSL errors, you can call "ignoreSslErrors" method before sending the request
387
- auto response = httpRequest.ignoreSslErrors().send().get();
380
+ auto response = httpRequest
381
+ .ignoreSslErrors()
382
+ .send()
383
+ .get();
388
384
389
385
return 0;
390
386
}
@@ -410,7 +406,7 @@ section to the documentation.
410
406
## Full function list
411
407
412
408
You can find the complete list of functions in the library below. Since all methods except
413
- send return the class itself, they can be added one after the other like a chain.
409
+ send return the class itself, so they can be added one after the other like a chain.
414
410
415
411
> [ !TIP]
416
412
> All methods and parameters descriptions are also available within the code as comment for IDEs.
0 commit comments