MCPcopy Create free account
hub / github.com/comaps/comaps / ReadRemoteFile

Function ReadRemoteFile

libs/traffic/traffic_info.cpp:42–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40namespace
41{
42bool ReadRemoteFile(string const & url, vector<uint8_t> & contents, int & errorCode)
43{
44 platform::HttpClient request(url);
45 if (!request.RunHttpRequest())
46 {
47 errorCode = request.ErrorCode();
48 LOG(LINFO, ("Couldn't run traffic request", url, ". Error:", errorCode));
49 return false;
50 }
51
52 errorCode = request.ErrorCode();
53
54 string const & result = request.ServerResponse();
55 contents.resize(result.size());
56 memcpy(contents.data(), result.data(), result.size());
57
58 if (errorCode != 200)
59 {
60 LOG(LINFO, ("Traffic request", url, "failed. HTTP Error:", errorCode));
61 return false;
62 }
63
64 return true;
65}
66
67string MakeRemoteURL(string const & name, uint64_t version)
68{

Callers 1

ReceiveTrafficKeysMethod · 0.85

Calls 5

ErrorCodeMethod · 0.80
RunHttpRequestMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected