Artifactspublic-v0

curl

master
ply4 git calls349 ms289 KiB2 cachedprotocol v2
249 lines9.9 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 "altsvc.h"
28static CURLcode test_unit1654(const char *arg)
30 UNITTEST_BEGIN_SIMPLE
32#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_ALTSVC)
33 char outname[256];
34 CURL *curl = NULL;
35 CURLcode result;
36 struct altsvcinfo *asi = Curl_altsvc_init();
37 struct altsvc *dstentry = NULL;
38 struct Curl_peer *origin = NULL;
39 const struct Curl_scheme *scheme = &Curl_scheme_https;
40 bool same_destination = FALSE;
42 abort_if(!asi, "Curl_altsvc_i");
43 result = Curl_altsvc_load(asi, arg);
44 fail_if(result, "Curl_altsvc_load");
45 if(result)
46 goto fail;
47 curl_global_init(CURL_GLOBAL_ALL);
48 curl = curl_easy_init();
49 fail_if(!curl, "curl_easy_init");
50 if(!curl)
51 goto fail;
53 fail_unless(Curl_llist_count(&asi->list) == 4, "wrong number of entries");
54 curl_msnprintf(outname, sizeof(outname), "%s-out", arg);
56 if(Curl_peer_create(curl, scheme, "example.org", 8080, &origin))
57 goto fail;
58 result = Curl_altsvc_parse(curl, asi, "h2=\"example.com:8080\"\r\n",
59 origin, ALPN_h1);
60 fail_if(result, "Curl_altsvc_parse() failed!");
61 fail_unless(Curl_llist_count(&asi->list) == 5, "wrong number of entries");
63 if(Curl_peer_create(curl, scheme, "2.example.org", 8080, &origin))
64 goto fail;
65 result = Curl_altsvc_parse(curl, asi, "h3=\":8080\"\r\n",
66 origin, ALPN_h1);
67 fail_if(result, "Curl_altsvc_parse(2) failed!");
68 fail_unless(Curl_llist_count(&asi->list) == 6, "wrong number of entries");
70 if(Curl_peer_create(curl, scheme, "3.example.org", 8080, &origin))
71 goto fail;
72 result = Curl_altsvc_parse(curl, asi,
73 "h2=\"example.com:8080\", "
74 "h3=\"yesyes.com:8080\"\r\n",
75 origin, ALPN_h1);
76 fail_if(result, "Curl_altsvc_parse(3) failed!");
77 /* that one should make two entries */
78 fail_unless(Curl_llist_count(&asi->list) == 8, "wrong number of entries");
80 if(Curl_peer_create(curl, scheme, "example.org", 80, &origin))
81 goto fail;
82 result = Curl_altsvc_parse(curl, asi,
83 "h2=\"example.com:443\"; ma = 120;\r\n",
84 origin, ALPN_h2);
85 fail_if(result, "Curl_altsvc_parse(4) failed!");
86 fail_unless(Curl_llist_count(&asi->list) == 9, "wrong number of entries");
88 /* quoted 'ma' value */
89 if(Curl_peer_create(curl, scheme, "example.net", 80, &origin))
90 goto fail;
91 result = Curl_altsvc_parse(curl, asi,
92 "h2=\"example.net:443\"; ma=\"180\";\r\n",
93 origin, ALPN_h2);
94 fail_if(result, "Curl_altsvc_parse(5) failed!");
95 fail_unless(Curl_llist_count(&asi->list) == 10, "wrong number of entries");
97 if(Curl_peer_create(curl, scheme, "curl.se", 80, &origin))
98 goto fail;
99 result = Curl_altsvc_parse(curl, asi,
100 "h2=\":443\"; ma=180, h3=\":443\"; "
101 "persist = \"1\"; ma = 120;\r\n",
102 origin, ALPN_h1);
103 fail_if(result, "Curl_altsvc_parse(6) failed!");
104 fail_unless(Curl_llist_count(&asi->list) == 12, "wrong number of entries");
106 /* clear that one again and decrease the counter */
107 result = Curl_altsvc_parse(curl, asi, "clear;\r\n",
108 origin, ALPN_h1);
109 fail_if(result, "Curl_altsvc_parse(7) failed!");
110 fail_unless(Curl_llist_count(&asi->list) == 10, "wrong number of entries");
112 result = Curl_altsvc_parse(curl, asi,
113 "h2=\":443\", h3=\":443\"; "
114 "persist = \"1\"; ma = 120;\r\n",
115 origin, ALPN_h1);
116 fail_if(result, "Curl_altsvc_parse(6) failed!");
117 fail_unless(Curl_llist_count(&asi->list) == 12, "wrong number of entries");
119 /* clear - without semicolon */
120 result = Curl_altsvc_parse(curl, asi, "clear\r\n",
121 origin, ALPN_h1);
122 fail_if(result, "Curl_altsvc_parse(7) failed!");
123 fail_unless(Curl_llist_count(&asi->list) == 10, "wrong number of entries");
125 /* only a non-existing alpn */
126 if(Curl_peer_create(curl, scheme, "5.example.net", 80, &origin))
127 goto fail;
128 result = Curl_altsvc_parse(curl, asi,
129 "h6=\"example.net:443\"; ma=\"180\";\r\n",
130 origin, ALPN_h2);
131 fail_if(result, "Curl_altsvc_parse(8) failed!");
133 /* missing quote in alpn host */
134 if(Curl_peer_create(curl, scheme, "6.example.net", 80, &origin))
135 goto fail;
136 result = Curl_altsvc_parse(curl, asi,
137 "h2=\"example.net:443,; ma=\"180\";\r\n",
138 origin, ALPN_h2);
139 fail_if(result, "Curl_altsvc_parse(9) failed!");
141 /* missing port in hostname */
142 if(Curl_peer_create(curl, scheme, "7.example.net", 80, &origin))
143 goto fail;
144 result = Curl_altsvc_parse(curl, asi,
145 "h2=\"example.net\"; ma=\"180\";\r\n",
146 origin, ALPN_h2);
147 fail_if(result, "Curl_altsvc_parse(10) failed!");
149 /* illegal port in hostname */
150 if(Curl_peer_create(curl, scheme, "8.example.net", 80, &origin))
151 goto fail;
152 result = Curl_altsvc_parse(curl, asi,
153 "h2=\"example.net:70000\"; ma=\"180\";\r\n",
154 origin, ALPN_h2);
155 fail_if(result, "Curl_altsvc_parse(11) failed!");
157 if(Curl_peer_create(curl, scheme, "test.se", 443, &origin))
158 goto fail;
159 result = Curl_altsvc_parse(curl, asi,
160 "h2=\"test2.se:443\"; ma=\"180 \" ; unknown=2, "
161 "h2=\"test3.se:443\"; ma = 120;\r\n",
162 origin, ALPN_h2);
163 fail_if(result, "Curl_altsvc_parse(12) failed!");
165 /* Unknown extension parameters must not hide later known parameters. */
166 if(Curl_peer_create(curl, scheme, "params.example", 443, &origin))
167 goto fail;
168 result = Curl_altsvc_parse(curl, asi,
169 "h2=\":443\"; long-extension-parameter=token; "
170 "ext=token; "
171 "quoted=\"a;\\\"b\"; ma=120; persist=1\r\n",
172 origin, ALPN_h1);
173 fail_if(result, "Curl_altsvc_parse(13) failed!");
174 if(!Curl_altsvc_lookup(asi, origin, ALPN_h1, &dstentry,
175 CURLALTSVC_H2, &same_destination)) {
176 fail_unless(FALSE, "alt-svc entry not found");
177 goto fail;
178 }
179 fail_unless(dstentry->expires == 1548369261 + 120,
180 "unknown parameters hid ma");
181 fail_unless(dstentry->persist, "unknown parameters hid persist");
182 fail_unless(same_destination, "wrong alt-svc destination");
184 result = Curl_altsvc_parse(curl, asi, "clear\r\n", origin, ALPN_h1);
185 fail_if(result, "Curl_altsvc_parse(14) failed!");
187 Curl_altsvc_save(curl, asi, outname);
189 /* RFC 7838 section 3: the protocol-id is a token where octets not
190 allowed in a token are percent-encoded, so "http%2F1.1" is the
191 conforming spelling of "http/1.1". See issue #23654. */
192 {
193 static const struct {
194 const char *header;
195 enum alpnid expected;
196 } cases[] = {
197 { "http%2F1.1=\":8080\"\r\n", ALPN_h1 },
198 /* Noncanonical spellings are tolerated by the URL decoder. */
199 { "http%2f1.1=\":8080\"\r\n", ALPN_h1 },
200 { "%68%32=\":8080\"\r\n", ALPN_h2 },
201 { "http%2G1.1=\":8080\"\r\n", ALPN_none },
202 { "http%2=\":8080\"\r\n", ALPN_none },
203 { "http%=\":8080\"\r\n", ALPN_none },
204 { "h2%00=\":8080\"\r\n", ALPN_none },
205 { "%00h2=\":8080\"\r\n", ALPN_none },
206 { "h2%1F=\":8080\"\r\n", ALPN_none },
207 { "=\":8080\"\r\n", ALPN_none },
208 { " =\":8080\"\r\n", ALPN_none },
209 { "http%2G1.1=\":8443\", h2=\":8080\"\r\n", ALPN_h2 },
210 { "h2%00=\":8443\", h2=\":8080\"\r\n", ALPN_h2 },
211 { "h2%1F=\":8443\", http%2F1.1=\":8080\"\r\n", ALPN_h1 },
212 { "h2=\":8080\", h2%00=\":8443\"\r\n", ALPN_h2 }
213 };
214 size_t i;
216 if(Curl_peer_create(curl, scheme, "percent.example", 443, &origin))
217 goto fail;
218 for(i = 0; i < CURL_ARRAYSIZE(cases); i++) {
219 bool found;
221 /* Each case starts without an entry for this origin. */
222 result = Curl_altsvc_parse(curl, asi, "clear\r\n", origin, ALPN_h1);
223 fail_if(result, "Curl_altsvc_parse(clear) failed!");
224 if(result)
225 goto fail;
226 result = Curl_altsvc_parse(curl, asi, cases[i].header, origin, ALPN_h1);
227 fail_if(result, cases[i].header);
228 if(result)
229 goto fail;
230 found = Curl_altsvc_lookup(asi, origin, ALPN_h1, &dstentry,
231 CURLALTSVC_H1 | CURLALTSVC_H2 | CURLALTSVC_H3,
232 &same_destination);
233 fail_unless(found == (cases[i].expected != ALPN_none), cases[i].header);
234 if(found) {
235 fail_unless(dstentry->dst.alpnid == cases[i].expected,
236 cases[i].header);
237 fail_unless(dstentry->dst.port == 8080, cases[i].header);
238 }
239 }
240 }
242fail:
243 curl_easy_cleanup(curl);
244 Curl_altsvc_cleanup(&asi);
245 Curl_peer_unlink(&origin);
246#endif
248 UNITTEST_END(curl_global_cleanup())
Diagnostics4 git calls · 349 ms
CallStatusSizeTime0349 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=344
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.3 KiB344 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2313
git.response.cache=MISS
git.response.duration_ms=344
git.fetch.wants=524b1b1d140845cd1688152ac6ec6418e4eaa2e9
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=2313
git.pkt.payload.max=2292
git.sideband.band1.bytes=2291
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
a5e2efbe3b02fda9
Request
3fd6a5a1…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format