Artifactspublic-v0

curl

master
ply4 git calls235 ms288 KiB2 cachedprotocol v2
84 lines1.9 KiBRaw

NAME

CURLOPT_MIMEPOST - send data from mime structure

SYNOPSIS

c
#include <curl/curl.h>

curl_mime *mime;

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MIMEPOST, mime);

DESCRIPTION

Pass a mime handle previously obtained from curl_mime_init(3).

This setting is supported by the HTTP protocol to post forms and by the SMTP and IMAP protocols to provide the email data to send/upload.

This option is the preferred way of posting an HTTP form, replacing and extending the CURLOPT_HTTPPOST(3) option.

When setting CURLOPT_MIMEPOST(3) to NULL, libcurl resets the request type for HTTP to the default to disable the POST. Typically that would mean it is reset to GET. Instead you should set a desired request method explicitly.

%PROTOCOLS%

EXAMPLE

c
int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    curl_mime *multipart = curl_mime_init(curl);
    if(multipart) {
      CURLcode result;
      curl_mimepart *part = curl_mime_addpart(multipart);
      curl_mime_name(part, "name");
      curl_mime_data(part, "daniel", CURL_ZERO_TERMINATED);
      part = curl_mime_addpart(multipart);
      curl_mime_name(part, "project");
      curl_mime_data(part, "curl", CURL_ZERO_TERMINATED);
      part = curl_mime_addpart(multipart);
      curl_mime_name(part, "logotype-image");
      curl_mime_filedata(part, "curl.png");

      /* Set the form info */
      curl_easy_setopt(curl, CURLOPT_MIMEPOST, multipart);

      result = curl_easy_perform(curl); /* post away */
      curl_mime_free(multipart); /* free the post data */
    }
    curl_easy_cleanup(curl);
  }
}

%AVAILABILITY%

RETURN VALUE

This returns CURLE_OK.

1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_MIMEPOST
5Section: 3
6Source: libcurl
7See-also:
8 - CURLOPT_HTTPPOST (3)
9 - CURLOPT_POSTFIELDS (3)
10 - CURLOPT_PUT (3)
11 - curl_mime_init (3)
12Protocol:
13 - HTTP
14 - SMTP
15 - IMAP
16Added-in: 7.56.0
17---
19# NAME
21CURLOPT_MIMEPOST - send data from mime structure
23# SYNOPSIS
25~~~c
26#include <curl/curl.h>
28curl_mime *mime;
30CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MIMEPOST, mime);
31~~~
33# DESCRIPTION
35Pass a mime handle previously obtained from curl_mime_init(3).
37This setting is supported by the HTTP protocol to post forms and by the
38SMTP and IMAP protocols to provide the email data to send/upload.
40This option is the preferred way of posting an HTTP form, replacing and
41extending the CURLOPT_HTTPPOST(3) option.
43When setting CURLOPT_MIMEPOST(3) to NULL, libcurl resets the request
44type for HTTP to the default to disable the POST. Typically that would mean it
45is reset to GET. Instead you should set a desired request method explicitly.
47# %PROTOCOLS%
49# EXAMPLE
51~~~c
52int main(void)
54 CURL *curl = curl_easy_init();
55 if(curl) {
56 curl_mime *multipart = curl_mime_init(curl);
57 if(multipart) {
58 CURLcode result;
59 curl_mimepart *part = curl_mime_addpart(multipart);
60 curl_mime_name(part, "name");
61 curl_mime_data(part, "daniel", CURL_ZERO_TERMINATED);
62 part = curl_mime_addpart(multipart);
63 curl_mime_name(part, "project");
64 curl_mime_data(part, "curl", CURL_ZERO_TERMINATED);
65 part = curl_mime_addpart(multipart);
66 curl_mime_name(part, "logotype-image");
67 curl_mime_filedata(part, "curl.png");
69 /* Set the form info */
70 curl_easy_setopt(curl, CURLOPT_MIMEPOST, multipart);
72 result = curl_easy_perform(curl); /* post away */
73 curl_mime_free(multipart); /* free the post data */
74 }
75 curl_easy_cleanup(curl);
76 }
78~~~
80# %AVAILABILITY%
82# RETURN VALUE
84This returns CURLE_OK.
Diagnostics4 git calls · 235 ms
CallStatusSizeTime0235 ms
discover200152 B2 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 · 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=230
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
fetch200977 B230 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=977
git.response.cache=MISS
git.response.duration_ms=230
git.fetch.wants=1f12908e1573341c47e139029e446e9a607e5ddc
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=977
git.pkt.payload.max=956
git.sideband.band1.bytes=955
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
a5e3547a7ba2994c
Request
02a81eb4…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format