Artifactspublic-v0

curl

master
ply4 git calls30 ms289 KiB3 cachedprotocol v2
164 lines5.4 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 email on behalf of another user with SMTP
26 * </DESC>
27 */
28#include <stdio.h>
29#include <string.h>
31#include <curl/curl.h>
33/*
34 * This is a simple example show how to send an email using libcurl's SMTP
35 * capabilities.
36 *
37 * Note that this example requires libcurl 7.66.0 or above.
38 */
40/* The libcurl options want plain addresses, the viewable headers in the mail
41 * can get a full name as well.
42 */
43#define FROM_ADDR "<ursel@example.org>"
44#define SENDER_ADDR "<kurt@example.org>"
45#define TO_ADDR "<addressee@example.net>"
47#define FROM_MAIL "Ursel " FROM_ADDR
48#define SENDER_MAIL "Kurt " SENDER_ADDR
49#define TO_MAIL "A Receiver " TO_ADDR
51static const char payload_text[] =
52 "Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n"
53 "To: " TO_MAIL "\r\n"
54 "From: " FROM_MAIL "\r\n"
55 "Sender: " SENDER_MAIL "\r\n"
56 "Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@"
57 "rfcpedant.example.org>\r\n"
58 "Subject: SMTP example message\r\n"
59 "\r\n" /* empty line to divide headers from body, see RFC 5322 */
60 "The body of the message starts here.\r\n"
61 "\r\n"
62 "It could be a lot of lines, could be MIME encoded, whatever.\r\n"
63 "Check RFC 5322.\r\n";
65struct upload_status {
66 size_t bytes_read;
67};
69static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
71 struct upload_status *upload_ctx = (struct upload_status *)userp;
72 const char *data;
73 size_t room = size * nmemb;
74 size_t len;
76 if((size == 0) || (nmemb == 0) || ((size * nmemb) < 1)) {
77 return 0;
78 }
80 data = &payload_text[upload_ctx->bytes_read];
82 len = strlen(data);
83 if(room < len)
84 len = room;
85 memcpy(ptr, data, len);
86 upload_ctx->bytes_read += len;
88 return len;
91int main(void)
93 CURL *curl;
95 CURLcode result = curl_global_init(CURL_GLOBAL_ALL);
96 if(result != CURLE_OK)
97 return (int)result;
99 curl = curl_easy_init();
100 if(curl) {
101 struct curl_slist *recipients = NULL;
102 struct upload_status upload_ctx = { 0 };
104 /* This is the URL for your mailserver. In this example we connect to the
105 smtp-submission port as we require an authenticated connection. */
106 curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com:587");
108 /* Set the username and password */
109 curl_easy_setopt(curl, CURLOPT_USERNAME, "kurt");
110 curl_easy_setopt(curl, CURLOPT_PASSWORD, "xipj3plmq");
112 /* Set the authorization identity (identity to act as) */
113 curl_easy_setopt(curl, CURLOPT_SASL_AUTHZID, "ursel");
115 /* Force PLAIN authentication */
116 curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, "AUTH=PLAIN");
118 /* Note that this option is not strictly required, omitting it results in
119 * libcurl sending the MAIL FROM command with empty sender data. All
120 * autoresponses should have an empty reverse-path, and should be directed
121 * to the address in the reverse-path which triggered them. Otherwise,
122 * they could cause an endless loop. See RFC 5321 Section 4.5.5 for more
123 * details.
124 */
125 curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM_ADDR);
127 /* Add a recipient, in this particular case it corresponds to the
128 * To: addressee in the header. */
129 recipients = curl_slist_append(recipients, TO_ADDR);
130 curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
132 /* We are using a callback function to specify the payload (the headers
133 * and body of the message). You can use the CURLOPT_READDATA option to
134 * specify a FILE pointer to read from. */
135 curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_cb);
136 curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx);
137 curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
139 /* Send the message */
140 result = curl_easy_perform(curl);
142 /* Check for errors */
143 if(result != CURLE_OK)
144 fprintf(stderr, "curl_easy_perform() failed: %s\n",
145 curl_easy_strerror(result));
147 /* Free the list of recipients */
148 curl_slist_free_all(recipients);
150 /* curl does not send the QUIT command until you call cleanup, so you
151 * should be able to reuse this connection for additional messages
152 * (setting CURLOPT_MAIL_FROM and CURLOPT_MAIL_RCPT as required, and
153 * calling curl_easy_perform() again. It may not be a good idea to keep
154 * the connection open for a long time though (more than a few minutes may
155 * result in the server timing out the connection), and you do want to
156 * clean up in the end.
157 */
158 curl_easy_cleanup(curl);
159 }
161 curl_global_cleanup();
163 return (int)result;
Diagnostics4 git calls · 30 ms
CallStatusSizeTime030 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=25
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 · hit25 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2458
git.response.cache=HIT
git.response.duration_ms=25
git.fetch.wants=0260452990c37419da873d2a34d0e52edfc0d502
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=2458
git.pkt.payload.max=2437
git.sideband.band1.bytes=2436
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
a5e1b5243feb5b65
Request
ba57f64d…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format