Artifactspublic-v0

curl

master
ply4 git calls30 ms288 KiB3 cachedprotocol v2
107 lines2.5 KiBRaw

NAME

CURLOPT_MIME_OPTIONS - set MIME option flags

SYNOPSIS

c
#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MIME_OPTIONS, long options);

DESCRIPTION

Pass a long that holds a bitmask of options. Each bit is a boolean flag used while encoding a MIME tree or multipart form data.

Available bits are:

CURLMIMEOPT_FORMESCAPE

Tells libcurl to escape multipart form field and filenames using the backslash-escaping algorithm rather than percent-encoding (HTTP only).

Backslash-escaping consists in preceding backslashes and double quotes with a backslash. Percent encoding maps all occurrences of double quote, carriage return and line feed to %22, %0D and %0A respectively.

Before version 7.81.0, percent-encoding was never applied.

HTTP browsers used to do backslash-escaping in the past but have over time transitioned to use percent-encoding. This option allows one to address server-side applications that have not yet have been converted.

As an example, consider field or filename strangename"kind. When the containing multipart form is sent, this is normally transmitted as strangename%22kind. When this option is set, it is sent as strangename"kind.

DEFAULT

0, meaning disabled.

%PROTOCOLS%

EXAMPLE

c
int main(void)
{
  CURL *curl = curl_easy_init();
  curl_mime *form = NULL;

  if(curl) {
    CURLcode result = CURLE_OK;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
    curl_easy_setopt(curl, CURLOPT_MIME_OPTIONS, CURLMIMEOPT_FORMESCAPE);

    form = curl_mime_init(curl);
    if(form) {
      curl_mimepart *part = curl_mime_addpart(form);

      if(part) {
        curl_mime_filedata(part, "strange\\file\\name");
        curl_mime_name(part, "strange\"field\"name");
        curl_easy_setopt(curl, CURLOPT_MIMEPOST, form);

        /* Perform the request */
        result = curl_easy_perform(curl);
      }
    }

    curl_easy_cleanup(curl);
    curl_mime_free(form);
  }
}

HISTORY

CURLMIMEOPT_FORMESCAPE macro became long type in 8.16.0, prior to this version a long cast was necessary when passed to curl_easy_setopt(3).

%AVAILABILITY%

RETURN VALUE

curl_easy_setopt(3) returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3).

1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_MIME_OPTIONS
5Section: 3
6Source: libcurl
7See-also:
8 - CURLOPT_HTTPPOST (3)
9 - CURLOPT_MIMEPOST (3)
10Protocol:
11 - HTTP
12 - IMAP
13 - SMTP
14Added-in: 7.81.0
15---
17# NAME
19CURLOPT_MIME_OPTIONS - set MIME option flags
21# SYNOPSIS
23~~~c
24#include <curl/curl.h>
26CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MIME_OPTIONS, long options);
27~~~
29# DESCRIPTION
31Pass a long that holds a bitmask of options. Each bit is a boolean flag used
32while encoding a MIME tree or multipart form data.
34Available bits are:
36## CURLMIMEOPT_FORMESCAPE
38Tells libcurl to escape multipart form field and filenames using the
39backslash-escaping algorithm rather than percent-encoding (HTTP only).
41Backslash-escaping consists in preceding backslashes and double quotes with
42a backslash. Percent encoding maps all occurrences of double quote,
43carriage return and line feed to %22, %0D and %0A respectively.
45Before version 7.81.0, percent-encoding was never applied.
47HTTP browsers used to do backslash-escaping in the past but have over time
48transitioned to use percent-encoding. This option allows one to address
49server-side applications that have not yet have been converted.
51As an example, consider field or filename *strangename"kind*. When the
52containing multipart form is sent, this is normally transmitted as
53*strangename%22kind*. When this option is set, it is sent as
54*strangename"kind*.
56# DEFAULT
580, meaning disabled.
60# %PROTOCOLS%
62# EXAMPLE
64~~~c
65int main(void)
67 CURL *curl = curl_easy_init();
68 curl_mime *form = NULL;
70 if(curl) {
71 CURLcode result = CURLE_OK;
72 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
73 curl_easy_setopt(curl, CURLOPT_MIME_OPTIONS, CURLMIMEOPT_FORMESCAPE);
75 form = curl_mime_init(curl);
76 if(form) {
77 curl_mimepart *part = curl_mime_addpart(form);
79 if(part) {
80 curl_mime_filedata(part, "strange\\file\\name");
81 curl_mime_name(part, "strange\"field\"name");
82 curl_easy_setopt(curl, CURLOPT_MIMEPOST, form);
84 /* Perform the request */
85 result = curl_easy_perform(curl);
86 }
87 }
89 curl_easy_cleanup(curl);
90 curl_mime_free(form);
91 }
93~~~
95# HISTORY
97**CURLMIMEOPT_FORMESCAPE** macro became `long` type in 8.16.0, prior to this
98version a `long` cast was necessary when passed to curl_easy_setopt(3).
100# %AVAILABILITY%
102# RETURN VALUE
104curl_easy_setopt(3) returns a CURLcode indicating success or error.
106CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
107libcurl-errors(3).
Diagnostics4 git calls · 30 ms
CallStatusSizeTime030 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200149 B · hit3 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=3
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=149
git.pkt.payload.max=78
git.ls_refs.count=2
git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit4 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=23
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=4
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=10
git.pkt.data=8
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=293470
git.pkt.payload.max=65516
git.sideband.band1.bytes=293354
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=87
git.pack.bytes=293354
git.pack.ofs_delta=0
git.pack.ref_delta=1
git.pack.chain.max=1
git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0
git.pack.full=86
Open pack map
fetch2001.3 KiB · hit23 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1350
git.response.cache=HIT
git.response.duration_ms=23
git.fetch.wants=15ffc97dc3b6b122870520160208bfe95317c9cf
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=1350
git.pkt.payload.max=1329
git.sideband.band1.bytes=1328
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
Ref
refs/heads/master
Commit
31c911efe5652725e930f4d2e60c9060e5f6646d
cf-ray
a5e36359cbaab23b
Request
af8b168a…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format