Artifactspublic-v0

curl

master
ply4 git calls27 ms290 KiB3 cachedprotocol v2
326 lines9.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#include "curl_setup.h"
25#include "urldata.h"
26#include "dict.h"
28#ifndef CURL_DISABLE_DICT
30#ifdef HAVE_NETINET_IN_H
31#include <netinet/in.h>
32#endif
33#ifdef HAVE_NETDB_H
34#include <netdb.h>
35#endif
36#ifdef HAVE_ARPA_INET_H
37#include <arpa/inet.h>
38#endif
39#ifdef HAVE_NET_IF_H
40#include <net/if.h>
41#endif
42#ifdef HAVE_SYS_IOCTL_H
43#include <sys/ioctl.h>
44#endif
46#ifdef HAVE_SYS_PARAM_H
47#include <sys/param.h>
48#endif
50#ifdef HAVE_SYS_SELECT_H
51#include <sys/select.h>
52#elif defined(HAVE_UNISTD_H)
53#include <unistd.h>
54#endif
56#include "transfer.h"
57#include "curl_trc.h"
58#include "connect.h"
59#include "select.h"
60#include "escape.h"
62#define DICT_MATCH "/MATCH:"
63#define DICT_MATCH2 "/M:"
64#define DICT_MATCH3 "/FIND:"
65#define DICT_DEFINE "/DEFINE:"
66#define DICT_DEFINE2 "/D:"
67#define DICT_DEFINE3 "/LOOKUP:"
69#define DYN_DICT_WORD 10000
70static char *unescape_word(const char *input)
72 struct dynbuf out;
73 const char *ptr;
74 CURLcode result = CURLE_OK;
75 curlx_dyn_init(&out, DYN_DICT_WORD);
77 /* According to RFC2229 section 2.2, these letters need to be escaped with
78 \[letter] */
79 for(ptr = input; *ptr; ptr++) {
80 char ch = *ptr;
81 if((ch <= 32) || (ch == 127) ||
82 (ch == '\'') || (ch == '\"') || (ch == '\\'))
83 result = curlx_dyn_addn(&out, "\\", 1);
84 if(!result)
85 result = curlx_dyn_addn(&out, ptr, 1);
86 if(result)
87 return NULL;
88 }
89 return curlx_dyn_ptr(&out);
92/* sendf() sends formatted data to the server */
93static CURLcode sendf(struct Curl_easy *data,
94 const char *fmt, ...) CURL_PRINTF(2, 3);
96static CURLcode sendf(struct Curl_easy *data, const char *fmt, ...)
98 curl_socket_t sockfd = data->conn->sock[FIRSTSOCKET];
99 size_t bytes_written;
100 size_t write_len;
101 CURLcode result = CURLE_OK;
102 timediff_t timeout_ms;
103 int what;
104 char *s;
105 char *sptr;
106 va_list ap;
107 va_start(ap, fmt);
108 s = curl_mvaprintf(fmt, ap); /* returns an allocated string */
109 va_end(ap);
110 if(!s)
111 return CURLE_OUT_OF_MEMORY; /* failure */
113 bytes_written = 0;
114 write_len = strlen(s);
115 sptr = s;
117 for(;;) {
118 /* Write the buffer to the socket */
119 result = Curl_xfer_send(data, sptr, write_len, FALSE, &bytes_written);
121 if(result)
122 break;
124 Curl_debug(data, CURLINFO_DATA_OUT, sptr, bytes_written);
126 if(bytes_written != write_len) {
127 /* if not all was written at once, we must advance the pointer, decrease
128 the size left and try again! */
129 write_len -= bytes_written;
130 sptr += bytes_written;
131 }
132 else
133 break;
135 timeout_ms = Curl_timeleft_ms(data);
136 if(timeout_ms < 0) {
137 result = CURLE_OPERATION_TIMEDOUT;
138 break;
139 }
140 if(!timeout_ms)
141 timeout_ms = TIMEDIFF_T_MAX;
143 /* Do not busyloop. The entire loop thing is a workaround as it causes a
144 BLOCKING behavior which is a NO-NO. This function should rather be
145 split up in a do and a doing piece where the pieces that are not
146 possible to send now will be sent in the doing function repeatedly
147 until the entire request is sent. */
148 what = SOCKET_WRITABLE(sockfd, timeout_ms);
149 if(what < 0) {
150 result = CURLE_SEND_ERROR;
151 break;
152 }
153 else if(!what) {
154 result = CURLE_OPERATION_TIMEDOUT;
155 break;
156 }
157 }
159 curlx_free(s); /* free the output string */
161 return result;
164static CURLcode dict_do(struct Curl_easy *data, bool *done)
166 char *word;
167 char *eword = NULL;
168 char *ppath;
169 char *database = NULL;
170 char *strategy = NULL;
171 char *nthdef = NULL; /* This is not part of the protocol, but required
172 by RFC 2229 */
173 CURLcode result;
175 char *path;
177 *done = TRUE; /* unconditionally */
179 /* URL-decode path before further evaluation */
180 result = Curl_urldecode(data->state.up.path, 0, &path, NULL, REJECT_CTRL);
181 if(result)
182 return result;
184 if(curl_strnequal(path, DICT_MATCH, CURL_CSTRLEN(DICT_MATCH)) ||
185 curl_strnequal(path, DICT_MATCH2, CURL_CSTRLEN(DICT_MATCH2)) ||
186 curl_strnequal(path, DICT_MATCH3, CURL_CSTRLEN(DICT_MATCH3))) {
188 word = strchr(path, ':');
189 if(word) {
190 word++;
191 database = strchr(word, ':');
192 if(database) {
193 *database++ = (char)0;
194 strategy = strchr(database, ':');
195 if(strategy) {
196 *strategy++ = (char)0;
197 nthdef = strchr(strategy, ':');
198 if(nthdef) {
199 *nthdef = (char)0;
200 }
201 }
202 }
203 }
205 if(!word || (*word == (char)0)) {
206 infof(data, "lookup word is missing");
207 }
208 eword = unescape_word((!word || (*word == (char)0)) ? "default" : word);
209 if(!eword) {
210 result = CURLE_OUT_OF_MEMORY;
211 goto error;
212 }
214 result = sendf(data,
215 "CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\r\n"
216 "MATCH "
217 "%s " /* database */
218 "%s " /* strategy */
219 "%s\r\n" /* word */
220 "QUIT\r\n",
221 (!database || (*database == (char)0)) ? "!" : database,
222 (!strategy || (*strategy == (char)0)) ? "." : strategy,
223 eword);
225 if(result) {
226 failf(data, "Failed sending DICT request");
227 goto error;
228 }
229 Curl_xfer_setup_recv(data, FIRSTSOCKET, -1);
230 }
231 else if(curl_strnequal(path, DICT_DEFINE, CURL_CSTRLEN(DICT_DEFINE)) ||
232 curl_strnequal(path, DICT_DEFINE2, CURL_CSTRLEN(DICT_DEFINE2)) ||
233 curl_strnequal(path, DICT_DEFINE3, CURL_CSTRLEN(DICT_DEFINE3))) {
235 word = strchr(path, ':');
236 if(word) {
237 word++;
238 database = strchr(word, ':');
239 if(database) {
240 *database++ = (char)0;
241 nthdef = strchr(database, ':');
242 if(nthdef) {
243 *nthdef = (char)0;
244 }
245 }
246 }
248 if(!word || (*word == (char)0)) {
249 infof(data, "lookup word is missing");
250 }
251 eword = unescape_word((!word || (*word == (char)0)) ? "default" : word);
252 if(!eword) {
253 result = CURLE_OUT_OF_MEMORY;
254 goto error;
255 }
257 result = sendf(data,
258 "CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\r\n"
259 "DEFINE "
260 "%s " /* database */
261 "%s\r\n" /* word */
262 "QUIT\r\n",
263 (!database || (*database == (char)0)) ? "!" : database,
264 eword);
266 if(result) {
267 failf(data, "Failed sending DICT request");
268 goto error;
269 }
270 Curl_xfer_setup_recv(data, FIRSTSOCKET, -1);
271 }
272 else {
274 ppath = strchr(path, '/');
275 if(ppath) {
276 int i;
278 ppath++;
279 for(i = 0; ppath[i]; i++) {
280 if(ppath[i] == ':')
281 ppath[i] = ' ';
282 }
283 result = sendf(data,
284 "CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\r\n"
285 "%s\r\n"
286 "QUIT\r\n", ppath);
287 if(result) {
288 failf(data, "Failed sending DICT request");
289 goto error;
290 }
292 Curl_xfer_setup_recv(data, FIRSTSOCKET, -1);
293 }
294 }
296error:
297 curlx_free(eword);
298 curlx_free(path);
299 return result;
302/*
303 * DICT protocol
304 */
305const struct Curl_protocol Curl_protocol_dict = {
306 ZERO_NULL, /* setup_connection */
307 ZERO_NULL, /* setup_filters */
308 dict_do, /* do_it */
309 ZERO_NULL, /* done */
310 ZERO_NULL, /* do_more */
311 ZERO_NULL, /* connect_it */
312 ZERO_NULL, /* connecting */
313 ZERO_NULL, /* doing */
314 ZERO_NULL, /* proto_pollset */
315 ZERO_NULL, /* doing_pollset */
316 ZERO_NULL, /* domore_pollset */
317 ZERO_NULL, /* perform_pollset */
318 ZERO_NULL, /* disconnect */
319 ZERO_NULL, /* write_resp */
320 ZERO_NULL, /* write_resp_hd */
321 ZERO_NULL, /* connection_is_dead */
322 ZERO_NULL, /* attach connection */
323 ZERO_NULL, /* follow */
324};
326#endif /* CURL_DISABLE_DICT */
Diagnostics4 git calls · 27 ms
CallStatusSizeTime027 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 · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=21
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.9 KiB · hit22 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2999
git.response.cache=HIT
git.response.duration_ms=22
git.fetch.wants=7f2e0632821df9ef8dc005d189b494fc36fa9504
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=2999
git.pkt.payload.max=2978
git.sideband.band1.bytes=2977
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
a5e2ad5fc888e6b0
Request
41877a43…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format