MCPcopy Create free account
hub / github.com/chen3feng/toft / ResolveAddress

Function ResolveAddress

net/http/client.cpp:35–59  ·  view source on GitHub ↗

Resolve domain address, output is a vector of SocketAddressInet4 domain example: www.qq.com 192.168.1.1

Source from the content-addressed store, hash-verified

33// www.qq.com
34// 192.168.1.1
35bool ResolveAddress(const std::string& host,
36 uint16_t port,
37 std::vector<SocketAddressInet4> *sa,
38 HttpClient::ErrorCode *error)
39{
40 std::vector<IpAddress> ipaddr;
41 int error_code;
42 if (!DomainResolver::ResolveIpAddress(
43 host,
44 &ipaddr,
45 &error_code)) {
46 *error = HttpClient::ERROR_FAIL_TO_RESOLVE_ADDRESS;
47 return false;
48 }
49
50 std::vector<SocketAddressInet4> sock_addr;
51 for (std::vector<IpAddress>::const_iterator it = ipaddr.begin();
52 it != ipaddr.end();
53 ++it) {
54 sock_addr.push_back(SocketAddressInet4(*it, port));
55 }
56 sa->swap(sock_addr);
57
58 return true;
59}
60
61// according to RFC2616, HTTP STATUS 1xx, 204, and 304 doesn't have a HTTP
62// body.

Callers 1

ProcessRequestMethod · 0.85

Calls 5

SocketAddressInet4Class · 0.85
push_backMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
swapMethod · 0.45

Tested by

no test coverage detected