Artifactspublic-v0

curl

master
ply4 git calls175 ms288 KiB2 cachedprotocol v2
86 lines1.9 KiBRaw

NAME

curl_mime_data - set a mime part's body data from memory

SYNOPSIS

c
#include <curl/curl.h>

CURLcode curl_mime_data(curl_mimepart *part, const char *data,
                        size_t datasize);

DESCRIPTION

curl_mime_data(3) sets a mime part's body content from memory data.

part is the mime part to assign contents to, created with curl_mime_addpart(3).

data points to the data that gets copied by this function. The storage may safely be reused after the call.

datasize is the number of bytes data points to. It can be set to CURL_ZERO_TERMINATED to indicate data is a null-terminated character string.

Setting a part's contents multiple times is valid: only the value set by the last call is retained. It is possible to unassign part's contents by setting data to NULL.

Setting large data is memory consuming: one might consider using curl_mime_data_cb(3) in such a case.

%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);

    /* add data to the part */
    curl_mime_data(part, "raw contents to send", CURL_ZERO_TERMINATED);
  }
}

%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_data
5Section: 3
6Source: libcurl
7See-also:
8 - curl_mime_addpart (3)
9 - curl_mime_data_cb (3)
10 - curl_mime_name (3)
11 - curl_mime_type (3)
12Protocol:
13 - HTTP
14 - IMAP
15 - SMTP
16Added-in: 7.56.0
17---
19# NAME
21curl_mime_data - set a mime part's body data from memory
23# SYNOPSIS
25~~~c
26#include <curl/curl.h>
28CURLcode curl_mime_data(curl_mimepart *part, const char *data,
29 size_t datasize);
30~~~
32# DESCRIPTION
34curl_mime_data(3) sets a mime part's body content from memory data.
36*part* is the mime part to assign contents to, created with
37curl_mime_addpart(3).
39*data* points to the data that gets copied by this function. The storage
40may safely be reused after the call.
42*datasize* is the number of bytes *data* points to. It can be set to
43*CURL_ZERO_TERMINATED* to indicate *data* is a null-terminated
44character string.
46Setting a part's contents multiple times is valid: only the value set by the
47last call is retained. It is possible to unassign part's contents by setting
48*data* to NULL.
50Setting large data is memory consuming: one might consider using
51curl_mime_data_cb(3) in such a case.
53# %PROTOCOLS%
55# EXAMPLE
57~~~c
58int main(void)
60 curl_mime *mime;
61 curl_mimepart *part;
63 CURL *curl = curl_easy_init();
64 if(curl) {
65 /* create a mime handle */
66 mime = curl_mime_init(curl);
68 /* add a part */
69 part = curl_mime_addpart(mime);
71 /* add data to the part */
72 curl_mime_data(part, "raw contents to send", CURL_ZERO_TERMINATED);
73 }
75~~~
77# %AVAILABILITY%
79# RETURN VALUE
81This function returns a CURLcode indicating success or error.
83CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
84libcurl-errors(3). If CURLOPT_ERRORBUFFER(3) was set with curl_easy_setopt(3)
85there can be an error message stored in the error buffer when non-zero is
86returned.
Diagnostics4 git calls · 175 ms
CallStatusSizeTime0175 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 · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=170
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=2
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.0 KiB170 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1061
git.response.cache=MISS
git.response.duration_ms=170
git.fetch.wants=a03f6b555b23bdc315f13cc4a316ce03fcb8f55a
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=1061
git.pkt.payload.max=1040
git.sideband.band1.bytes=1039
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
a5e324d6be0098f1
Request
6be92a48…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format