1CURLINFO_CONTENT_TYPE(3)   curl_easy_getinfo options  CURLINFO_CONTENT_TYPE(3)
2
3
4

NAME

6       CURLINFO_CONTENT_TYPE - get Content-Type
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONTENT_TYPE, char **ct);
12

DESCRIPTION

14       Pass  a  pointer  to  a char pointer to receive the content-type of the
15       downloaded object. This is the value read from the Content-Type: field.
16       If you get NULL, it means that the server did not send a valid Content-
17       Type header or that the protocol used does not support this.
18
19       The ct pointer will be NULL or pointing to private memory you MUST  NOT
20       free  it - it gets freed when you call curl_easy_cleanup(3) on the cor‐
21       responding CURL handle.
22

PROTOCOLS

24       HTTP(S)
25

EXAMPLE

27       CURL *curl = curl_easy_init();
28       if(curl) {
29         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
30
31         res = curl_easy_perform(curl);
32
33         if(!res) {
34           /* extract the content-type */
35           char *ct = NULL;
36           res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
37           if(!res && ct) {
38             printf("Content-Type: %s\n", ct);
39           }
40         }
41         curl_easy_cleanup(curl);
42       }
43

AVAILABILITY

45       Added in 7.9.4
46

RETURN VALUE

48       Returns CURLE_OK if the option is supported,  and  CURLE_UNKNOWN_OPTION
49       if not.
50

SEE ALSO

52       curl_easy_getinfo(3),  curl_easy_setopt(3),  CURLOPT_HEADERFUNCTION(3),
53       curl_easy_header(3)
54
55
56
57libcurl 7.85.0                   May 17, 2022         CURLINFO_CONTENT_TYPE(3)
Impressum