Artifactspublic-v0

curl

master
ply4 git calls27 ms289 KiB3 cachedprotocol v2
265 lines7.2 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#include "tool_setup.h"
26#include "slist_wc.h"
28#ifndef CURL_DISABLE_LIBCURL_OPTION
30#include "tool_cfgable.h"
31#include "tool_easysrc.h"
32#include "tool_msgs.h"
34/* global variable definitions, for easy-interface source code generation */
36struct slist_wc *easysrc_decl; /* Variable declarations */
37struct slist_wc *easysrc_data; /* Build slists, forms etc. */
38struct slist_wc *easysrc_code; /* Setopt calls */
39struct slist_wc *easysrc_toohard; /* Unconvertible setopt */
40struct slist_wc *easysrc_clean; /* Clean up allocated data */
41int easysrc_mime_count;
42int easysrc_slist_count;
43static bool easysrc_performed;
45/* Set once a transfer has been performed, so that the next generated
46 statement resets the handle first: the tool uses a fresh easy handle per
47 operation, the generated code reuses one. Deferred rather than emitted
48 right after curl_easy_perform() so that no reset is generated when nothing
49 follows. */
50static bool easysrc_pending_reset = FALSE;
52static const char * const srchead[] = {
53 "/********* Sample code generated by the curl command line tool **********",
54 " * All curl_easy_setopt() options are documented at:",
55 " * https://curl.se/libcurl/c/curl_easy_setopt.html",
56 " ************************************************************************/",
57 "#include <curl/curl.h>",
58 "",
59 "int main(int argc, char *argv[])",
60 "{",
61 " CURLcode result;",
62 " CURL *curl;",
63 NULL
64};
65/* easysrc_decl declarations come here */
66/* easysrc_data initialization come here */
67/* easysrc_code statements come here */
68static const char * const srchard[] = {
69 "/* Here is a list of options the curl code used that cannot get generated",
70 " as source easily. You may choose to either not use them or implement",
71 " them yourself.",
72 "",
73 NULL
74};
75static const char * const srcend[] = {
76 "",
77 " return (int)result;",
78 "}",
79 "/**** End of sample code ****/",
80 NULL
81};
83/* Clean up all source code if we run out of memory */
84static void easysrc_free(void)
86 slist_wc_free_all(easysrc_decl);
87 easysrc_decl = NULL;
88 slist_wc_free_all(easysrc_data);
89 easysrc_data = NULL;
90 slist_wc_free_all(easysrc_code);
91 easysrc_code = NULL;
92 slist_wc_free_all(easysrc_toohard);
93 easysrc_toohard = NULL;
94 slist_wc_free_all(easysrc_clean);
95 easysrc_clean = NULL;
98/* Add a source line to the main code or remarks */
99CURLcode easysrc_add(struct slist_wc **plist, const char *line)
101 CURLcode result = CURLE_OK;
102 struct slist_wc *list;
103 if(easysrc_pending_reset && (plist == &easysrc_code)) {
104 /* cleared first: the recursive call adds to easysrc_code as well */
105 easysrc_pending_reset = FALSE;
106 result = easysrc_add(&easysrc_code, "curl_easy_reset(curl);");
107 if(result)
108 return result;
109 }
110 list = slist_wc_append(*plist, line);
111 if(!list) {
112 easysrc_free();
113 result = CURLE_OUT_OF_MEMORY;
114 }
115 else
116 *plist = list;
117 return result;
120CURLcode easysrc_addf(struct slist_wc **plist, const char *fmt, ...)
122 CURLcode result;
123 char *bufp;
124 va_list ap;
125 va_start(ap, fmt);
126 bufp = curl_mvaprintf(fmt, ap);
127 va_end(ap);
128 if(!bufp) {
129 result = CURLE_OUT_OF_MEMORY;
130 }
131 else {
132 result = easysrc_add(plist, bufp);
133 curl_free(bufp);
134 }
135 return result;
138CURLcode easysrc_init(void)
140 easysrc_performed = FALSE;
141 return easysrc_add(&easysrc_code, "curl = curl_easy_init();");
144bool easysrc_is_first(void)
146 return !easysrc_performed;
149CURLcode easysrc_perform(void)
151 CURLcode result = CURLE_OK;
152 /* Note any setopt calls which we could not convert */
153 if(easysrc_toohard) {
154 int i;
155 struct curl_slist *ptr;
156 result = easysrc_add(&easysrc_code, "");
157 /* Preamble comment */
158 for(i = 0; srchard[i] && !result; i++)
159 result = easysrc_add(&easysrc_code, srchard[i]);
160 /* Each unconverted option */
161 if(easysrc_toohard && !result) {
162 for(ptr = easysrc_toohard->first; ptr && !result; ptr = ptr->next)
163 result = easysrc_add(&easysrc_code, ptr->data);
164 }
165 if(!result)
166 result = easysrc_add(&easysrc_code, "");
167 if(!result)
168 result = easysrc_add(&easysrc_code, "*/");
170 slist_wc_free_all(easysrc_toohard);
171 easysrc_toohard = NULL;
172 }
174 if(!result)
175 result = easysrc_add(&easysrc_code, "");
176 if(!result)
177 result = easysrc_add(&easysrc_code, "result = curl_easy_perform(curl);");
178 if(!result)
179 result = easysrc_add(&easysrc_code, "");
180 if(!result)
181 easysrc_performed = TRUE;
183 /* Options set for this operation must not leak into the next one */
184 if(!result)
185 easysrc_pending_reset = TRUE;
187 return result;
190CURLcode easysrc_cleanup(void)
192 CURLcode result;
193 /* nothing follows, so no reset is needed before the cleanup */
194 easysrc_pending_reset = FALSE;
195 result = easysrc_add(&easysrc_code, "curl_easy_cleanup(curl);");
196 if(!result)
197 result = easysrc_add(&easysrc_code, "curl = NULL;");
199 return result;
202void dumpeasysrc(void)
204 struct curl_slist *ptr;
205 char *o = global->libcurl;
207 FILE *out;
208 bool fopened = FALSE;
209 if(strcmp(o, "-")) {
210 out = curlx_fopen(o, FOPEN_WRITETEXT);
211 fopened = TRUE;
212 }
213 else
214 out = stdout;
215 if(!out)
216 warnf("Failed to open %s to write libcurl code", o);
217 else {
218 int i;
219 const char *c;
221 for(i = 0; ((c = srchead[i]) != NULL); i++)
222 curl_mfprintf(out, "%s\n", c);
224 /* Declare variables used for complex setopt values */
225 if(easysrc_decl) {
226 for(ptr = easysrc_decl->first; ptr; ptr = ptr->next)
227 curl_mfprintf(out, " %s\n", ptr->data);
228 }
230 /* Set up complex values for setopt calls */
231 if(easysrc_data) {
232 curl_mfprintf(out, "\n");
234 for(ptr = easysrc_data->first; ptr; ptr = ptr->next)
235 curl_mfprintf(out, " %s\n", ptr->data);
236 }
238 curl_mfprintf(out, "\n");
239 if(easysrc_code) {
240 for(ptr = easysrc_code->first; ptr; ptr = ptr->next) {
241 if(ptr->data[0]) {
242 curl_mfprintf(out, " %s\n", ptr->data);
243 }
244 else {
245 curl_mfprintf(out, "\n");
246 }
247 }
248 }
250 if(easysrc_clean) {
251 for(ptr = easysrc_clean->first; ptr; ptr = ptr->next)
252 curl_mfprintf(out, " %s\n", ptr->data);
253 }
255 for(i = 0; ((c = srcend[i]) != NULL); i++)
256 curl_mfprintf(out, "%s\n", c);
258 if(fopened)
259 curlx_fclose(out);
260 }
262 easysrc_free();
265#endif /* CURL_DISABLE_LIBCURL_OPTION */
Diagnostics4 git calls · 27 ms
CallStatusSizeTime027 ms
discover200152 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
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=3
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.5 KiB · hit21 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=21
git.response.bytes=2538
git.response.cache=HIT
git.response.duration_ms=21
git.fetch.wants=1c2a3361792a80d031598a9f8c427b04872aab07
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=2538
git.pkt.payload.max=2517
git.sideband.band1.bytes=2516
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
a5e26ade58f1f4e0
Request
72df400a…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format