Skip to content

Commit d93222c

Browse files
committed
Documentation has been updated for setUserAgent method
1 parent 2682aec commit d93222c

File tree

1 file changed

+46
-7
lines changed

1 file changed

+46
-7
lines changed

README.md

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,30 @@ int main() {
438438
```
439439

440440

441+
## Setting the User Agent
442+
443+
You can set the User Agent information to be sent during the request with the setUserAgent method.
444+
445+
```cpp
446+
#include <fstream>
447+
#include "libcpp-http-client.hpp"
448+
449+
using namespace lklibs;
450+
451+
int main() {
452+
HttpRequest httpRequest("https://api.myproject.com");
453+
454+
// You can set the user agent to be used for the request with setUserAgent method
455+
auto response = httpRequest
456+
.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0")
457+
.send()
458+
.get();
459+
460+
return 0;
461+
}
462+
```
463+
464+
441465
## How can I limit download and upload bandwidth?
442466

443467
If you do not want the bandwidth to exceed a certain limit during the download and upload process, you can determine the maximum limit that can be used in Bytes with the setDownloadBandwidthLimit and setUploadBandwidthLimit methods.
@@ -488,14 +512,29 @@ send return the class itself, so they can be added one after the other like a ch
488512
> All methods and parameters descriptions are also available within the code as comment for IDEs.
489513
490514
```cpp
491-
- HttpRequest &setMethod(const HttpMethod &method) noexcept
492-
- HttpRequest &setQueryString(const std::string &queryString) noexcept
493-
- HttpRequest &setPayload(const std::string &payload) noexcept
494-
- HttpRequest &returnAsBinary() noexcept
495-
- HttpRequest &ignoreSslErrors() noexcept
496-
- HttpRequest &addHeader(const std::string &key, const std::string &value) noexcept
497-
- std::future<HttpResult> send() noexcept
515+
- HttpRequest& setMethod(const HttpMethod& method) noexcept
516+
517+
- HttpRequest& setQueryString(const std::string& queryString) noexcept
518+
519+
- HttpRequest& setPayload(const std::string& payload) noexcept
520+
521+
- HttpRequest& returnAsBinary() noexcept
498522

523+
- HttpRequest& addHeader(const std::string& key, const std::string& value) noexcept
524+
525+
- HttpRequest& setTimeout(const int timeout) noexcept
526+
527+
- HttpRequest& ignoreSslErrors() noexcept
528+
529+
- HttpRequest& setTLSVersion(const TLSVersion version) noexcept
530+
531+
- HttpRequest& setUserAgent(const std::string& userAgent) noexcept
532+
533+
- HttpRequest& setDownloadBandwidthLimit(const int limit) noexcept
534+
535+
- HttpRequest& setUploadBandwidthLimit(const int limit) noexcept
536+
537+
- std::future<HttpResult> send() noexcept
499538
```
500539
501540

0 commit comments

Comments
 (0)