Skip to content

Commit 2c062f0

Browse files
committed
Update README.md and BUILDING.md
1 parent 18273ea commit 2c062f0

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Test/Build
2+
Test/.cmake
23
*vcproj.*.user
34
*.suo
45
*.pdb
@@ -10,4 +11,5 @@ ipch/
1011
*.obj
1112
*.aps
1213
.vs/
13-
.vscode/
14+
.vscode/
15+
CMakeUserPresets.json

README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
# curl-cpp-wrapper
22

3-
A very simple HTTP client (C++ 11 wrapper for libcurl). Requires [libcurl](https://curl.se ) as dependency.
3+
A very simple HTTP client (C++ 11 wrapper for libcurl). It requires [libcurl](https://curl.se).
44

55
## Usage
66

77
Just add NetworkClient.cpp and NetworkClient.h files to your project.
88

99
Do a GET request:
1010
```cpp
11+
#include "NetworkClient.h"
12+
1113
NetworkClient nc;
1214
nc.doGet("http://google.com/?q=" + nc.urlEncode("Smelly cat"));
1315
std::cout << nc.responseBody();
1416
```
1517

16-
Do a POST request:
18+
Do a POST request (using method chaining):
1719
```cpp
18-
nc.setUrl("https://www.googleapis.com/oauth2/v3/token");
19-
nc.addQueryParam("refresh_token", refreshToken);
20-
nc.addQueryParam("client_id", clientId);
21-
nc.addQueryParam("client_secret", clientSecret);
22-
nc.addQueryParam("grant_type", "refresh_token");
23-
nc.doPost();
20+
nc.setUrl("https://www.googleapis.com/oauth2/v3/token")
21+
.addQueryParam("refresh_token", refreshToken)
22+
.addQueryParam("client_id", clientId)
23+
.addQueryParam("client_secret", clientSecret)
24+
.addQueryParam("grant_type", "refresh_token")
25+
.doPost();
2426
std::cout << nc.responseBody();
2527
```
2628

@@ -39,15 +41,14 @@ nc.doGet("http://i.imgur.com/DDf2wbJ.png");
3941

4042
Uploading a file:
4143
```cpp
42-
#include "NetworkClient.h"
4344
NetworkClient nc;
4445
std::string fileName = "c:\\test\\file.txt"; // file path should be UTF-8 encoded on Windows
4546
nc.setUrl("http://takebin.com/action");
4647
nc.addQueryParamFile("file", fileName, "file.txt", "");
4748
nc.addQueryParam("fileDesc", "cool file");
4849

4950
nc.doUploadMultipartData();
50-
if ( nc.responseCode() == 200 ) {
51+
if (nc.responseCode() == 200) {
5152
std::cout << nc.responseBody();
5253
}
5354
```
@@ -72,14 +73,15 @@ nc.doUpload(fileName, "");
7273

7374
Using proxy:
7475
```cpp
75-
nc.setProxy("127.0.0.1", "8888", CURLPROXY_HTTP); // CURLPROXY_HTTP, CURLPROXY_SOCKS4, CURLPROXY_SOCKS4A, CURLPROXY_SOCKS5, CURLPROXY_SOCKS5_HOSTNAME
76+
nc.setProxy("127.0.0.1", "8888", CURLPROXY_HTTP); // CURLPROXY_HTTP, CURLPROXY_HTTPS,CURLPROXY_SOCKS4, CURLPROXY_SOCKS4A, CURLPROXY_SOCKS5, CURLPROXY_SOCKS5_HOSTNAME
7677
```
7778
Custom request header:
7879
```
7980
nc.addQueryHeader("Content-Type", "application/json");
8081
```
8182
## Attention
8283

83-
You **should** build libcurl with **Unicode** feature enabled on Windows, otherwise, file upload may fail.
84+
**On Windows, enable Unicode support when building libcurl** — otherwise, file uploads may fail.
85+
86+
If using OpenSSL (not WinSSL), ensure the `curl-ca-bundle.crt` file is in your app’s binary directory. https://curl.se/docs/caextract.html
8487

85-
If you compile libcurl for Windows with OpenSSL support (instead of Schannel), you should put "curl-ca-bundle.crt" file into your application's binary directory).

Test/BUILDING.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44

55
```bash
66
mkdir Build
7+
conan install . --build=missing -s build_type=Debug --output-folder=Build
78
cd Build
8-
conan install .. --build=missing -s build_type=Debug
99
cmake .. -G "Visual Studio 16 2019" --toolchain=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Debug
1010
cmake --build .
1111
```
1212

1313
## On Linux
1414

1515
```bash
16+
mkdir Build
17+
conan install . --build=missing -s build_type=Debug --output-folder=Build
1618
cd Build
17-
conan install .. --build=missing -s build_type=Debug
1819
cmake .. --toolchain=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Debug
1920
cmake --build .
2021
```

0 commit comments

Comments
 (0)