MCPcopy Create free account
hub / github.com/apache/httpd / internals_setup

Function internals_setup

modules/md/md_curl.c:243–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241}
242
243static apr_status_t internals_setup(md_http_request_t *req)
244{
245 md_curl_internals_t *internals;
246 CURL *curl;
247 apr_status_t rv = APR_SUCCESS;
248 long ssl_options = 0;
249
250 curl = md_http_get_impl_data(req->http);
251 if (!curl) {
252 md_log_perror(MD_LOG_MARK, MD_LOG_TRACE3, 0, req->pool, "creating curl instance");
253 curl = curl_easy_init();
254 if (!curl) {
255 rv = APR_EGENERAL;
256 goto leave;
257 }
258 }
259 else {
260 md_log_perror(MD_LOG_MARK, MD_LOG_TRACE3, 0, req->pool, "reusing curl instance from http");
261 curl_easy_reset(curl);
262 }
263
264 curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_cb);
265 curl_easy_setopt(curl, CURLOPT_HEADERDATA, NULL);
266 curl_easy_setopt(curl, CURLOPT_READFUNCTION, req_data_cb);
267 curl_easy_setopt(curl, CURLOPT_READDATA, NULL);
268 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, resp_data_cb);
269 curl_easy_setopt(curl, CURLOPT_WRITEDATA, NULL);
270
271 internals = apr_pcalloc(req->pool, sizeof(*internals));
272 internals->curl = curl;
273
274 internals->response = apr_pcalloc(req->pool, sizeof(md_http_response_t));
275 internals->response->req = req;
276 internals->response->status = 400;
277 internals->response->headers = apr_table_make(req->pool, 5);
278 internals->response->body = apr_brigade_create(req->pool, req->bucket_alloc);
279
280 curl_easy_setopt(curl, CURLOPT_URL, req->url);
281 if (!apr_cstr_casecmp("GET", req->method)) {
282 /* nop */
283 }
284 else if (!apr_cstr_casecmp("HEAD", req->method)) {
285 curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
286 }
287 else if (!apr_cstr_casecmp("POST", req->method)) {
288 curl_easy_setopt(curl, CURLOPT_POST, 1L);
289 }
290 else {
291 curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, req->method);
292 }
293 curl_easy_setopt(curl, CURLOPT_HEADERDATA, internals);
294 curl_easy_setopt(curl, CURLOPT_READDATA, req->body);
295 curl_easy_setopt(curl, CURLOPT_WRITEDATA, internals);
296
297 if (req->timeout.overall > 0) {
298 curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, timeout_msec(req->timeout.overall));
299 }
300 if (req->timeout.connect > 0) {

Callers 2

md_curl_performFunction · 0.85
md_curl_multi_performFunction · 0.85

Calls 5

md_http_get_impl_dataFunction · 0.85
md_log_perrorFunction · 0.85
timeout_msecFunction · 0.85
timeout_secFunction · 0.85
md_log_is_levelFunction · 0.85

Tested by

no test coverage detected