master
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"
26#if !defined(CURL_DISABLE_HTTP) && defined(USE_NGHTTP2)
27#include <nghttp2/nghttp2.h>
29#include "urldata.h"
30#include "ngh2_shim.h"
33bool Curl_ngh2_valid(struct curl_ngh2 *ngh2)
34{
35 return ngh2->s && !ngh2->fatal_rv;
36}
38bool Curl_ngh2_is_fatal(struct curl_ngh2 *ngh2, int rv)
39{
40 if(ngh2->fatal_rv)
41 return TRUE;
42 if(nghttp2_is_fatal(rv)) {
43 ngh2->fatal_rv = rv;
44 return TRUE;
45 }
46 return FALSE;
47}
49int Curl_ngh2_fatal(struct curl_ngh2 *ngh2)
50{
51 return ngh2->fatal_rv;
52}
54static int ngh2_check(struct curl_ngh2 *ngh2, int rv)
55{
56 if(nghttp2_is_fatal(rv))
57 ngh2->fatal_rv = rv;
58 return rv;
59}
61static int32_t ngh2_check32(struct curl_ngh2 *ngh2, int32_t rv)
62{
63 if((rv < 0) && nghttp2_is_fatal((int)rv))
64 ngh2->fatal_rv = (int)rv;
65 return rv;
66}
68static ssize_t ngh2_checks(struct curl_ngh2 *ngh2, ssize_t rv)
69{
70 if((rv < 0) && nghttp2_is_fatal((int)rv))
71 ngh2->fatal_rv = (int)rv;
72 return rv;
73}
75void Curl_ngh2_del(struct curl_ngh2 *ngh2)
76{
77 if(ngh2->s) {
78 nghttp2_session_del(ngh2->s);
79 ngh2->s = NULL;
80 }
81}
83int Curl_ngh2_submit_settings(struct curl_ngh2 *ngh2,
84 uint8_t flags,
85 const nghttp2_settings_entry *iv,
86 size_t niv)
87{
88 if(ngh2->fatal_rv)
89 return ngh2->fatal_rv;
90 return ngh2_check(ngh2, nghttp2_submit_settings(ngh2->s, flags, iv, niv));
91}
93void *Curl_ngh2_session_get_stream_user_data(struct curl_ngh2 *ngh2,
94 int32_t stream_id)
95{
96 if(ngh2->fatal_rv)
97 return NULL;
98 return nghttp2_session_get_stream_user_data(ngh2->s, stream_id);
99}
101int Curl_ngh2_session_set_stream_user_data(
102 struct curl_ngh2 *ngh2, int32_t stream_id, void *stream_user_data)
103{
104 if(ngh2->fatal_rv)
105 return ngh2->fatal_rv;
106 return ngh2_check(ngh2,
107 nghttp2_session_set_stream_user_data(
108 ngh2->s, stream_id, stream_user_data));
109}
111uint32_t Curl_ngh2_session_get_remote_settings(
112 struct curl_ngh2 *ngh2, nghttp2_settings_id id)
113{
114 if(!Curl_ngh2_valid(ngh2))
115 return 0;
116 return nghttp2_session_get_remote_settings(ngh2->s, id);
117}
119int32_t Curl_ngh2_session_get_stream_effective_local_window_size(
120 struct curl_ngh2 *ngh2, int32_t stream_id)
121{
122 if(ngh2->fatal_rv)
123 return 0;
124 return nghttp2_session_get_stream_effective_local_window_size(
125 ngh2->s, stream_id);
126}
128int32_t Curl_ngh2_session_get_local_window_size(
129 struct curl_ngh2 *ngh2)
130{
131 if(ngh2->fatal_rv)
132 return 0;
133 return nghttp2_session_get_local_window_size(ngh2->s);
134}
136int32_t Curl_ngh2_session_get_stream_remote_window_size(
137 struct curl_ngh2 *ngh2, int32_t stream_id)
138{
139 if(ngh2->fatal_rv)
140 return 0;
141 return nghttp2_session_get_stream_remote_window_size(ngh2->s, stream_id);
142}
144int32_t Curl_ngh2_session_get_remote_window_size(
145 struct curl_ngh2 *ngh2)
146{
147 if(ngh2->fatal_rv)
148 return 0;
149 return nghttp2_session_get_remote_window_size(ngh2->s);
150}
152int Curl_ngh2_session_set_local_window_size(
153 struct curl_ngh2 *ngh2, uint8_t flags,
154 int32_t stream_id, int32_t window_size)
155{
156 if(ngh2->fatal_rv)
157 return ngh2->fatal_rv;
158 return ngh2_check(ngh2, nghttp2_session_set_local_window_size(
159 ngh2->s, flags, stream_id, window_size));
160}
162int Curl_ngh2_submit_window_update(struct curl_ngh2 *ngh2,
163 uint8_t flags,
164 int32_t stream_id,
165 int32_t window_size_increment)
166{
167 if(ngh2->fatal_rv)
168 return ngh2->fatal_rv;
169 return ngh2_check(ngh2, nghttp2_submit_window_update(
170 ngh2->s, flags, stream_id, window_size_increment));
171}
173int Curl_ngh2_submit_rst_stream(
174 struct curl_ngh2 *ngh2, uint8_t flags,
175 int32_t stream_id, uint32_t error_code)
176{
177 if(ngh2->fatal_rv)
178 return ngh2->fatal_rv;
179 return ngh2_check(ngh2, nghttp2_submit_rst_stream(
180 ngh2->s, flags, stream_id, error_code));
181}
183int Curl_ngh2_session_send(struct curl_ngh2 *ngh2)
184{
185 int rv;
186 if(ngh2->fatal_rv)
187 return ngh2->fatal_rv;
188 rv = ngh2_check(ngh2, nghttp2_session_send(ngh2->s));
189 /* a callback might trigger a fatal state without session_send()
190 * noticing. Check again. */
191 return ngh2->fatal_rv ? ngh2->fatal_rv : rv;
192}
194int Curl_ngh2_session_client_new3(
195 struct curl_ngh2 *ngh2, const nghttp2_session_callbacks *callbacks,
196 void *user_data, const nghttp2_option *option, nghttp2_mem *mem)
197{
198 if(ngh2->s)
199 ngh2->fatal_rv = NGHTTP2_ERR_FATAL;
200 if(ngh2->fatal_rv)
201 return ngh2->fatal_rv;
202 return ngh2_check(ngh2,
203 nghttp2_session_client_new3(
204 &(ngh2->s), callbacks, user_data, option, mem));
205}
207int Curl_ngh2_session_want_read(struct curl_ngh2 *ngh2)
208{
209 if(!Curl_ngh2_valid(ngh2))
210 return 0;
211 return nghttp2_session_want_read(ngh2->s);
212}
214int Curl_ngh2_session_want_write(struct curl_ngh2 *ngh2)
215{
216 if(!Curl_ngh2_valid(ngh2))
217 return 0;
218 return nghttp2_session_want_write(ngh2->s);
219}
221ssize_t Curl_ngh2_session_mem_recv(
222 struct curl_ngh2 *ngh2, const uint8_t *in, size_t inlen)
223{
224 ssize_t rv;
225 if(ngh2->fatal_rv)
226 return ngh2->fatal_rv;
227 rv = ngh2_checks(ngh2, nghttp2_session_mem_recv(ngh2->s, in, inlen));
228 /* the session might encounter a fatal state in a callback,
229 * but session_mem_rec() might not notice and return a non-error.
230 * Check again. */
231 return ngh2->fatal_rv ? ngh2->fatal_rv : rv;
232}
234int Curl_ngh2_session_check_request_allowed(struct curl_ngh2 *ngh2)
235{
236 if(!Curl_ngh2_valid(ngh2))
237 return 0;
238 return nghttp2_session_check_request_allowed(ngh2->s);
239}
241int Curl_ngh2_submit_ping(
242 struct curl_ngh2 *ngh2, uint8_t flags, const uint8_t *opaque_data)
243{
244 if(ngh2->fatal_rv)
245 return ngh2->fatal_rv;
246 return ngh2_check(ngh2,
247 nghttp2_submit_ping(ngh2->s, flags, opaque_data));
248}
250int32_t Curl_ngh2_session_get_stream_effective_recv_data_length(
251 struct curl_ngh2 *ngh2, int32_t stream_id)
252{
253 if(!Curl_ngh2_valid(ngh2))
254 return 0;
255 return nghttp2_session_get_stream_effective_recv_data_length(
256 ngh2->s, stream_id);
257}
259int Curl_ngh2_session_resume_data(
260 struct curl_ngh2 *ngh2, int32_t stream_id)
261{
262 if(ngh2->fatal_rv)
263 return ngh2->fatal_rv;
264 return ngh2_check(ngh2,
265 nghttp2_session_resume_data(ngh2->s, stream_id));
266}
268int Curl_ngh2_session_consume(
269 struct curl_ngh2 *ngh2, int32_t stream_id, size_t size)
270{
271 if(ngh2->fatal_rv)
272 return ngh2->fatal_rv;
273 return ngh2_check(ngh2,
274 nghttp2_session_consume(ngh2->s, stream_id, size));
275}
277int Curl_ngh2_submit_priority(
278 struct curl_ngh2 *ngh2, uint8_t flags,
279 int32_t stream_id, const nghttp2_priority_spec *pri_spec)
280{
281 if(ngh2->fatal_rv)
282 return ngh2->fatal_rv;
283 return ngh2_check(ngh2,
284 nghttp2_submit_priority(ngh2->s, flags, stream_id, pri_spec));
285}
287int32_t Curl_ngh2_submit_request(
288 struct curl_ngh2 *ngh2, const nghttp2_priority_spec *pri_spec,
289 const nghttp2_nv *nva, size_t nvlen, const nghttp2_data_provider *data_prd,
290 void *stream_user_data)
291{
292 if(ngh2->fatal_rv)
293 return (int32_t)ngh2->fatal_rv;
294 return ngh2_check32(ngh2,
295 nghttp2_submit_request(ngh2->s, pri_spec, nva, nvlen,
296 data_prd, stream_user_data));
297}
299int Curl_ngh2_session_upgrade2(
300 struct curl_ngh2 *ngh2, const uint8_t *settings_payload,
301 size_t settings_payloadlen, int head_request, void *stream_user_data)
302{
303 if(ngh2->fatal_rv)
304 return ngh2->fatal_rv;
305 return ngh2_check(ngh2,
306 nghttp2_session_upgrade2(ngh2->s, settings_payload,
307 settings_payloadlen, head_request, stream_user_data));
308}
310int Curl_ngh2_submit_goaway(
311 struct curl_ngh2 *ngh2, uint8_t flags, int32_t last_stream_id,
312 uint32_t error_code, const uint8_t *opaque_data, size_t opaque_data_len)
313{
314 if(ngh2->fatal_rv)
315 return ngh2->fatal_rv;
316 return ngh2_check(ngh2,
317 nghttp2_submit_goaway(ngh2->s, flags, last_stream_id, error_code,
318 opaque_data, opaque_data_len));
319}
321#endif /* !CURL_DISABLE_HTTP && USE_NGHTTP2 */
Diagnostics4 git calls · 272 ms
CallStatusSizeTime0272 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=267 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=86Open pack map
fetch2001.8 KiB267 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=1871 git.response.cache=MISS git.response.duration_ms=267 git.fetch.wants=5f350244a3ac62db6f1216936f44d2e73723ce3a 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=1871 git.pkt.payload.max=1850 git.sideband.band1.bytes=1849 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
- a5e307380d2115db
- Request
- 6d050575…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format