Artifactspublic-v0

curl

master
ply4 git calls31 ms290 KiB3 cachedprotocol v2
175 lines6.3 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 email using implicit TLS
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 mail using libcurl's SMTP
34 * capabilities. It builds on the smtp-mail.c example to add authentication
35 * and, more importantly, transport security to protect the authentication
36 * details from being snooped.
37 *
38 * Note that this example requires libcurl 7.20.0 or above.
39 */
41#define FROM_MAIL "<sender@example.com>"
42#define TO_MAIL "<recipient@example.com>"
43#define CC_MAIL "<info@example.com>"
45static const char payload_text[] =
46 "Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n"
47 "To: " TO_MAIL "\r\n"
48 "From: " FROM_MAIL "\r\n"
49 "Cc: " CC_MAIL "\r\n"
50 "Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@"
51 "rfcpedant.example.org>\r\n"
52 "Subject: SMTP example message\r\n"
53 "\r\n" /* empty line to divide headers from body, see RFC 5322 */
54 "The body of the message starts here.\r\n"
55 "\r\n"
56 "It could be a lot of lines, could be MIME encoded, whatever.\r\n"
57 "Check RFC 5322.\r\n";
59struct upload_status {
60 size_t bytes_read;
61};
63static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
65 struct upload_status *upload_ctx = (struct upload_status *)userp;
66 const char *data;
67 size_t room = size * nmemb;
68 size_t len;
70 if((size == 0) || (nmemb == 0) || ((size * nmemb) < 1)) {
71 return 0;
72 }
74 data = &payload_text[upload_ctx->bytes_read];
76 len = strlen(data);
77 if(room < len)
78 len = room;
79 memcpy(ptr, data, len);
80 upload_ctx->bytes_read += len;
82 return len;
85int main(void)
87 CURL *curl;
89 CURLcode result = curl_global_init(CURL_GLOBAL_ALL);
90 if(result != CURLE_OK)
91 return (int)result;
93 curl = curl_easy_init();
94 if(curl) {
95 struct curl_slist *recipients = NULL;
96 struct upload_status upload_ctx = { 0 };
98 /* Set username and password */
99 curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
100 curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
102 /* This is the URL for your mailserver. Note the use of port 587 here,
103 * instead of the normal SMTP port (25). Port 587 is commonly used for
104 * secure mail submission (see RFC 4403), but you should use whatever
105 * matches your server configuration. */
106 curl_easy_setopt(curl, CURLOPT_URL, "smtp://mainserver.example.net:587");
108 /* In this example, we start with a plain text connection, and upgrade to
109 * Transport Layer Security (TLS) using the STARTTLS command. Be careful
110 * of using CURLUSESSL_TRY here, because if TLS upgrade fails, the
111 * transfer continues anyway - see the security discussion in the libcurl
112 * tutorial for more details. */
113 curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_ALL);
115 /* If your server does not have a valid certificate, then you can disable
116 * part of the Transport Layer Security protection by setting the
117 * CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST options to 0 (false).
118 * curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
119 * curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
120 * That is, in general, a bad idea. It is still better than sending your
121 * authentication details in plain text though. Instead, you should get
122 * the issuer certificate (or the host certificate if the certificate is
123 * self-signed) and add it to the set of certificates that are known to
124 * libcurl using CURLOPT_CAINFO and/or CURLOPT_CAPATH. See docs/SSLCERTS
125 * for more information. */
126 curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem");
128 /* Note that this option is not strictly required, omitting it results in
129 * libcurl sending the MAIL FROM command with empty sender data. All
130 * autoresponses should have an empty reverse-path, and should be directed
131 * to the address in the reverse-path which triggered them. Otherwise,
132 * they could cause an endless loop. See RFC 5321 Section 4.5.5 for more
133 * details.
134 */
135 curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM_MAIL);
137 /* Add two recipients, in this particular case they correspond to the
138 * To: and Cc: addressees in the header, but they could be any kind of
139 * recipient. */
140 recipients = curl_slist_append(recipients, TO_MAIL);
141 recipients = curl_slist_append(recipients, CC_MAIL);
142 curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
144 /* We are using a callback function to specify the payload (the headers
145 * and body of the message). You can use the CURLOPT_READDATA option to
146 * specify a FILE pointer to read from. */
147 curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_cb);
148 curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx);
149 curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
151 /* Since the traffic is encrypted, it is useful to turn on debug
152 * information within libcurl to see what is happening during the
153 * transfer.
154 */
155 curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
157 /* Send the message */
158 result = curl_easy_perform(curl);
160 /* Check for errors */
161 if(result != CURLE_OK)
162 fprintf(stderr, "curl_easy_perform() failed: %s\n",
163 curl_easy_strerror(result));
165 /* Free the list of recipients */
166 curl_slist_free_all(recipients);
168 /* Always cleanup */
169 curl_easy_cleanup(curl);
170 }
172 curl_global_cleanup();
174 return (int)result;
Diagnostics4 git calls · 31 ms
CallStatusSizeTime031 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=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 · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=25
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
fetch2002.7 KiB · hit25 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2790
git.response.cache=HIT
git.response.duration_ms=25
git.fetch.wants=c3c992717be65249e475ece6a27c3594a07e5321
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=2790
git.pkt.payload.max=2769
git.sideband.band1.bytes=2768
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
a5e19322fd7eddf0
Request
31d5cf3e…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format