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
12       **ct);
13

DESCRIPTION

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

PROTOCOLS

25       HTTP(S)
26

EXAMPLE

28       CURL *curl = curl_easy_init();
29       if(curl) {
30         curl_easy_setopt(curl, CURLOPT_URL, "https://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

AVAILABILITY

46       Added in 7.9.4
47

RETURN VALUE

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

SEE ALSO

53       curl_easy_getinfo(3), curl_easy_setopt(3),
54
55
56
57libcurl 7.79.1                 November 04, 2020      CURLINFO_CONTENT_TYPE(3)
Impressum