Artifactspublic-v0

curl

master
ply4 git calls27 ms289 KiB3 cachedprotocol v2
245 lines6.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#include "tool_setup.h"
26#include "tool_operate.h"
27#include "tool_cfgable.h"
28#include "tool_doswin.h"
29#include "tool_operhlp.h"
30#include "tool_msgs.h"
32void clean_getout(struct OperationConfig *config)
34 if(config) {
35 struct getout *next;
36 struct getout *node = config->url_list;
38 while(node) {
39 next = node->next;
40 curlx_safefree(node->url);
41 curlx_safefree(node->outfile);
42 curlx_safefree(node->infile);
43 curlx_safefree(node);
44 node = next;
45 }
46 config->url_list = NULL;
47 single_transfer_cleanup();
48 }
51bool output_expected(const char *url, const char *uploadfile)
53 if(!uploadfile)
54 return TRUE; /* download */
55 if(checkprefix("http://", url) || checkprefix("https://", url))
56 return TRUE; /* HTTP(S) upload */
58 return FALSE; /* non-HTTP upload, probably no output should be expected */
61bool stdin_upload(const char *uploadfile)
63 return !strcmp(uploadfile, "-") || !strcmp(uploadfile, ".");
66/* Convert a CURLUcode into a CURLcode */
67CURLcode urlerr_cvt(CURLUcode ucode)
69 if(ucode == CURLUE_OUT_OF_MEMORY)
70 return CURLE_OUT_OF_MEMORY;
71 else if(ucode == CURLUE_UNSUPPORTED_SCHEME)
72 return CURLE_UNSUPPORTED_PROTOCOL;
73 else if(ucode == CURLUE_LACKS_IDN)
74 return CURLE_NOT_BUILT_IN;
75 else if(ucode == CURLUE_BAD_HANDLE)
76 return CURLE_BAD_FUNCTION_ARGUMENT;
77 return CURLE_URL_MALFORMAT;
80/*
81 * Adds the filename to the URL if it does not already have one.
82 * URL is freed before return if the returned pointer is different
83 */
84CURLcode add_file_name_to_url(CURL *curl, char **inurlp, const char *filename)
86 CURLcode result = CURLE_OUT_OF_MEMORY;
87 CURLUcode uerr;
88 CURLU *uh = curl_url();
89 char *path = NULL;
90 char *query = NULL;
91 if(uh) {
92 const char *ptr;
93 uerr = curl_url_set(uh, CURLUPART_URL, *inurlp,
94 CURLU_GUESS_SCHEME | CURLU_NON_SUPPORT_SCHEME);
95 if(uerr) {
96 result = urlerr_cvt(uerr);
97 goto out;
98 }
99 uerr = curl_url_get(uh, CURLUPART_PATH, &path, 0);
100 if(uerr) {
101 result = urlerr_cvt(uerr);
102 goto out;
103 }
104 uerr = curl_url_get(uh, CURLUPART_QUERY, &query, 0);
105 if(uerr == CURLUE_OUT_OF_MEMORY) {
106 result = urlerr_cvt(uerr);
107 goto out;
108 }
109 if(!uerr && query) {
110 curl_free(query);
111 result = CURLE_OK;
112 goto out;
113 }
114 ptr = strrchr(path, '/');
115 if(!ptr || !*++ptr) {
116 /* The URL path has no filename part, add the local filename. In order
117 to be able to do so, we have to create a new URL in another buffer.*/
119 /* We only want the part of the local path that is on the right
120 side of the rightmost slash and backslash. */
121 const char *filep = strrchr(filename, '/');
122 const char *file2 = strrchr(filep ? filep : filename, '\\');
123 char *encfile;
125 if(file2)
126 filep = file2 + 1;
127 else if(filep)
128 filep++;
129 else
130 filep = filename;
132 /* URL encode the filename */
133 encfile = curl_easy_escape(curl, filep, 0 /* use strlen */);
134 if(encfile) {
135 char *newpath;
136 char *newurl;
137 if(ptr)
138 /* there is a trailing slash on the path */
139 newpath = curl_maprintf("%s%s", path, encfile);
140 else
141 /* there is no trailing slash on the path */
142 newpath = curl_maprintf("%s/%s", path, encfile);
144 curl_free(encfile);
146 if(!newpath)
147 goto out;
148 uerr = curl_url_set(uh, CURLUPART_PATH, newpath, 0);
149 curl_free(newpath);
150 if(uerr) {
151 result = urlerr_cvt(uerr);
152 goto out;
153 }
154 uerr = curl_url_get(uh, CURLUPART_URL, &newurl,
155 CURLU_DEFAULT_SCHEME | CURLU_NO_GUESS_SCHEME);
156 if(uerr) {
157 result = urlerr_cvt(uerr);
158 goto out;
159 }
160 curlx_free(*inurlp);
161 /* make it owned by tool memory */
162 *inurlp = curlx_strdup(newurl);
163 curl_free(newurl);
164 if(*inurlp)
165 result = CURLE_OK;
166 else
167 result = CURLE_OUT_OF_MEMORY;
168 }
169 }
170 else
171 result = CURLE_OK; /* nothing to do */
172 }
173out:
174 curl_url_cleanup(uh);
175 curl_free(path);
176 return result;
179#define DEFAULT_FILENAME "curl_response"
181/* Extracts the name portion of the URL.
182 * Returns a pointer to a heap-allocated string or NULL if
183 * no name part, at location indicated by first argument.
184 */
185CURLcode get_url_file_name(char **filename, const char *url, SANITIZEcode *sc)
187 CURLU *uh = curl_url();
188 char *path = NULL;
189 CURLUcode uerr;
191 *sc = SANITIZE_ERR_OK;
193 if(!uh)
194 return CURLE_OUT_OF_MEMORY;
196 *filename = NULL;
198 uerr = curl_url_set(uh, CURLUPART_URL, url, CURLU_GUESS_SCHEME);
199 if(!uerr) {
200 uerr = curl_url_get(uh, CURLUPART_PATH, &path, 0);
201 curl_url_cleanup(uh);
202 uh = NULL;
203 if(!uerr) {
204 char *pc = NULL, *pc2 = NULL;
205 char *end = path + strlen(path);
206 /* Remove the entire trailing separator run before searching the path. */
207 while(end > path && (end[-1] == '/' || end[-1] == '\\'))
208 *--end = 0;
209 pc = strrchr(path, '/');
210 pc2 = strrchr(pc ? pc + 1 : path, '\\');
211 if(pc2)
212 pc = pc2;
214 if(pc) {
215 /* duplicate the string beyond the slash */
216 *filename = curlx_strdup(pc + 1);
217 }
218 else {
219 /* no slash => empty string, use default */
220 *filename = curlx_strdup(DEFAULT_FILENAME);
221 if(*filename)
222 warnf("No remote filename, uses \"" DEFAULT_FILENAME "\"");
223 }
225 curl_free(path);
226 if(!*filename)
227 return CURLE_OUT_OF_MEMORY;
229#if defined(_WIN32) || defined(MSDOS)
230 {
231 char *sanitized;
232 *sc = sanitize_file_name(&sanitized, *filename, 0);
233 curlx_safefree(*filename);
234 if(*sc)
235 return CURLE_BAD_FUNCTION_ARGUMENT;
236 *filename = sanitized;
237 }
238#endif /* _WIN32 || MSDOS */
240 return CURLE_OK;
241 }
242 }
243 curl_url_cleanup(uh);
244 return urlerr_cvt(uerr);
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=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 · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=2
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=23
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.5 KiB · hit23 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2610
git.response.cache=HIT
git.response.duration_ms=23
git.fetch.wants=91c116f14a949c6ae265dbcedf2dc4892e09167d
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=2610
git.pkt.payload.max=2589
git.sideband.band1.bytes=2588
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
a5e2c003386e89da
Request
bc9a1d91…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format