MCPcopy Create free account
hub / github.com/acl-dev/acl / rpc_request

Method rpc_request

lib_rpc/src/http_stream.cpp:64–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64bool http_request::rpc_request(const MessageLite& in, MessageLite* out)
65{
66 if (request_ == NULL)
67 {
68 if (addr_ == NULL)
69 return false;
70 request_inner_ = new acl::http_request(addr_,
71 conn_timeout_, rw_timeout_);
72 request_ = request_inner_;
73 }
74
75 std::string buf;
76
77#ifdef DEBUG
78 struct timeval begin, end;
79 gettimeofday(&begin, NULL);
80#endif
81
82 in.SerializeToString(&buf);
83
84#ifdef DEBUG
85 gettimeofday(&end, NULL);
86 build_spent_ = stamp_sub(&end, &begin);
87
88 gettimeofday(&begin, NULL);
89#endif
90 acl::http_header& header = request_->request_header();
91 header.set_content_length(buf.length());
92 header.set_keep_alive(true);
93
94 if (request_->request(buf.c_str(), buf.length()) == false)
95 return false;
96
97#ifdef DEBUG
98 gettimeofday(&end, NULL);
99 request_spent_ = stamp_sub(&end, &begin);
100#endif
101
102 if (out == NULL)
103 return true;
104
105 buf.clear();
106 acl::string tmp;
107 int ret;
108
109#ifdef DEBUG
110 gettimeofday(&begin, NULL);
111#endif
112 while (true)
113 {
114 ret = request_->read_body(tmp, true);
115 if (ret < 0)
116 return false;
117 else if (ret == 0)
118 break;
119 buf.append(tmp.c_str(), (size_t) ret);
120 }
121

Callers 1

handle_oneFunction · 0.45

Calls 10

request_headerMethod · 0.80
set_keep_aliveMethod · 0.80
stamp_subFunction · 0.70
gettimeofdayFunction · 0.50
lengthMethod · 0.45
requestMethod · 0.45
c_strMethod · 0.45
clearMethod · 0.45
read_bodyMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected