1CURLINFO_CONTENT_TYPE(3) curl_easy_getinfo options CURLINFO_CONTENT_TYPE(3)
2
3
4
6 CURLINFO_CONTENT_TYPE - get Content-Type
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONTENT_TYPE, char
12 **ct);
13
15 Pass a pointer to a char pointer to receive the content-type of the
16 downloaded object. This is the value read from the Content-Type: field.
17 If you get NULL, it means that the server didn't send a valid Content-
18 Type header or that the protocol used doesn't support this.
19
20 The ct pointer will be NULL or pointing to private memory you MUST NOT
21 free it - it gets freed when you call curl_easy_cleanup(3) on the cor‐
22 responding CURL handle.
23
25 HTTP(S)
26
28 CURL *curl = curl_easy_init();
29 if(curl) {
30 curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
31
32 res = curl_easy_perform(curl);
33
34 if(!res) {
35 /* extract the content-type */
36 char *ct = NULL;
37 res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
38 if(!res && ct) {
39 printf("Content-Type: %s\n", ct);
40 }
41 }
42 curl_easy_cleanup(curl);
43 }
44
46 Added in 7.9.4
47
49 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
50 if not.
51
53 curl_easy_getinfo(3), curl_easy_setopt(3),
54
55
56
57libcurl 7.66.0 May 06, 2017 CURLINFO_CONTENT_TYPE(3)