Artifactspublic-v0

curl

master
ply4 git calls290 ms288 KiB2 cachedprotocol v2
110 lines2.9 KiBRaw

NAME

curl_mime_encoder - set a mime part's encoder and content transfer encoding

SYNOPSIS

c
#include <curl/curl.h>

CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding);

DESCRIPTION

curl_mime_encoder() requests a mime part's content to be encoded before being transmitted.

part is the part's handle to assign an encoder. encoding is a pointer to a null-terminated encoding scheme. It may be set to NULL to disable an encoder previously attached to the part. The encoding scheme storage may safely be reused after this function returns.

Setting a part's encoder multiple times is valid: only the value set by the last call is retained.

Upon multipart rendering, the part's content is encoded according to the pertaining scheme and a corresponding "Content-Transfer-Encoding" header is added to the part.

Supported encoding schemes are:

"binary": the data is left unchanged, the header is added.

"8bit": header added, no data change.

"7bit": the data is unchanged, but is each byte is checked to be a 7-bit value; if not, a read error occurs.

"base64": Data is converted to base64 encoding, then split in CRLF-terminated lines of at most 76 characters.

"quoted-printable": data is encoded in quoted printable lines of at most 76 characters. Since the resulting size of the final data cannot be determined prior to reading the original data, it is left as unknown, causing chunked transfer in HTTP. For the same reason, this encoder may not be used with IMAP. This encoder targets text data that is mostly ASCII and should not be used with other types of data.

If the original data is already encoded in such a scheme, a custom Content-Transfer-Encoding header should be added with curl_mime_headers(3) instead of setting a part encoder.

Encoding should not be applied to multiparts, thus the use of this function on a part with content set with curl_mime_subparts(3) is strongly discouraged.

%PROTOCOLS%

EXAMPLE

c
int main(void)
{
  curl_mime *mime;
  curl_mimepart *part;

  CURL *curl = curl_easy_init();
  if(curl) {
    /* create a mime handle */
    mime = curl_mime_init(curl);

    /* add a part */
    part = curl_mime_addpart(mime);

    /* send a file */
    curl_mime_filedata(part, "image.png");

    /* encode file data in base64 for transfer */
    curl_mime_encoder(part, "base64");
  }
}

%AVAILABILITY%

RETURN VALUE

This function returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3). If CURLOPT_ERRORBUFFER(3) was set with curl_easy_setopt(3) there can be an error message stored in the error buffer when non-zero is returned.

1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: curl_mime_encoder
5Section: 3
6Source: libcurl
7See-also:
8 - curl_mime_addpart (3)
9 - curl_mime_headers (3)
10 - curl_mime_subparts (3)
11Protocol:
12 - HTTP
13 - IMAP
14 - SMTP
15Added-in: 7.56.0
16---
18# NAME
20curl_mime_encoder - set a mime part's encoder and content transfer encoding
22# SYNOPSIS
24~~~c
25#include <curl/curl.h>
27CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding);
28~~~
30# DESCRIPTION
32curl_mime_encoder() requests a mime part's content to be encoded before being
33transmitted.
35*part* is the part's handle to assign an encoder.
36*encoding* is a pointer to a null-terminated encoding scheme. It may be
37set to NULL to disable an encoder previously attached to the part. The encoding
38scheme storage may safely be reused after this function returns.
40Setting a part's encoder multiple times is valid: only the value set by the
41last call is retained.
43Upon multipart rendering, the part's content is encoded according to the
44pertaining scheme and a corresponding *"Content-Transfer-Encoding"* header
45is added to the part.
47Supported encoding schemes are:
49"*binary*": the data is left unchanged, the header is added.
51"*8bit*": header added, no data change.
53"*7bit*": the data is unchanged, but is each byte is checked
54to be a 7-bit value; if not, a read error occurs.
56"*base64*": Data is converted to base64 encoding, then split in
57CRLF-terminated lines of at most 76 characters.
59"*quoted-printable*": data is encoded in quoted printable lines of
60at most 76 characters. Since the resulting size of the final data cannot be
61determined prior to reading the original data, it is left as unknown, causing
62chunked transfer in HTTP. For the same reason, this encoder may not be used
63with IMAP. This encoder targets text data that is mostly ASCII and should
64not be used with other types of data.
66If the original data is already encoded in such a scheme, a custom
67*Content-Transfer-Encoding* header should be added with
68curl_mime_headers(3) instead of setting a part encoder.
70Encoding should not be applied to multiparts, thus the use of this function on
71a part with content set with curl_mime_subparts(3) is strongly
72discouraged.
74# %PROTOCOLS%
76# EXAMPLE
78~~~c
79int main(void)
81 curl_mime *mime;
82 curl_mimepart *part;
84 CURL *curl = curl_easy_init();
85 if(curl) {
86 /* create a mime handle */
87 mime = curl_mime_init(curl);
89 /* add a part */
90 part = curl_mime_addpart(mime);
92 /* send a file */
93 curl_mime_filedata(part, "image.png");
95 /* encode file data in base64 for transfer */
96 curl_mime_encoder(part, "base64");
97 }
99~~~
101# %AVAILABILITY%
103# RETURN VALUE
105This function returns a CURLcode indicating success or error.
107CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
108libcurl-errors(3). If CURLOPT_ERRORBUFFER(3) was set with curl_easy_setopt(3)
109there can be an error message stored in the error buffer when non-zero is
110returned.
Diagnostics4 git calls · 290 ms
CallStatusSizeTime0290 ms
discover200152 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
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 · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=2
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 · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=3
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.5 KiB285 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=285
git.response.bytes=1490
git.response.cache=MISS
git.response.duration_ms=285
git.fetch.wants=bb5990c7b887e6a7617d57f0ee26c12fc90b78cd
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=1490
git.pkt.payload.max=1469
git.sideband.band1.bytes=1468
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
a5e33146ca2718aa
Request
d55b81c4…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format