Artifactspublic-v0

curl

master
ply4 git calls24 ms290 KiB3 cachedprotocol v2
280 lines8.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 "tool_cfgable.h"
27#include "tool_msgs.h"
28#include "tool_cb_dbg.h"
29#include "tool_util.h"
30#include "toolx/tool_time.h"
32/*
33 * Return the formatted HH:MM:SS for the tv_sec given.
34 */
35static const char *hms_for_sec(time_t tv_sec)
37 static time_t cached_tv_sec;
38 static char hms_buf[12];
40 if(tv_sec != cached_tv_sec) {
41 struct tm now;
42 CURLcode result = toolx_localtime(tv_sec, &now);
43 if(result)
44 memset(&now, 0, sizeof(now));
45 curl_msnprintf(hms_buf, sizeof(hms_buf), "%02d:%02d:%02d",
46 now.tm_hour, now.tm_min, now.tm_sec);
47 cached_tv_sec = tv_sec;
48 }
49 return hms_buf;
52static void log_line_start(FILE *log, const char *timebuf,
53 const char *idsbuf, curl_infotype type)
55 /*
56 * This is the trace look that is similar to what libcurl makes on its
57 * own.
58 */
59 static const char * const s_infotype[] = {
60 "* ", "< ", "> ", "{ ", "} ", "{ ", "} "
61 };
62 if((timebuf && *timebuf) || (idsbuf && *idsbuf))
63 curl_mfprintf(log, "%s%s%s", timebuf, idsbuf, s_infotype[type]);
64 else
65 fputs(s_infotype[type], log);
68static void dump(const char *timebuf, const char *idsbuf, const char *text,
69 FILE *stream, const unsigned char *ptr, size_t size,
70 trace tracetype, curl_infotype infotype)
72 size_t i;
73 size_t c;
75 unsigned int width = 0x10;
77 if(tracetype == TRACE_ASCII)
78 /* without the hex output, we can fit more on screen */
79 width = 0x40;
81 curl_mfprintf(stream, "%s%s%s, %zu bytes (0x%zx)\n", timebuf, idsbuf,
82 text, size, size);
84 for(i = 0; i < size; i += width) {
86 curl_mfprintf(stream, "%04zx: ", i);
88 if(tracetype == TRACE_BIN) {
89 /* hex not disabled, show it */
90 for(c = 0; c < width; c++)
91 if(i + c < size)
92 curl_mfprintf(stream, "%02x ", ptr[i + c]);
93 else
94 fputs(" ", stream);
95 }
97 for(c = 0; (c < width) && (i + c < size); c++) {
98 /* check for 0D0A; if found, skip past and start a new line of output */
99 if((tracetype == TRACE_ASCII) &&
100 (i + c + 1 < size) && (ptr[i + c] == 0x0D) &&
101 (ptr[i + c + 1] == 0x0A)) {
102 i += (c + 2 - width);
103 break;
104 }
105 (void)infotype;
106 curl_mfprintf(stream, "%c",
107 ((ptr[i + c] >= 0x20) && (ptr[i + c] < 0x7F)) ?
108 ptr[i + c] : UNPRINTABLE_CHAR);
109 /* check again for 0D0A, to avoid an extra \n if it is at width */
110 if((tracetype == TRACE_ASCII) &&
111 (i + c + 2 < size) && (ptr[i + c + 1] == 0x0D) &&
112 (ptr[i + c + 2] == 0x0A)) {
113 i += (c + 3 - width);
114 break;
115 }
116 }
117 fputc('\n', stream); /* newline */
118 }
119 fflush(stream);
122#define TRC_IDS_FORMAT_IDS_1 "[%" CURL_FORMAT_CURL_OFF_T "-x] "
123#define TRC_IDS_FORMAT_IDS_2 "[%" CURL_FORMAT_CURL_OFF_T "-%" \
124 CURL_FORMAT_CURL_OFF_T "] "
125/*
126 * callback for CURLOPT_DEBUGFUNCTION
127 */
128int tool_debug_cb(CURL *handle, curl_infotype type,
129 char *data, size_t size,
130 void *userdata)
132 FILE *output = tool_stderr;
133 const char *text;
134 struct timeval tv;
135 char timebuf[20];
136 /* largest signed 64-bit is: 9,223,372,036,854,775,807
137 * max length in decimal: 1 + (6 * 3) = 19
138 * formatted via TRC_IDS_FORMAT_IDS_2 this becomes 2 + 19 + 1 + 19 + 2 = 43
139 * negative xfer-id are not printed, negative conn-ids use TRC_IDS_FORMAT_1
140 */
141 char idsbuf[60];
142 curl_off_t xfer_id, conn_id;
144 (void)handle;
145 (void)userdata;
147 if(global->tracetime) {
148 tv = tvrealnow();
149 curl_msnprintf(timebuf, sizeof(timebuf), "%s.%06ld ",
150 hms_for_sec(tv.tv_sec), (long)tv.tv_usec);
151 }
152 else
153 timebuf[0] = 0;
155 if(handle && global->traceids &&
156 !curl_easy_getinfo(handle, CURLINFO_XFER_ID, &xfer_id) && xfer_id >= 0) {
157 if(!curl_easy_getinfo(handle, CURLINFO_CONN_ID, &conn_id) &&
158 conn_id >= 0) {
159 curl_msnprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_2,
160 xfer_id, conn_id);
161 }
162 else {
163 curl_msnprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_1, xfer_id);
164 }
165 }
166 else
167 idsbuf[0] = 0;
169 if(!global->trace_stream) {
170 /* open for append */
171 if(!strcmp("-", global->trace_dump))
172 global->trace_stream = stdout;
173 else if(!strcmp("%", global->trace_dump))
174 /* Ok, this is somewhat hackish but we do it undocumented for now */
175 global->trace_stream = tool_stderr;
176 else {
177 global->trace_stream = curlx_fopen(global->trace_dump, FOPEN_WRITETEXT);
178 global->trace_fopened = TRUE;
179 }
180 }
182 if(global->trace_stream)
183 output = global->trace_stream;
185 if(!output) {
186 warnf("Failed to create/open output");
187 return 0;
188 }
190 if(global->tracetype == TRACE_PLAIN) {
191 static bool newl = FALSE;
192 static bool traced_data = FALSE;
194 switch(type) {
195 case CURLINFO_HEADER_OUT:
196 if(size > 0) {
197 size_t st = 0;
198 size_t i;
199 for(i = 0; i < size - 1; i++) {
200 if(data[i] == '\n') { /* LF */
201 if(!newl) {
202 log_line_start(output, timebuf, idsbuf, type);
203 }
204 (void)fwrite(data + st, i - st + 1, 1, output);
205 st = i + 1;
206 newl = FALSE;
207 }
208 }
209 if(!newl)
210 log_line_start(output, timebuf, idsbuf, type);
211 (void)fwrite(data + st, i - st + 1, 1, output);
212 }
213 newl = (size && (data[size - 1] != '\n'));
214 traced_data = FALSE;
215 break;
216 case CURLINFO_TEXT:
217 case CURLINFO_HEADER_IN:
218 if(!newl)
219 log_line_start(output, timebuf, idsbuf, type);
220 (void)fwrite(data, size, 1, output);
221 newl = (size && (data[size - 1] != '\n'));
222 traced_data = FALSE;
223 break;
224 case CURLINFO_DATA_OUT:
225 case CURLINFO_DATA_IN:
226 case CURLINFO_SSL_DATA_IN:
227 case CURLINFO_SSL_DATA_OUT:
228 if(!traced_data &&
229 /* if the data is output to a tty and we are sending this debug trace
230 to stderr or stdout, we do not display the alert about the data not
231 being shown as the data _is_ shown then not via this function */
232 (!global->isatty ||
233 ((output != tool_stderr) && (output != stdout)))) {
234 if(!newl)
235 log_line_start(output, timebuf, idsbuf, type);
236 curl_mfprintf(output, "[%zu bytes data]\n", size);
237 newl = FALSE;
238 traced_data = TRUE;
239 }
240 break;
241 default: /* nada */
242 newl = FALSE;
243 traced_data = FALSE;
244 break;
245 }
247 return 0;
248 }
250 switch(type) {
251 case CURLINFO_TEXT:
252 curl_mfprintf(output, "%s%s* %.*s", timebuf, idsbuf, (int)size, data);
253 FALLTHROUGH();
254 default: /* in case a new one is introduced to shock us */
255 return 0;
257 case CURLINFO_HEADER_OUT:
258 text = "=> Send header";
259 break;
260 case CURLINFO_DATA_OUT:
261 text = "=> Send data";
262 break;
263 case CURLINFO_HEADER_IN:
264 text = "<= Recv header";
265 break;
266 case CURLINFO_DATA_IN:
267 text = "<= Recv data";
268 break;
269 case CURLINFO_SSL_DATA_IN:
270 text = "<= Recv SSL data";
271 break;
272 case CURLINFO_SSL_DATA_OUT:
273 text = "=> Send SSL data";
274 break;
275 }
277 dump(timebuf, idsbuf, text, output, (unsigned char *)data, size,
278 global->tracetype, type);
279 return 0;
Diagnostics4 git calls · 24 ms
CallStatusSizeTime024 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=19
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
fetch2003.0 KiB · hit19 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=3070
git.response.cache=HIT
git.response.duration_ms=19
git.fetch.wants=ea2ec964b08d59210e5161f61ae3052360ceeaea
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=3070
git.pkt.payload.max=3049
git.sideband.band1.bytes=3048
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
a5e2ae59d9cfe6b0
Request
0dfe7824…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format