Artifactspublic-v0

curl

master
ply4 git calls26 ms289 KiB3 cachedprotocol v2
152 lines4.9 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 with SMTP
26 * </DESC>
27 */
28#include <stdio.h>
29#include <string.h>
31#include <curl/curl.h>
33/*
34 * For an SMTP example using the multi interface please see smtp-multi.c.
35 */
37/* The libcurl options want plain addresses, the viewable headers in the mail
38 * can get a full name as well.
39 */
40#define FROM_ADDR "<sender@example.org>"
41#define TO_ADDR "<addressee@example.net>"
42#define CC_ADDR "<info@example.org>"
44#define FROM_MAIL "Sender Person " FROM_ADDR
45#define TO_MAIL "A Receiver " TO_ADDR
46#define CC_MAIL "John CC Smith " CC_ADDR
48static const char payload_text[] =
49 "Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n"
50 "To: " TO_MAIL "\r\n"
51 "From: " FROM_MAIL "\r\n"
52 "Cc: " CC_MAIL "\r\n"
53 "Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@"
54 "rfcpedant.example.org>\r\n"
55 "Subject: SMTP example message\r\n"
56 "\r\n" /* empty line to divide headers from body, see RFC 5322 */
57 "The body of the message starts here.\r\n"
58 "\r\n"
59 "It could be a lot of lines, could be MIME encoded, whatever.\r\n"
60 "Check RFC 5322.\r\n";
62struct upload_status {
63 size_t bytes_read;
64};
66static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
68 struct upload_status *upload_ctx = (struct upload_status *)userp;
69 const char *data;
70 size_t room = size * nmemb;
71 size_t len;
73 if((size == 0) || (nmemb == 0) || ((size * nmemb) < 1)) {
74 return 0;
75 }
77 data = &payload_text[upload_ctx->bytes_read];
79 len = strlen(data);
80 if(room < len)
81 len = room;
82 memcpy(ptr, data, len);
83 upload_ctx->bytes_read += len;
85 return len;
88int main(void)
90 CURL *curl;
92 CURLcode result = curl_global_init(CURL_GLOBAL_ALL);
93 if(result != CURLE_OK)
94 return (int)result;
96 curl = curl_easy_init();
97 if(curl) {
98 struct curl_slist *recipients = NULL;
99 struct upload_status upload_ctx = { 0 };
101 /* This is the URL for your mailserver */
102 curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com");
104 /* Note that this option is not strictly required, omitting it results in
105 * libcurl sending the MAIL FROM command with empty sender data. All
106 * autoresponses should have an empty reverse-path, and should be directed
107 * to the address in the reverse-path which triggered them. Otherwise,
108 * they could cause an endless loop. See RFC 5321 Section 4.5.5 for more
109 * details.
110 */
111 curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM_ADDR);
113 /* Add two recipients, in this particular case they correspond to the
114 * To: and Cc: addressees in the header, but they could be any kind of
115 * recipient. */
116 recipients = curl_slist_append(recipients, TO_ADDR);
117 recipients = curl_slist_append(recipients, CC_ADDR);
118 curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
120 /* We are using a callback function to specify the payload (the headers
121 * and body of the message). You can use the CURLOPT_READDATA option to
122 * specify a FILE pointer to read from. */
123 curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_cb);
124 curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx);
125 curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
127 /* Send the message */
128 result = curl_easy_perform(curl);
130 /* Check for errors */
131 if(result != CURLE_OK)
132 fprintf(stderr, "curl_easy_perform() failed: %s\n",
133 curl_easy_strerror(result));
135 /* Free the list of recipients */
136 curl_slist_free_all(recipients);
138 /* curl does not send the QUIT command until you call cleanup, so you
139 * should be able to reuse this connection for additional messages
140 * (setting CURLOPT_MAIL_FROM and CURLOPT_MAIL_RCPT as required, and
141 * calling curl_easy_perform() again. It may not be a good idea to keep
142 * the connection open for a long time though (more than a few minutes may
143 * result in the server timing out the connection), and you do want to
144 * clean up in the end.
145 */
146 curl_easy_cleanup(curl);
147 }
149 curl_global_cleanup();
151 return (int)result;
Diagnostics4 git calls · 26 ms
CallStatusSizeTime026 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 · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=20
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.2 KiB · hit20 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2265
git.response.cache=HIT
git.response.duration_ms=20
git.fetch.wants=618123ab5e2db3759a0a23ec03b2093d267b75f7
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=2265
git.pkt.payload.max=2244
git.sideband.band1.bytes=2243
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
a5e2d64f1d89689d
Request
b4f48aa3…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format