quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

curl_mime_headers.md (2062B)


      1 ---
      2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      3 SPDX-License-Identifier: curl
      4 Title: curl_mime_headers
      5 Section: 3
      6 Source: libcurl
      7 See-also:
      8   - curl_mime_addpart (3)
      9   - curl_mime_name (3)
     10 Protocol:
     11   - HTTP
     12   - IMAP
     13   - SMTP
     14 Added-in: 7.56.0
     15 ---
     16 
     17 # NAME
     18 
     19 curl_mime_headers - set a mime part's custom headers
     20 
     21 # SYNOPSIS
     22 
     23 ~~~c
     24 #include <curl/curl.h>
     25 
     26 CURLcode curl_mime_headers(curl_mimepart *part,
     27                            struct curl_slist *headers, int take_ownership);
     28 ~~~
     29 
     30 # DESCRIPTION
     31 
     32 curl_mime_headers(3) sets a mime part's custom headers.
     33 
     34 *part* is the part's handle to assign the custom headers list to.
     35 
     36 *headers* is the head of a list of custom headers; it may be set to NULL
     37 to remove a previously attached custom header list.
     38 
     39 *take_ownership*: when non-zero, causes the list to be freed upon
     40 replacement or mime structure deletion; in this case the list must not be
     41 freed explicitly.
     42 
     43 Setting a part's custom headers list multiple times is valid: only the value
     44 set by the last call is retained.
     45 
     46 # %PROTOCOLS%
     47 
     48 # EXAMPLE
     49 
     50 ~~~c
     51 int main(void)
     52 {
     53   struct curl_slist *headers = NULL;
     54   CURL *easy = curl_easy_init();
     55   curl_mime *mime;
     56   curl_mimepart *part;
     57 
     58   headers = curl_slist_append(headers, "Custom-Header: mooo");
     59 
     60   mime = curl_mime_init(easy);
     61   part = curl_mime_addpart(mime);
     62 
     63   /* use these headers in the part, takes ownership */
     64   curl_mime_headers(part, headers, 1);
     65 
     66   /* pass on this data */
     67   curl_mime_data(part, "12345679", CURL_ZERO_TERMINATED);
     68 
     69   /* set name */
     70   curl_mime_name(part, "numbers");
     71 
     72   /* Post and send it. */
     73   curl_easy_setopt(easy, CURLOPT_MIMEPOST, mime);
     74   curl_easy_setopt(easy, CURLOPT_URL, "https://example.com");
     75   curl_easy_perform(easy);
     76 }
     77 ~~~
     78 
     79 # %AVAILABILITY%
     80 
     81 # RETURN VALUE
     82 
     83 This function returns a CURLcode indicating success or error.
     84 
     85 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
     86 libcurl-errors(3). If CURLOPT_ERRORBUFFER(3) was set with curl_easy_setopt(3)
     87 there can be an error message stored in the error buffer when non-zero is
     88 returned.