Artifactspublic-v0

curl

master
ply4 git calls397 ms289 KiB2 cachedprotocol v2
238 lines6.5 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 "testtrace.h"
26#include <toolx/tool_time.h>
28struct libtest_trace_cfg debug_config;
30static time_t epoch_offset; /* for test time tracing */
31static int known_offset; /* for test time tracing */
33void debug_dump(const char *timebuf, const char *text,
34 FILE *stream, const unsigned char *ptr,
35 size_t size, bool nohex)
37 size_t i;
38 size_t c;
40 unsigned int width = 0x10;
42 if(nohex)
43 /* without the hex output, we can fit more on screen */
44 width = 0x40;
46 curl_mfprintf(stream, "%s%s, %zu bytes (0x%zx)\n", timebuf, text,
47 size, size);
49 for(i = 0; i < size; i += width) {
51 curl_mfprintf(stream, "%04zx: ", i);
53 if(!nohex) {
54 /* hex not disabled, show it */
55 for(c = 0; c < width; c++)
56 if(i + c < size)
57 curl_mfprintf(stream, "%02x ", ptr[i + c]);
58 else
59 fputs(" ", stream);
60 }
62 for(c = 0; (c < width) && (i + c < size); c++) {
63 /* check for 0D0A; if found, skip past and start a new line of output */
64 if(nohex && (i + c + 1 < size) && ptr[i + c] == 0x0D &&
65 ptr[i + c + 1] == 0x0A) {
66 i += (c + 2 - width);
67 break;
68 }
69 curl_mfprintf(stream, "%c",
70 ((ptr[i + c] >= 0x20) && (ptr[i + c] < 0x80)) ?
71 ptr[i + c] : '.');
72 /* check again for 0D0A, to avoid an extra \n if it is at width */
73 if(nohex && (i + c + 2 < size) && ptr[i + c + 1] == 0x0D &&
74 ptr[i + c + 2] == 0x0A) {
75 i += (c + 3 - width);
76 break;
77 }
78 }
79 fputc('\n', stream); /* newline */
80 }
81 fflush(stream);
84int libtest_debug_cb(CURL *curl, curl_infotype type,
85 char *data, size_t size, void *userp)
87 struct libtest_trace_cfg *trace_cfg = userp;
88 const char *text;
89 char timebuf[20];
90 const char *timestr;
92 (void)curl;
94 timebuf[0] = '\0';
95 timestr = &timebuf[0];
97 if(trace_cfg->tracetime) {
98 CURLcode result;
99 struct tm now;
100 struct curltime tv;
101 time_t secs;
102 tv = curlx_now();
103 if(!known_offset) {
104 epoch_offset = time(NULL) - tv.tv_sec;
105 known_offset = 1;
106 }
107 secs = epoch_offset + tv.tv_sec;
108 result = toolx_localtime(secs, &now);
109 if(result)
110 memset(&now, 0, sizeof(now));
111 curl_msnprintf(timebuf, sizeof(timebuf), "%02d:%02d:%02d.%06ld ",
112 now.tm_hour, now.tm_min, now.tm_sec, (long)tv.tv_usec);
113 }
115 switch(type) {
116 case CURLINFO_TEXT:
117 curl_mfprintf(stderr, "%s== Info: %s", timestr, data);
118 return 0;
119 case CURLINFO_HEADER_OUT:
120 text = "=> Send header";
121 break;
122 case CURLINFO_DATA_OUT:
123 text = "=> Send data";
124 break;
125 case CURLINFO_SSL_DATA_OUT:
126 text = "=> Send SSL data";
127 break;
128 case CURLINFO_HEADER_IN:
129 text = "<= Recv header";
130 break;
131 case CURLINFO_DATA_IN:
132 text = "<= Recv data";
133 break;
134 case CURLINFO_SSL_DATA_IN:
135 text = "<= Recv SSL data";
136 break;
137 default: /* in case a new one is introduced to shock us */
138 return 0;
139 }
141 debug_dump(timebuf, text, stderr, (const unsigned char *)data, size,
142 trace_cfg->nohex);
143 return 0;
146static void log_line_start(FILE *log, const char *idsbuf, curl_infotype type)
148 /*
149 * This is the trace look that is similar to what libcurl makes on its
150 * own.
151 */
152 static const char * const s_infotype[] = {
153 "* ", "< ", "> ", "{ ", "} ", "{ ", "} "
154 };
155 if(idsbuf && *idsbuf)
156 curl_mfprintf(log, "%s%s", idsbuf, s_infotype[type]);
157 else
158 fputs(s_infotype[type], log);
161/* callback for CURLOPT_DEBUGFUNCTION (used in client tests) */
162int cli_debug_cb(CURL *curl, curl_infotype type,
163 char *data, size_t size, void *userp)
165 FILE *output = stderr;
166 static int newl = 0;
167 static int traced_data = 0;
168 char idsbuf[60];
169 curl_off_t xfer_id, conn_id;
171 (void)curl;
172 (void)userp;
174 if(!curl_easy_getinfo(curl, CURLINFO_XFER_ID, &xfer_id) && xfer_id >= 0) {
175 if(!curl_easy_getinfo(curl, CURLINFO_CONN_ID, &conn_id) &&
176 conn_id >= 0) {
177 curl_msnprintf(idsbuf, sizeof(idsbuf),
178 "[%" CURL_FORMAT_CURL_OFF_T "-"
179 "%" CURL_FORMAT_CURL_OFF_T "] ", xfer_id, conn_id);
180 }
181 else {
182 curl_msnprintf(idsbuf, sizeof(idsbuf),
183 "[%" CURL_FORMAT_CURL_OFF_T "-x] ", xfer_id);
184 }
185 }
186 else
187 idsbuf[0] = 0;
189 switch(type) {
190 case CURLINFO_HEADER_OUT:
191 if(size > 0) {
192 size_t st = 0;
193 size_t i;
194 for(i = 0; i < size - 1; i++) {
195 if(data[i] == '\n') { /* LF */
196 if(!newl) {
197 log_line_start(output, idsbuf, type);
198 }
199 (void)fwrite(data + st, i - st + 1, 1, output);
200 st = i + 1;
201 newl = 0;
202 }
203 }
204 if(!newl)
205 log_line_start(output, idsbuf, type);
206 (void)fwrite(data + st, i - st + 1, 1, output);
207 }
208 newl = (size && (data[size - 1] != '\n')) ? 1 : 0;
209 traced_data = 0;
210 break;
211 case CURLINFO_TEXT:
212 case CURLINFO_HEADER_IN:
213 if(!newl)
214 log_line_start(output, idsbuf, type);
215 (void)fwrite(data, size, 1, output);
216 newl = (size && (data[size - 1] != '\n')) ? 1 : 0;
217 traced_data = 0;
218 break;
219 case CURLINFO_DATA_OUT:
220 case CURLINFO_DATA_IN:
221 case CURLINFO_SSL_DATA_IN:
222 case CURLINFO_SSL_DATA_OUT:
223 if(!traced_data) {
224 if(!newl)
225 log_line_start(output, idsbuf, type);
226 curl_mfprintf(output, "[%zu bytes data]\n", size);
227 newl = 0;
228 traced_data = 1;
229 }
230 break;
231 default: /* nada */
232 newl = 0;
233 traced_data = 1;
234 break;
235 }
237 return 0;
Diagnostics4 git calls · 397 ms
CallStatusSizeTime0397 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 · hit15 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=15
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.4 KiB379 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=379
git.response.bytes=2437
git.response.cache=MISS
git.response.duration_ms=379
git.fetch.wants=2433c8488978f9142207248fd8e6f14c5881ff50
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=2437
git.pkt.payload.max=2416
git.sideband.band1.bytes=2415
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
a5e2cb3f4d2b7929
Request
6ad18f69…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format