Artifactspublic-v0

curl

master
ply4 git calls327 ms289 KiB2 cachedprotocol v2
215 lines6.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/* This is based on the PoC client of issue #11769
25 */
26#include "first.h"
28#include "testtrace.h"
30static size_t total_read = 0;
32static size_t read_callback(char *ptr, size_t size, size_t nmemb,
33 void *userdata)
35 static const size_t PAUSE_READ_AFTER = 1;
37 (void)size;
38 (void)nmemb;
39 (void)userdata;
40 if(total_read >= PAUSE_READ_AFTER) {
41 curl_mfprintf(stderr, "read_callback, return PAUSE\n");
42 return CURL_READFUNC_PAUSE;
43 }
44 else {
45 ptr[0] = '\n';
46 ++total_read;
47 curl_mfprintf(stderr, "read_callback, return 1 byte\n");
48 return 1;
49 }
52static int progress_callback(void *clientp,
53 curl_off_t dltotal,
54 curl_off_t dlnow,
55 curl_off_t ultotal,
56 curl_off_t ulnow)
58 (void)dltotal;
59 (void)dlnow;
60 (void)ultotal;
61 (void)ulnow;
62 (void)clientp;
63#if 0
64 /* Used to unpause on progress, but keeping for now. */
65 {
66 CURL *curl = (CURL *)clientp;
67 curl_easy_pause(curl, CURLPAUSE_CONT);
68#if 0
69 curl_easy_pause(curl, CURLPAUSE_RECV_CONT);
70#endif
71 }
72#endif
73 return 0;
76static void usage_upload_pausing(const char *msg)
78 if(msg)
79 curl_mfprintf(stderr, "%s\n", msg);
80 curl_mfprintf(stderr,
81 "usage: [options] url\n"
82 " upload and pause, options:\n"
83 " -V http_version (http/1.1, h2, h3) http version to use\n"
84 );
87static CURLcode test_cli_upload_pausing(const char *URL)
89 CURL *curl = NULL;
90 CURLcode result = CURLE_OK;
91 CURLU *cu;
92 struct curl_slist *resolve = NULL;
93 char resolve_buf[1024];
94 const char *url;
95 char *host = NULL, *port = NULL;
96 long http_version = CURL_HTTP_VERSION_1_1;
97 int ch;
99 (void)URL;
101 while((ch = cgetopt(test_argc, test_argv, "V:")) != -1) {
102 switch(ch) {
103 case 'V': {
104 if(!strcmp("http/1.1", coptarg))
105 http_version = CURL_HTTP_VERSION_1_1;
106 else if(!strcmp("h2", coptarg))
107 http_version = CURL_HTTP_VERSION_2_0;
108 else if(!strcmp("h3", coptarg))
109 http_version = CURL_HTTP_VERSION_3ONLY;
110 else {
111 usage_upload_pausing("invalid http version");
112 return (CURLcode)1;
113 }
114 break;
115 }
116 default:
117 usage_upload_pausing("invalid option");
118 return (CURLcode)1;
119 }
120 }
121 test_argc -= coptind;
122 test_argv += coptind;
124 if(test_argc != 1) {
125 usage_upload_pausing("not enough arguments");
126 return (CURLcode)2;
127 }
128 url = test_argv[0];
130 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
131 curl_mfprintf(stderr, "curl_global_init() failed\n");
132 return (CURLcode)3;
133 }
135 curl_global_trace("ids,time");
137 cu = curl_url();
138 if(!cu) {
139 curl_mfprintf(stderr, "out of memory\n");
140 result = (CURLcode)1;
141 goto cleanup;
142 }
143 if(curl_url_set(cu, CURLUPART_URL, url, 0)) {
144 curl_mfprintf(stderr, "not a URL: '%s'\n", url);
145 result = (CURLcode)1;
146 goto cleanup;
147 }
148 if(curl_url_get(cu, CURLUPART_HOST, &host, 0)) {
149 curl_mfprintf(stderr, "could not get host of '%s'\n", url);
150 result = (CURLcode)1;
151 goto cleanup;
152 }
153 if(curl_url_get(cu, CURLUPART_PORT, &port, 0)) {
154 curl_mfprintf(stderr, "could not get port of '%s'\n", url);
155 result = (CURLcode)1;
156 goto cleanup;
157 }
159 curl_msnprintf(resolve_buf, sizeof(resolve_buf) - 1, "%s:%s:127.0.0.1",
160 host, port);
161 resolve = curl_slist_append(resolve, resolve_buf);
163 curl = curl_easy_init();
164 if(!curl) {
165 curl_mfprintf(stderr, "out of memory\n");
166 result = (CURLcode)1;
167 goto cleanup;
168 }
169 /* We want to use our own read function. */
170 curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
172 /* It helps us to continue the read function. */
173 curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_callback);
174 curl_easy_setopt(curl, CURLOPT_XFERINFODATA, curl);
175 curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
177 /* It helps us to ensure that keepalive does not help. */
178 curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
179 curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 1L);
180 curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 1L);
181 curl_easy_setopt(curl, CURLOPT_TCP_KEEPCNT, 1L);
183 /* Enable uploading. */
184 curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
185 curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
187 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
188 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
190 if(curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L) != CURLE_OK ||
191 curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, cli_debug_cb) != CURLE_OK ||
192 curl_easy_setopt(curl, CURLOPT_RESOLVE, resolve) != CURLE_OK) {
193 curl_mfprintf(stderr, "something unexpected went wrong - bailing out!\n");
194 result = (CURLcode)2;
195 goto cleanup;
196 }
198 curl_easy_setopt(curl, CURLOPT_URL, url);
199 curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, http_version);
201 result = curl_easy_perform(curl);
203cleanup:
205 if(curl)
206 curl_easy_cleanup(curl);
207 curl_slist_free_all(resolve);
208 curl_free(host);
209 curl_free(port);
210 if(cu)
211 curl_url_cleanup(cu);
212 curl_global_cleanup();
214 return result;
Diagnostics4 git calls · 327 ms
CallStatusSizeTime0327 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=322
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 KiB322 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2177
git.response.cache=MISS
git.response.duration_ms=322
git.fetch.wants=228304368a32e2091e3b659010447c20297409ce
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=2177
git.pkt.payload.max=2156
git.sideband.band1.bytes=2155
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
a5e2ab6b9a76e6b0
Request
7725bd83…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format