MCPcopy Create free account
hub / github.com/9miao/CrossApp / init

Method init

CrossApp/support/network/HttpClient.cpp:255–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253
254
255 bool init(CAHttpRequest *request, write_callback callback, void *stream, write_callback headerCallback, void *headerStream)
256 {
257 if (!m_curl)
258 return false;
259 if (!configureCURL(m_curl, s_pHttpClient[request->getThreadID()]))
260 return false;
261 /* get custom header data (if set) */
262 std::vector<std::string> headers=request->getHeaders();
263 if(!headers.empty())
264 {
265 /* append custom headers one by one */
266 for (std::vector<std::string>::iterator it = headers.begin(); it != headers.end(); ++it)
267 m_headers = curl_slist_append(m_headers,it->c_str());
268 /* set custom headers for curl */
269 if (!setOption(CURLOPT_HTTPHEADER, m_headers))
270 return false;
271 }
272
273 return setOption(CURLOPT_URL, request->getUrl().c_str())
274 && setOption(CURLOPT_WRITEFUNCTION, callback)
275 && setOption(CURLOPT_WRITEDATA, stream)
276 && setOption(CURLOPT_HEADERFUNCTION, headerCallback)
277 && setOption(CURLOPT_HEADERDATA, headerStream);
278
279 }
280
281 bool perform(int *responseCode)
282 {

Callers 5

processGetTaskFunction · 0.45
processPostTaskFunction · 0.45
processPutTaskFunction · 0.45
processDeleteTaskFunction · 0.45
processPostFileTaskFunction · 0.45

Calls 5

configureCURLFunction · 0.85
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected