Function newHttpClient

Summary

#include <lib/inc/drogon/HttpClient.h>

(1) static HttpClientPtr newHttpClient(const std::string &ip, uint16_t port, bool useSSL=false, trantor::EventLoop *loop=nullptr)

(2) static HttpClientPtr newHttpClient(const std::string &hostString, trantor::EventLoop *loop=nullptr)

Function overload

Synopsis

#include <lib/inc/drogon/HttpClient.h>

static HttpClientPtr newHttpClient(const std::string &ip, uint16_t port, bool useSSL=false, trantor::EventLoop *loop=nullptr)

Description

Creaet a new HTTP client which use ip and port to connect to server.

Parameters:

ip - The ip address of the HTTP server

port - The port of the HTTP server

useSSL - if the parameter is set to true, the client connects to the server using https.

loop - If the loop parameter is set to nullptr, the client uses the HttpAppFramework's event loop, otherwise it runs in the loop identified by the parameter.

Return
HttpClientPtr The smart pointer to the new client object.
Note
: The ip parameter support for both ipv4 and ipv6 address

Source

Line 168 in lib/inc/drogon/HttpClient.h.

Synopsis

#include <lib/inc/drogon/HttpClient.h>

static HttpClientPtr newHttpClient(const std::string &hostString, trantor::EventLoop *loop=nullptr)

Description

Create a Http client using the hostString to connect to server.

Parameters:

hostString - this parameter must be prefixed by 'http://' or 'https://'.

Examples for hostString:
https://www.baidu.com
http://www.baidu.com
https://127.0.0.1:8080/
http://127.0.0.1
http://[::1]:8080/   //IPv6 address must be enclosed in [], rfc2732
Parameters:

loop - If the loop parameter is set to nullptr, the client uses the HttpAppFramework's event loop, otherwise it runs in the loop identified by the parameter.

Note
Don't add path and parameters in hostString, the request path and parameters should be set in HttpRequestPtr when calling the sendRequest() method.

Source

Line 205 in lib/inc/drogon/HttpClient.h.






Add Discussion as Guest

Log in to DocsForge