Artifactspublic-v0

curl

master
ply4 git calls32 ms290 KiB3 cachedprotocol v2
311 lines7.6 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 "first.h"
26#ifdef HAVE_LOCALE_H
27#include <locale.h> /* for setlocale() */
28#endif
30#if defined(UNITTESTS) && !defined(BUILDING_LIBCURL)
31#include "tool_stderr.h" /* for tool_init_stderr() */
32#endif
34int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc,
35 struct timeval *tv)
37 if(nfds < 0) {
38 SET_SOCKERRNO(SOCKEINVAL);
39 return -1;
40 }
41#ifdef USE_WINSOCK
42 /*
43 * Winsock select() requires that at least one of the three fd_set
44 * pointers is not NULL and points to a non-empty fdset. IOW Winsock
45 * select() can not be used to sleep without a single fd_set.
46 */
47 if(!nfds) {
48 Sleep((DWORD)curlx_tvtoms(tv));
49 return 0;
50 }
51#endif
52 return select(nfds, rd, wr, exc, tv);
55const char *libtest_arg2 = NULL;
56const char *libtest_arg3 = NULL;
57const char *libtest_arg4 = NULL;
58const char *libtest_arg5 = NULL;
59int test_argc;
60const char **test_argv;
61int testnum;
63struct curltime tv_test_start; /* for test timing */
65int unitfail; /* for unittests */
67int coptind;
68const char *coptarg;
70int cgetopt(int argc, const char * const argv[], const char *optstring)
72 static int optpos = 1;
73 int coptopt;
74 const char *arg;
76 if(coptind == 0) { /* Reset? */
77 coptind = !!argc;
78 optpos = 1;
79 }
81 arg = argv[coptind];
82 if(arg && !strcmp(arg, "--")) {
83 coptind++;
84 return -1;
85 }
86 else if(!arg || arg[0] != '-') {
87 return -1;
88 }
89 else {
90 const char *opt = strchr(optstring, arg[optpos]);
91 coptopt = (unsigned char)arg[optpos];
92 if(!opt) {
93 if(!arg[++optpos]) {
94 coptind++;
95 optpos = 1;
96 }
97 return '?';
98 }
99 else if(opt[1] == ':') {
100 if(arg[optpos + 1]) {
101 coptarg = arg + optpos + 1;
102 coptind++;
103 optpos = 1;
104 return coptopt;
105 }
106 else if(argv[coptind + 1]) {
107 coptarg = argv[coptind + 1];
108 coptind += 2;
109 optpos = 1;
110 return coptopt;
111 }
112 else {
113 if(!arg[++optpos]) {
114 coptind++;
115 optpos = 1;
116 }
117 return *optstring == ':' ? ':' : '?';
118 }
119 }
120 else {
121 if(!arg[++optpos]) {
122 coptind++;
123 optpos = 1;
124 }
125 return coptopt;
126 }
127 }
130#ifdef CURL_MEMDEBUG
131static void memory_tracking_init(void)
133 const char *env;
134 /* if CURL_MEMDEBUG is set, this starts memory tracking message logging */
135 env = getenv("CURL_MEMDEBUG");
136 if(env) {
137 /* use the value as filename */
138 curl_dbg_memdebug(env);
139 }
140 /* if CURL_MEMLIMIT is set, this enables fail-on-alloc-number-N feature */
141 env = getenv("CURL_MEMLIMIT");
142 if(env) {
143 curl_off_t num;
144 if(!curlx_str_number(&env, &num, LONG_MAX) && num > 0)
145 curl_dbg_memlimit((long)num);
146 }
148#else
149#define memory_tracking_init() Curl_nop_stmt
150#endif
152/* returns a hexdump in a static memory area */
153char *hexdump(const unsigned char *buf, size_t len)
155 static char dump[(200 * 3) + 1];
156 char *p = dump;
157 size_t i;
158 if(len > 200)
159 return NULL;
160 for(i = 0; i < len; i++, p += 3)
161 curl_msnprintf(p, 4, "%02x ", buf[i]);
162 return dump;
165#ifndef CURL_DISABLE_WEBSOCKETS
166CURLcode ws_send_ping(CURL *curl, const char *send_payload)
168 size_t sent;
169 CURLcode result = curl_ws_send(curl, send_payload, strlen(send_payload),
170 &sent, 0, CURLWS_PING);
171 curl_mfprintf(stderr, "ws: curl_ws_send returned %d, sent %zu\n",
172 (int)result, sent);
173 return result;
176CURLcode ws_recv_pong(CURL *curl, const char *expected_payload)
178 size_t rlen;
179 const struct curl_ws_frame *meta;
180 char buffer[256];
181 CURLcode result = curl_ws_recv(curl, buffer, sizeof(buffer), &rlen, &meta);
182 if(result) {
183 curl_mfprintf(stderr, "ws: curl_ws_recv returned %d, received %zu\n",
184 (int)result, rlen);
185 return result;
186 }
188 if(!(meta->flags & CURLWS_PONG)) {
189 curl_mfprintf(stderr, "recv_pong: wrong frame, got %zu bytes rflags %x\n",
190 rlen, (unsigned int)meta->flags);
191 return CURLE_RECV_ERROR;
192 }
194 curl_mfprintf(stderr, "ws: got PONG back\n");
195 if(rlen == strlen(expected_payload) &&
196 !memcmp(expected_payload, buffer, rlen)) {
197 curl_mfprintf(stderr, "ws: got the same payload back\n");
198 return CURLE_OK;
199 }
200 curl_mfprintf(stderr, "ws: did NOT get the same payload back\n");
201 return CURLE_RECV_ERROR;
204/* close the connection */
205void ws_close(CURL *curl)
207 size_t sent;
208 CURLcode result = curl_ws_send(curl, "", 0, &sent, 0, CURLWS_CLOSE);
209 curl_mfprintf(stderr, "ws: curl_ws_send returned %d, sent %zu\n",
210 (int)result, sent);
212#endif /* CURL_DISABLE_WEBSOCKETS */
214int main(int argc, const char *argv[])
216 const char *URL = "";
217 CURLcode result;
218 entry_func_t entry_func;
219 const char *entry_name;
220 const char *env;
221 size_t tmp;
223 CURL_MSVC_CRTDBG_INIT();
225#ifdef _WIN32
226 if(argc == 2 && !strcmp(argv[1], "--dump-module-paths")) {
227 CURL_DUMP_MODULE_PATHS(curl_mprintf);
228 return 0;
229 }
230#endif
232 CURL_BINMODE(stdout);
234 memory_tracking_init();
235#ifdef _WIN32
236 curlx_now_init();
237#endif
239 /*
240 * Setup proper locale from environment. This is needed to enable locale-
241 * specific behavior by the C library in order to test for undesired side
242 * effects that could cause in libcurl.
243 */
244#ifdef HAVE_SETLOCALE
245 setlocale(LC_ALL, "");
246#endif
248 test_argc = argc - 1;
249 test_argv = argv + 1;
251 if(argc < 2) {
252 curl_mfprintf(stderr, "Pass testname "
253 "(and URL as argument for numbered tests) please\n");
254 return 1;
255 }
257 entry_name = argv[1];
258 entry_func = NULL;
259 for(tmp = 0; s_entries[tmp].ptr; ++tmp) {
260 if(!strcmp(entry_name, s_entries[tmp].name)) {
261 entry_func = s_entries[tmp].ptr;
262 break;
263 }
264 }
266 if(!entry_func) {
267 curl_mfprintf(stderr, "Test '%s' not found.\n", entry_name);
268 return 1;
269 }
271 if(argc > 2) {
272 URL = argv[2];
273 curl_mfprintf(stderr, "URL: %s\n", URL);
274 }
276 if(argc > 3)
277 libtest_arg2 = argv[3];
279 if(argc > 4)
280 libtest_arg3 = argv[4];
282 if(argc > 5)
283 libtest_arg4 = argv[5];
285 if(argc > 6)
286 libtest_arg5 = argv[6];
288 testnum = 0;
289 env = getenv("CURL_TESTNUM");
290 if(env) {
291 curl_off_t num;
292 if(!curlx_str_number(&env, &num, INT_MAX) && num > 0)
293 testnum = (int)num;
294 }
296#if defined(UNITTESTS) && !defined(BUILDING_LIBCURL)
297 tool_init_stderr();
298#endif
300 result = entry_func(URL);
301 curl_mfprintf(stderr, "Test ended with result %d\n", (int)result);
303#ifdef _WIN32
304 /* flush buffers of all streams regardless of mode */
305 _flushall();
306#endif
308 /* Regular program status codes are limited to 0..127 and 126 and 127 have
309 * special meanings by the shell, so limit a normal return code to 125 */
310 return result <= 125 ? result : 125;
Diagnostics4 git calls · 32 ms
CallStatusSizeTime032 ms
discover200152 B3 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 · 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 · hit4 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=25
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=4
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 · hit25 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=3080
git.response.cache=HIT
git.response.duration_ms=25
git.fetch.wants=440bd07f24abdf455fa7207ef1a67030f220c63b
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=3080
git.pkt.payload.max=3059
git.sideband.band1.bytes=3058
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
a5e2dd708b50c125
Request
57a6f2c7…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format