Artifactspublic-v0

curl

master
ply4 git calls45 ms289 KiB3 cachedprotocol v2
171 lines5.7 KiBRaw
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.se/docs/copyright.html.
13 *
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24/* <DESC>
25 * Send SMTP mime emails
26 * </DESC>
27 */
28#include <stdio.h>
29#include <string.h>
31#include <curl/curl.h>
33/* This is a simple example showing how to send mime mail using libcurl's SMTP
34 * capabilities. For an example of using the multi interface please see
35 * smtp-multi.c.
36 *
37 * Note that this example requires libcurl 7.56.0 or above.
38 */
40#define FROM "<sender@example.org>"
41#define TO "<addressee@example.net>"
42#define CC "<info@example.org>"
44static const char * const headers_text[] = {
45 "Date: Tue, 22 Aug 2017 14:08:43 +0100",
46 "To: " TO,
47 "From: " FROM " (Example User)",
48 "Cc: " CC " (Another example User)",
49 "Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@"
50 "rfcpedant.example.org>",
51 "Subject: example sending a MIME-formatted message",
52 NULL
53};
55static const char inline_text[] =
56 "This is the inline text message of the email.\r\n"
57 "\r\n"
58 " It could be a lot of lines that would be displayed in an email\r\n"
59 "viewer that is not able to handle HTML.\r\n";
61static const char inline_html[] =
62 "<html><body>\r\n"
63 "<p>This is the inline <b>HTML</b> message of the email.</p>"
64 "<br />\r\n"
65 "<p>It could be a lot of HTML data that would be displayed by "
66 "email viewers able to handle HTML.</p>"
67 "</body></html>\r\n";
69int main(void)
71 CURL *curl;
73 CURLcode result = curl_global_init(CURL_GLOBAL_ALL);
74 if(result != CURLE_OK)
75 return (int)result;
77 curl = curl_easy_init();
78 if(curl) {
79 struct curl_slist *headers = NULL;
80 struct curl_slist *recipients = NULL;
81 struct curl_slist *slist = NULL;
82 curl_mime *mime;
83 curl_mime *alt;
84 curl_mimepart *part;
85 const char * const *cpp;
87 /* This is the URL for your mailserver */
88 curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com");
90 /* Note that this option is not strictly required, omitting it results in
91 * libcurl sending the MAIL FROM command with empty sender data. All
92 * autoresponses should have an empty reverse-path, and should be directed
93 * to the address in the reverse-path which triggered them. Otherwise,
94 * they could cause an endless loop. See RFC 5321 Section 4.5.5 for more
95 * details.
96 */
97 curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM);
99 /* Add two recipients, in this particular case they correspond to the
100 * To: and Cc: addressees in the header, but they could be any kind of
101 * recipient. */
102 recipients = curl_slist_append(recipients, TO);
103 recipients = curl_slist_append(recipients, CC);
104 curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
106 /* allow one of the recipients to fail and still consider it okay */
107 curl_easy_setopt(curl, CURLOPT_MAIL_RCPT_ALLOWFAILS, 1L);
109 /* Build and set the message header list. */
110 for(cpp = headers_text; *cpp; cpp++)
111 headers = curl_slist_append(headers, *cpp);
112 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
114 /* Build the mime message. */
115 mime = curl_mime_init(curl);
117 /* The inline part is an alternative proposing the html and the text
118 versions of the email. */
119 alt = curl_mime_init(curl);
121 /* HTML message. */
122 part = curl_mime_addpart(alt);
123 curl_mime_data(part, inline_html, CURL_ZERO_TERMINATED);
124 curl_mime_type(part, "text/html");
126 /* Text message. */
127 part = curl_mime_addpart(alt);
128 curl_mime_data(part, inline_text, CURL_ZERO_TERMINATED);
130 /* Create the inline part. */
131 part = curl_mime_addpart(mime);
132 curl_mime_subparts(part, alt);
133 curl_mime_type(part, "multipart/alternative");
134 slist = curl_slist_append(NULL, "Content-Disposition: inline");
135 curl_mime_headers(part, slist, 1);
137 /* Add the current source program as an attachment. */
138 part = curl_mime_addpart(mime);
139 curl_mime_filedata(part, "smtp-mime.c");
140 curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
142 /* Send the message */
143 result = curl_easy_perform(curl);
145 /* Check for errors */
146 if(result != CURLE_OK)
147 fprintf(stderr, "curl_easy_perform() failed: %s\n",
148 curl_easy_strerror(result));
150 /* Free lists. */
151 curl_slist_free_all(recipients);
152 curl_slist_free_all(headers);
154 /* curl does not send the QUIT command until you call cleanup, so you
155 * should be able to reuse this connection for additional messages
156 * (setting CURLOPT_MAIL_FROM and CURLOPT_MAIL_RCPT as required, and
157 * calling curl_easy_perform() again. It may not be a good idea to keep
158 * the connection open for a long time though (more than a few minutes may
159 * result in the server timing out the connection), and you do want to
160 * clean up in the end.
161 */
162 curl_easy_cleanup(curl);
164 /* Free multipart message. */
165 curl_mime_free(mime);
166 }
168 curl_global_cleanup();
170 return (int)result;
Diagnostics4 git calls · 45 ms
CallStatusSizeTime045 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
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=2
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
fetch2002.4 KiB · hit40 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=40
git.response.bytes=2455
git.response.cache=HIT
git.response.duration_ms=40
git.fetch.wants=4d54532559f646a2c67e37651cd93e10a9b3a1a4
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=2455
git.pkt.payload.max=2434
git.sideband.band1.bytes=2433
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
a5e1e3380bb2d96e
Request
22eb0320…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format