Artifactspublic-v0

curl

master
ply4 git calls273 ms289 KiB2 cachedprotocol v2
244 lines6.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#define PAUSE_TIME 5
28struct t670_ReadThis {
29 CURL *curl;
30 time_t origin;
31 int count;
32};
34static size_t t670_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
36 struct t670_ReadThis *pooh = (struct t670_ReadThis *)userp;
37 time_t delta;
39 if(size * nmemb < 1)
40 return 0;
42 switch(pooh->count++) {
43 case 0:
44 *ptr = '\x41'; /* ASCII A. */
45 return 1;
46 case 1:
47 pooh->origin = time(NULL);
48 return CURL_READFUNC_PAUSE;
49 case 2:
50 delta = time(NULL) - pooh->origin;
51 *ptr = delta >= PAUSE_TIME ? '\x42' : '\x41'; /* ASCII A or B. */
52 return 1;
53 case 3:
54 return 0;
55 }
56 curl_mfprintf(stderr, "Read callback called after EOF\n");
57 exit(1);
60static int t670_xferinfo(void *clientp,
61 curl_off_t dltotal, curl_off_t dlnow,
62 curl_off_t ultotal, curl_off_t ulnow)
64 struct t670_ReadThis *pooh = (struct t670_ReadThis *)clientp;
66 (void)dltotal;
67 (void)dlnow;
68 (void)ultotal;
69 (void)ulnow;
71 if(pooh->origin) {
72 time_t delta = time(NULL) - pooh->origin;
74 if(delta >= 4 * PAUSE_TIME) {
75 curl_mfprintf(stderr, "unpausing failed: drain problem?\n");
76 return CURLE_ABORTED_BY_CALLBACK;
77 }
79 if(delta >= PAUSE_TIME)
80 curl_easy_pause(pooh->curl, CURLPAUSE_CONT);
81 }
83 return 0;
86static CURLcode test_lib670(const char *URL)
88 static const char testname[] = "field";
89 curl_mime *mime = NULL;
90 struct curl_httppost *formpost = NULL;
91 struct t670_ReadThis pooh;
92 CURLcode result = TEST_ERR_FAILURE;
94 /*
95 * Check proper pausing/unpausing from a mime or form read callback.
96 */
98 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
99 curl_mfprintf(stderr, "curl_global_init() failed\n");
100 return TEST_ERR_MAJOR_BAD;
101 }
103 pooh.origin = (time_t)0;
104 pooh.count = 0;
105 pooh.curl = curl_easy_init();
107 /* First set the URL that is about to receive our POST. */
108 easy_setopt(pooh.curl, CURLOPT_URL, URL);
110 /* get verbose debug output please */
111 easy_setopt(pooh.curl, CURLOPT_VERBOSE, 1L);
113 /* include headers in the output */
114 easy_setopt(pooh.curl, CURLOPT_HEADER, 1L);
116 if(testnum == 670 || testnum == 671) {
117 curl_mimepart *part;
118 /* Build the mime tree. */
119 mime = curl_mime_init(pooh.curl);
120 part = curl_mime_addpart(mime);
121 result = curl_mime_name(part, testname);
122 if(result != CURLE_OK) {
123 curl_mfprintf(stderr,
124 "Something went wrong when building the "
125 "mime structure: %d\n", (int)result);
126 goto test_cleanup;
127 }
129 result = curl_mime_data_cb(part, (curl_off_t)2, t670_read_cb,
130 NULL, NULL, &pooh);
132 /* Bind mime data to its easy handle. */
133 if(result == CURLE_OK)
134 easy_setopt(pooh.curl, CURLOPT_MIMEPOST, mime);
135 }
136 else {
137 struct curl_httppost *lastptr = NULL;
138 CURLFORMcode formrc;
139 /* Build the form. */
140 formrc = curl_formadd(&formpost, &lastptr,
141 CURLFORM_COPYNAME, testname,
142 CURLFORM_STREAM, &pooh,
143 CURLFORM_CONTENTLEN, (curl_off_t)2,
144 CURLFORM_END);
145 if(formrc) {
146 curl_mfprintf(stderr, "curl_formadd() = %d\n", (int)formrc);
147 goto test_cleanup;
148 }
150 /* We want to use our own read function. */
151 easy_setopt(pooh.curl, CURLOPT_READFUNCTION, t670_read_cb);
153 /* Send a multi-part formpost. */
154 easy_setopt(pooh.curl, CURLOPT_HTTPPOST, formpost);
155 }
157 if(testnum == 670 || testnum == 672) {
158 CURLMcode mresult;
159 CURLM *multi;
160 /* Use the multi interface. */
161 multi = curl_multi_init();
162 mresult = curl_multi_add_handle(multi, pooh.curl);
163 while(!mresult) {
164 struct timeval timeout;
165 int rc = 0;
166 fd_set fdread;
167 fd_set fdwrite;
168 fd_set fdexcept;
169 int maxfd = -1;
170 int still_running = 0;
172 mresult = curl_multi_perform(multi, &still_running);
173 if(!still_running || mresult != CURLM_OK)
174 break;
176 if(pooh.origin) {
177 time_t delta = time(NULL) - pooh.origin;
179 if(delta >= 4 * PAUSE_TIME) {
180 curl_mfprintf(stderr, "unpausing failed: drain problem?\n");
181 result = CURLE_OPERATION_TIMEDOUT;
182 break;
183 }
185 if(delta >= PAUSE_TIME)
186 curl_easy_pause(pooh.curl, CURLPAUSE_CONT);
187 }
189 FD_ZERO(&fdread);
190 FD_ZERO(&fdwrite);
191 FD_ZERO(&fdexcept);
192 timeout.tv_sec = 0;
193 timeout.tv_usec = 1000000 * PAUSE_TIME / 10;
194 mresult = curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcept, &maxfd);
195 if(mresult)
196 break;
197#ifdef _WIN32
198 if(maxfd == -1)
199 curlx_wait_ms(100);
200 else
201#endif
202 rc = select(maxfd + 1, &fdread, &fdwrite, &fdexcept, &timeout);
203 if(rc == -1) {
204 curl_mfprintf(stderr, "Select error\n");
205 break;
206 }
207 }
209 if(mresult != CURLM_OK)
210 for(;;) {
211 int msgs_left;
212 CURLMsg *msg;
213 msg = curl_multi_info_read(multi, &msgs_left);
214 if(!msg)
215 break;
216 if(msg->msg == CURLMSG_DONE) {
217 result = msg->data.result;
218 }
219 }
221 curl_multi_remove_handle(multi, pooh.curl);
222 curl_multi_cleanup(multi);
223 }
224 else {
225 /* Use the easy interface. */
226 easy_setopt(pooh.curl, CURLOPT_XFERINFODATA, &pooh);
227 easy_setopt(pooh.curl, CURLOPT_XFERINFOFUNCTION, t670_xferinfo);
228 easy_setopt(pooh.curl, CURLOPT_NOPROGRESS, 0L);
229 result = curl_easy_perform(pooh.curl);
230 }
232test_cleanup:
233 curl_easy_cleanup(pooh.curl);
235 if(testnum == 670 || testnum == 671) {
236 curl_mime_free(mime);
237 }
238 else {
239 curl_formfree(formpost);
240 }
242 curl_global_cleanup();
243 return result;
Diagnostics4 git calls · 273 ms
CallStatusSizeTime0273 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 · 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 · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=268
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=2
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.5 KiB268 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2541
git.response.cache=MISS
git.response.duration_ms=268
git.fetch.wants=2daeb06576a7be0e6b8ee9abd411af6956fa06a4
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=2541
git.pkt.payload.max=2520
git.sideband.band1.bytes=2519
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
a5e31efcae289de8
Request
70a054d2…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format