Artifactspublic-v0

curl

master
ply4 git calls42 ms289 KiB3 cachedprotocol v2
189 lines5.0 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_xattr.h"
28#ifdef USE_XATTR
30/* returns a new URL that needs to be freed */
31/* @unittest: 1621 */
32UNITTEST char *stripcredentials(const char *url)
34 CURLU *u;
35 CURLUcode uc;
36 char *nurl;
37 u = curl_url();
38 if(u) {
39 uc = curl_url_set(u, CURLUPART_URL, url, CURLU_GUESS_SCHEME);
40 if(uc)
41 goto error;
43 uc = curl_url_set(u, CURLUPART_USER, NULL, 0);
44 if(uc)
45 goto error;
47 uc = curl_url_set(u, CURLUPART_PASSWORD, NULL, 0);
48 if(uc)
49 goto error;
51 uc = curl_url_get(u, CURLUPART_URL, &nurl, 0);
52 if(uc)
53 goto error;
55 curl_url_cleanup(u);
57 return nurl;
58 }
59error:
60 curl_url_cleanup(u);
61 return NULL;
64#ifndef _WIN32
65/* mapping table of curl metadata to extended attribute names */
66static const struct xattr_mapping {
67 const char *attr; /* name of the xattr */
68 CURLINFO info;
69} mappings[] = {
70 /* mappings proposed by
71 * https://freedesktop.org/wiki/CommonExtendedAttributes/
72 */
73 { "user.xdg.referrer.url", CURLINFO_REFERER },
74 { "user.mime_type", CURLINFO_CONTENT_TYPE },
75 { NULL, CURLINFO_NONE } /* last element, abort here */
76};
78static int xattr(int fd,
79 const char *attr, /* name of the xattr */
80 const char *value)
82 int err = 0;
83 if(value) {
84#ifdef DEBUGBUILD
85 if(getenv("CURL_FAKE_XATTR")) {
86 curl_mprintf("%s => %s\n", attr, value);
87 return 0;
88 }
89#endif
90#ifdef HAVE_FSETXATTR_6
91 err = fsetxattr(fd, attr, value, strlen(value), 0, 0);
92#elif defined(HAVE_FSETXATTR_5)
93 err = fsetxattr(fd, attr, value, strlen(value), 0);
94#elif defined(__FreeBSD_version) || defined(__MidnightBSD_version)
95 {
96 ssize_t rc = extattr_set_fd(fd, EXTATTR_NAMESPACE_USER,
97 attr, value, strlen(value));
98 /* FreeBSD's extattr_set_fd returns the length of the extended
99 attribute */
100 err = (rc < 0 ? -1 : 0);
101 }
102#endif
103 }
104 return err;
106#else
107static int win32_file_stream(CURL *curl, FILE *fs, const char *url)
109 int err = 1;
110 char *value = NULL;
111 char *nurl = stripcredentials(url);
112 CURLcode result = curl_easy_getinfo(curl, CURLINFO_REFERER, &value);
114 if(nurl && !result) {
115 err = 0;
116 err |= (fputs("[ZoneTransfer]\n", fs) == EOF);
117 if(value) {
118 err |= (fputs("ReferrerUrl=", fs) == EOF);
119 err |= (fputs(value, fs) == EOF);
120 err |= (fputs("\n", fs) == EOF);
121 }
122 err |= (fputs("HostUrl=", fs) == EOF);
123 err |= (fputs(nurl, fs) == EOF);
124 err |= (fputs("\n", fs) == EOF);
125 }
126 curl_free(nurl);
127 return err;
129#endif /* !_WIN32 */
131/* store metadata from the curl request alongside the downloaded
132 * file using extended attributes
133 */
134int fwrite_xattr(CURL *curl, const char *url, int fd, const char *filename)
136 int err;
137#ifdef _WIN32
138 char *fn_abs, *fn_stream;
139 FILE *fs;
140 (void)fd;
142 /* convert to absolute path to prevent Windows interpreting a 'X:<stream>'
143 filename as 'drive-letter:<filename>'. */
144 fn_abs = _fullpath(NULL, filename, 0);
145 if(!fn_abs)
146 return 1;
148 fn_stream = curl_maprintf("%s:%s", fn_abs, "Zone.Identifier");
149 /* !checksrc! disable BANNEDFUNC 1 */
150 free(fn_abs); /* allocated by CRT, use system free() */
151 if(!fn_stream)
152 return 1;
154 fs = curlx_fopen(fn_stream, FOPEN_WRITETEXT);
155 curl_free(fn_stream);
156 if(!fs)
157 return 1;
159#ifdef DEBUGBUILD
160 if(getenv("CURL_FAKE_XATTR"))
161 win32_file_stream(curl, stdout, url);
162#endif
163 err = win32_file_stream(curl, fs, url);
164 curlx_fclose(fs);
165#else
166 int i = 0;
167 (void)filename;
169 err = xattr(fd, "user.creator", "curl");
171 /* loop through all xattr-curlinfo pairs and abort on a set error */
172 while(!err && mappings[i].attr) {
173 char *value = NULL;
174 CURLcode result = curl_easy_getinfo(curl, mappings[i].info, &value);
175 if(!result && value)
176 err = xattr(fd, mappings[i].attr, value);
177 i++;
178 }
179 if(!err) {
180 char *nurl = stripcredentials(url);
181 if(!nurl)
182 return 1;
183 err = xattr(fd, "user.xdg.origin.url", nurl);
184 curl_free(nurl);
185 }
186#endif
187 return err;
189#endif
Diagnostics4 git calls · 42 ms
CallStatusSizeTime042 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=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 · 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 · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=37
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.1 KiB · hit37 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2147
git.response.cache=HIT
git.response.duration_ms=37
git.fetch.wants=7bf487a07783be63533635c0ace3240f7efc6561
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=2147
git.pkt.payload.max=2126
git.sideband.band1.bytes=2125
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
a5e18433e8c03014
Request
0d67b697…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format