Skip to content

Commit b5680a5

Browse files
author
Levent KARAGÖL
committed
ignoreSslErrors option has been added
1 parent a75b0d9 commit b5680a5

File tree

4 files changed

+117
-95
lines changed

4 files changed

+117
-95
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,9 @@ int main() {
339339

340340
## How to ignore SSL certificate errors?
341341

342-
If you need to ignore SSL certificate errors for any valid reason, you can continue working
343-
by passing the **"true"** value to the **"ignoreSslErrors"** parameter at the end of the functions.
342+
If you need to ignore SSL certificate errors for any valid reason, you can continue
343+
working by passing **"true"** value to the **"ignoreSslErrors"** variable of the
344+
HttpClient class.
344345

345346
```cpp
346347
#include <fstream>
@@ -351,10 +352,11 @@ using namespace lklibs;
351352
int main() {
352353

353354
HttpClient httpClient;
355+
356+
// If you need to ignore SSL errors, you can set the "ignoreSslErrors" field to true
357+
httpClient.ignoreSslErrors = true;
354358

355-
std::string payload = "param1=7&param2=test";
356-
357-
auto response = httpClient.postRequest("https://api.myinvalidssl.com", payload, true).get();
359+
auto response = httpClient.getRequest("https://api.myinvalidssl.com").get();
358360

359361
return 0;
360362
}

examples/main.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,20 @@ void simplePatch() {
160160
std::cout << "Data: " << response.textData << std::endl;
161161
}
162162

163+
void ignoreSslErrors() {
164+
165+
HttpClient httpClient;
166+
167+
// If you need to ignore SSL errors, you can set the "ignoreSslErrors" field to true
168+
httpClient.ignoreSslErrors = true;
169+
170+
auto response = httpClient.getRequest("https://self-signed-cert.httpbun.com").get();
171+
172+
std::cout << "Succeed: " << response.succeed << std::endl;
173+
std::cout << "Http Status Code: " << response.statusCode << std::endl;
174+
std::cout << "Data: " << response.textData << std::endl;
175+
}
176+
163177

164178
int main() {
165179

@@ -183,5 +197,7 @@ int main() {
183197

184198
simplePatch();
185199

200+
ignoreSslErrors();
201+
186202
return 0;
187203
}

0 commit comments

Comments
 (0)