Artifactspublic-v0

curl

master
ply4 git calls176 ms289 KiB2 cachedprotocol v2
224 lines8.2 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 "unitcheck.h"
25#include "urldata.h"
26#include "url.h" /* for curlx_safefree */
28struct etest {
29 const char *input;
30 size_t ilen;
31 const char *output;
32 size_t olen;
33};
35static CURLcode test_unit1302(const char *arg)
37 UNITTEST_BEGIN_SIMPLE
38 CURLcode result;
39 unsigned int i;
41 /* common base64 encoding */
42 struct etest encode[] = {
43 { "iiiiii", 1, "aQ==", 4 },
44 { "iiiiii", 2, "aWk=", 4 },
45 { "iiiiii", 3, "aWlp", 4 },
46 { "iiiiii", 4, "aWlpaQ==", 8 },
47 { "iiiiii", 5, "aWlpaWk=", 8 },
48 { "iiiiii", 6, "aWlpaWlp", 8 },
49 { "iiiiiii", 7, "aWlpaWlpaQ==", 12 },
50 { "iiiiiiii", 8, "aWlpaWlpaWk=", 12 },
51 { "iiiiiiiii", 9, "aWlpaWlpaWlp", 12 },
52 { "iiiiiiiiii", 10, "aWlpaWlpaWlpaQ==", 16 },
53 { "iiiiiiiiiii", 11, "aWlpaWlpaWlpaWk=", 16 },
54 { "iiiiiiiiiiii", 12, "aWlpaWlpaWlpaWlp", 16 },
55 { "\xff\x01\xfe\x02", 4, "/wH+Ag==", 8 },
56 { "\xff\xff\xff\xff", 4, "/////w==", 8 },
57 { "\x00\x00\x00\x00", 4, "AAAAAA==", 8 },
58 { "\x00\x00\x00\x00", 1, "AA==", 4 },
59 };
61 /* base64 URL encoding */
62 struct etest url[] = {
63 { "", 0, "", 0 },
64 { "iiiiiiiiiii", 1, "aQ", 2 },
65 { "iiiiiiiiiii", 2, "aWk", 3 },
66 { "iiiiiiiiiii", 3, "aWlp", 4 },
67 { "iiiiiiiiiii", 4, "aWlpaQ", 6 },
68 { "iiiiiiiiiii", 5, "aWlpaWk", 7 },
69 { "iiiiiiiiiii", 6, "aWlpaWlp", 8 },
70 { "iiiiiiiiiii", 7, "aWlpaWlpaQ", 10 },
71 { "iiiiiiiiiii", 8, "aWlpaWlpaWk", 11 },
72 { "iiiiiiiiiii", 9, "aWlpaWlpaWlp", 12 },
73 { "iiiiiiiiiii", 10, "aWlpaWlpaWlpaQ", 14 },
74 { "iiiiiiiiiii", 11, "aWlpaWlpaWlpaWk", 15 },
75 { "iiiiiiiiiiii", 12, "aWlpaWlpaWlpaWlp", 16 },
76 { "\xff\x01\xfe\x02", 4, "_wH-Ag", 6 },
77 { "\xff\xff\xff\xff", 4, "_____w", 6 },
78 { "\xff\x00\xff\x00", 4, "_wD_AA", 6 },
79 { "\x00\xff\x00\xff", 4, "AP8A_w", 6 },
80 { "\x00\x00\x00\x00", 4, "AAAAAA", 6 },
81 { "\x00", 1, "AA", 2 },
82 { "\x01", 1, "AQ", 2 },
83 { "\x02", 1, "Ag", 2 },
84 { "\x03", 1, "Aw", 2 },
85 { "\x04", 1, "BA", 2 }, /* spellchecker:disable-line */
86 { "\x05", 1, "BQ", 2 },
87 { "\x06", 1, "Bg", 2 },
88 { "\x07", 1, "Bw", 2 },
89 { "\x08", 1, "CA", 2 },
90 { "\x09", 1, "CQ", 2 },
91 { "\x0a", 1, "Cg", 2 },
92 { "\x0b", 1, "Cw", 2 },
93 { "\x0c", 1, "DA", 2 },
94 { "\x0d", 1, "DQ", 2 },
95 { "\x0e", 1, "Dg", 2 },
96 { "\x0f", 1, "Dw", 2 },
97 { "\x10", 1, "EA", 2 },
98 };
100 /* bad decode inputs */
101 struct etest badecode[] = {
102 { "", 0, "", 0 }, /* no dats means error */
103 { "", 0, "a", 1 }, /* data is too short */
104 { "", 0, "aQ", 2 }, /* data is too short */
105 { "", 0, "aQ=", 3 }, /* data is too short */
106 { "", 0, "====", 1 }, /* data is only padding characters */
107 { "", 0, "====", 2 }, /* data is only padding characters */
108 { "", 0, "====", 3 }, /* data is only padding characters */
109 { "", 0, "====", 4 }, /* data is only padding characters */
110 { "", 0, "a===", 4 }, /* contains three padding characters */
111 { "", 0, "a=Q=", 4 }, /* contains a padding character mid input */
112 { "", 0, "aWlpa=Q=", 8 }, /* contains a padding character mid input */
113 { "", 0, "a\x1f==", 4 }, /* contains illegal base64 character */
114 { "", 0, "abcd ", 5 }, /* contains illegal base64 character */
115 { "", 0, "abcd ", 6 }, /* contains illegal base64 character */
116 { "", 0, " abcd", 5 }, /* contains illegal base64 character */
117 { "", 0, "_abcd", 5 }, /* contains illegal base64 character */
118 { "", 0, "abcd-", 5 }, /* contains illegal base64 character */
119 { "", 0, "abcd_", 5 }, /* contains illegal base64 character */
120 { "", 0, "aWlpaWlpaQ==-", 17 }, /* bad character after padding */
121 { "", 0, "aWlpaWlpaQ==_", 17 }, /* bad character after padding */
122 { "", 0, "aWlpaWlpaQ== ", 17 }, /* bad character after padding */
123 { "", 0, "aWlpaWlpaQ=", 15 } /* unaligned size, missing a padding char */
124 };
126 for(i = 0; i < CURL_ARRAYSIZE(encode); i++) {
127 const struct etest *e = &encode[i];
128 char *out;
129 unsigned char *decoded;
130 size_t olen;
131 size_t dlen;
133 /* first encode */
134 result = curlx_base64_encode((const uint8_t *)e->input, e->ilen,
135 &out, &olen);
136 abort_unless(result == CURLE_OK, "return code should be CURLE_OK");
137 abort_unless(olen == e->olen, "wrong output size");
138 if(memcmp(out, e->output, e->olen)) {
139 curl_mfprintf(stderr, "Test %u encoded badly\n", i);
140 unitfail++;
141 }
142 curlx_safefree(out);
144 /* then verify decode */
145 result = curlx_base64_decode(e->output, &decoded, &dlen);
146 if(result != CURLE_OK) {
147 curl_mfprintf(stderr, "Test %u URL decode returned %d\n", i,
148 (int)result);
149 unitfail++;
150 }
151 if(dlen != e->ilen) {
152 curl_mfprintf(stderr, "Test %u URL decode output length %zu "
153 "instead of %zu\n", i, dlen, e->ilen);
154 unitfail++;
155 }
156 if(memcmp(decoded, e->input, dlen)) {
157 curl_mfprintf(stderr, "Test %u URL decoded badly. Got '%s', "
158 "expected '%s'\n", i, decoded, e->input);
159 unitfail++;
160 }
162 curlx_safefree(decoded);
163 }
165 {
166 unsigned char binary[256];
167 size_t length;
168 for(i = 0; i < sizeof(binary); i++)
169 binary[i] = (unsigned char)i;
170 for(length = 1; length <= sizeof(binary); length++) {
171 char *encoded;
172 unsigned char *decoded;
173 size_t enclen;
174 size_t declen;
175 result = curlx_base64_encode(binary, length, &encoded, &enclen);
176 abort_unless(result == CURLE_OK, "binary encoding failed");
177 fail_unless(enclen == (length + 2) / 3 * 4, "wrong encoded size");
178 fail_unless(!encoded[enclen], "encoded data is not terminated");
179 result = curlx_base64_decode(encoded, &decoded, &declen);
180 curlx_free(encoded);
181 abort_unless(result == CURLE_OK, "binary decoding failed");
182 fail_unless(declen == length, "wrong decoded size");
183 fail_unless(!memcmp(decoded, binary, length), "wrong decoded data");
184 fail_unless(!decoded[declen], "decoded data is not terminated");
185 curlx_free(decoded);
186 }
187 }
189 for(i = 0; i < CURL_ARRAYSIZE(url); i++) {
190 const struct etest *e = &url[i];
191 char *out;
192 size_t olen;
193 result = curlx_base64url_encode((const uint8_t *)e->input, e->ilen,
194 &out, &olen);
195 abort_unless(result == CURLE_OK, "return code should be CURLE_OK");
196 if(olen != e->olen) {
197 curl_mfprintf(stderr, "Test %u URL encoded output length %zu "
198 "instead of %zu\n", i, olen, e->olen);
199 }
200 if(out && memcmp(out, e->output, e->olen)) {
201 curl_mfprintf(stderr, "Test %u URL encoded badly. Got '%s', "
202 "expected '%s'\n", i, out, e->output);
203 unitfail++;
204 }
205 curlx_safefree(out);
206 }
208 for(i = 0; i < CURL_ARRAYSIZE(badecode); i++) {
209 struct etest *e = &badecode[i];
210 unsigned char *decoded;
211 size_t dlen;
213 /* then verify decode with illegal inputs */
214 result = curlx_base64_decode(e->output, &decoded, &dlen);
215 if(result != CURLE_BAD_CONTENT_ENCODING) {
216 curl_mfprintf(stderr, "Test %u URL bad decoded badly. "
217 "Returned '%d', expected '%d'\n",
218 i, (int)result, CURLE_BAD_CONTENT_ENCODING);
219 unitfail++;
220 }
221 }
223 UNITTEST_END_SIMPLE
Diagnostics4 git calls · 176 ms
CallStatusSizeTime0176 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
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 · 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 · hit29 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=29
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 KiB144 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=144
git.response.bytes=2411
git.response.cache=MISS
git.response.duration_ms=144
git.fetch.wants=8a0902ea6a4f805c9fa82fdbf4fc2ad2e49cd015
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=2411
git.pkt.payload.max=2390
git.sideband.band1.bytes=2389
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
a5e1fbc7f913a9c0
Request
93c64186…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format