Artifactspublic-v0

curl

master
ply4 git calls23 ms291 KiB3 cachedprotocol v2
300 lines13 KiBRaw
1#ifndef HEADER_CURL_PROTOCOL_H
2#define HEADER_CURL_PROTOCOL_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.se/docs/copyright.html.
15 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 * SPDX-License-Identifier: curl
24 *
25 ***************************************************************************/
26/* This file is for lib internal stuff */
27#include "curl_setup.h"
29struct Curl_easy;
30struct Curl_cfilter;
31struct connectdata;
32struct easy_pollset;
34/* Known protocol default port numbers */
35#define PORT_FTP 21
36#define PORT_FTPS 990
37#define PORT_TELNET 23
38#define PORT_HTTP 80
39#define PORT_HTTPS 443
40#define PORT_DICT 2628
41#define PORT_LDAP 389
42#define PORT_LDAPS 636
43#define PORT_TFTP 69
44#define PORT_SSH 22
45#define PORT_IMAP 143
46#define PORT_IMAPS 993
47#define PORT_POP3 110
48#define PORT_POP3S 995
49#define PORT_SMTP 25
50#define PORT_SMTPS 465 /* sometimes called SSMTP */
51#define PORT_RTSP 554
52#define PORT_GOPHER 70
53#define PORT_SOCKS 1080
54#define PORT_MQTT 1883
55#define PORT_MQTTS 8883
57/* CURLPROTO_GOPHERS (29) is the highest publicly used protocol bit number,
58 * the rest are internal information. If we use higher bits we only do this on
59 * platforms that have a >= 64-bit type and then we use such a type for the
60 * protocol fields in the scheme definition.
61 */
62#define CURLPROTO_WS (1L << 30)
63#define CURLPROTO_WSS ((curl_prot_t)1 << 31)
64#define CURLPROTO_MQTTS (1LL << 32)
65#define CURLPROTO_SOCKS (1LL << 33)
67#define CURLPROTO_64ALL ((uint64_t)0xffffffffffffffff)
69/* the default protocols accepting a redirect to */
70#define CURLPROTO_REDIR (CURLPROTO_HTTP | CURLPROTO_HTTPS | CURLPROTO_FTP | \
71 CURLPROTO_FTPS)
73typedef curl_off_t curl_prot_t;
75/* This mask is for all the old protocols that are provided and defined in the
76 public header and shall exclude protocols added since which are not exposed
77 in the API */
78#define CURLPROTO_MASK 0x3fffffff
80/* Convenience defines for checking protocols or their SSL based version. Each
81 protocol scheme should only ever have a single CURLPROTO_ in its protocol
82 field. */
83#define PROTO_FAMILY_HTTP (CURLPROTO_HTTP | CURLPROTO_HTTPS | CURLPROTO_WS | \
84 CURLPROTO_WSS)
85#define PROTO_FAMILY_FTP (CURLPROTO_FTP | CURLPROTO_FTPS)
86#define PROTO_FAMILY_POP3 (CURLPROTO_POP3 | CURLPROTO_POP3S)
87#define PROTO_FAMILY_SMTP (CURLPROTO_SMTP | CURLPROTO_SMTPS)
88#define PROTO_FAMILY_SSH (CURLPROTO_SCP | CURLPROTO_SFTP)
90#if !defined(CURL_DISABLE_FTP) || defined(USE_SSH) || \
91 !defined(CURL_DISABLE_POP3)
92/* these protocols support CURLOPT_DIRLISTONLY */
93#define CURL_LIST_ONLY_PROTOCOL 1
94#endif
96/* When redirecting transfers. */
97typedef enum {
98 FOLLOW_NONE, /* not used within the function, a placeholder to allow
99 initing to this */
100 FOLLOW_FAKE, /* only records stuff, not actually following */
101 FOLLOW_RETRY, /* set if this is a request retry as opposed to a real
102 redirect following */
103 FOLLOW_REDIR /* a full true redirect */
104} followtype;
106typedef enum {
107 DOMORE_GOBACK = -1,
108 DOMORE_INCOMPLETE = 0,
109 DOMORE_DONE = 1
110} domore;
112/*
113 * Specific protocol handler, an implementation of one or more URI schemes.
114 */
115struct Curl_protocol {
116 /* Complement to setup_connection_internals(). This is done before the
117 transfer "owns" the connection. */
118 CURLcode (*setup_connection)(struct Curl_easy *data,
119 struct connectdata *conn);
121 /* After IP/Proxy connectivity has been established, add protocol
122 * specific filters underneath `cf`, if so desired.
123 * This may be called several times during connection setup for
124 * different filters, but only once for a particular filter.
125 * The filter `cf` will have sub-filters, like TCP or PROXY or
126 * TLS already connected. The protocol handler may query these
127 * for properties like the established ALPN. */
128 CURLcode (*setup_filters)(struct Curl_easy *data, struct Curl_cfilter *cf);
130 /* These two functions MUST be set to be protocol dependent */
131 CURLcode (*do_it)(struct Curl_easy *data, bool *done);
132 CURLcode (*done)(struct Curl_easy *, CURLcode, bool);
134 /* If the curl_do() function is better made in two halves, this
135 * curl_do_more() function will be called afterwards, if set. For example
136 * for doing the FTP stuff after the PASV/PORT command. The second
137 * argument is an output parameter that MUST be set to one of the
138 * DOMORE_* values: DOMORE_INCOMPLETE if more do_more work remains,
139 * DOMORE_DONE when the second phase is complete, or DOMORE_GOBACK
140 * to return to the regular DO/DOING handling.
141 */
142 CURLcode (*do_more)(struct Curl_easy *, domore *);
144 /* This function *MAY* be set to a protocol-dependent function that is run
145 * after the connect() and everything is done, as a step in the connection.
146 * The 'done' pointer points to a bool that should be set to TRUE if the
147 * function completes before return. If it does not complete, the caller
148 * should call the ->connecting() function until it is.
149 */
150 CURLcode (*connect_it)(struct Curl_easy *data, bool *done);
152 /* See above. */
153 CURLcode (*connecting)(struct Curl_easy *data, bool *done);
154 CURLcode (*doing)(struct Curl_easy *data, bool *done);
156 /* Called from the multi interface during the PROTOCONNECT phase, and it
157 should then return a proper fd set */
158 CURLcode (*proto_pollset)(struct Curl_easy *data,
159 struct easy_pollset *ps);
161 /* Called from the multi interface during the DOING phase, and it should
162 then return a proper fd set */
163 CURLcode (*doing_pollset)(struct Curl_easy *data,
164 struct easy_pollset *ps);
166 /* Called from the multi interface during the DO_MORE phase, and it should
167 then return a proper fd set */
168 CURLcode (*domore_pollset)(struct Curl_easy *data,
169 struct easy_pollset *ps);
171 /* Called from the multi interface during the DO_DONE, PERFORM and
172 WAITPERFORM phases, and it should then return a proper fd set. Not setting
173 this will make libcurl use the generic default one. */
174 CURLcode (*perform_pollset)(struct Curl_easy *data,
175 struct easy_pollset *ps);
177 /* This function *MAY* be set to a protocol-dependent function that is run
178 * by the curl_disconnect(), as a step in the disconnection. If the handler
179 * is called because the connection has been considered dead,
180 * dead_connection is set to TRUE. The connection is (again) associated with
181 * the transfer here.
182 */
183 CURLcode (*disconnect)(struct Curl_easy *, struct connectdata *,
184 bool dead_connection);
186 /* If used, this function gets called from transfer.c to
187 allow the protocol to do extra handling in writing response to
188 the client. */
189 CURLcode (*write_resp)(struct Curl_easy *data, const char *buf, size_t blen,
190 bool is_eos);
192 /* If used, this function gets called from transfer.c to
193 allow the protocol to do extra handling in writing a single response
194 header line to the client. */
195 CURLcode (*write_resp_hd)(struct Curl_easy *data,
196 const char *hd, size_t hdlen, bool is_eos);
198 /* If used, this function checks for a connection managed by this
199 protocol and currently not in use, if it should be considered dead. */
200 bool (*connection_is_dead)(struct Curl_easy *data,
201 struct connectdata *conn);
203 /* attach() attaches this transfer to this connection */
204 void (*attach)(struct Curl_easy *data, struct connectdata *conn);
206 /* return CURLE_OK if a redirect to `newurl` should be followed,
207 CURLE_TOO_MANY_REDIRECTS otherwise. May alter `data` to change
208 the way the follow request is performed. */
209 CURLcode (*follow)(struct Curl_easy *data, const char *newurl,
210 followtype type);
211};
213#define PROTOPT_NONE 0 /* nothing extra */
214#define PROTOPT_SSL (1 << 0) /* uses SSL */
215#define PROTOPT_DUAL (1 << 1) /* this protocol uses two connections */
216#define PROTOPT_CLOSEACTION (1 << 2) /* need action before socket close */
217/* some protocols will have to call the underlying functions without regard to
218 what exact state the socket signals. IE even if the socket says "readable",
219 the send function might need to be called while uploading, or vice versa. */
220#define PROTOPT_DIRLOCK (1 << 3)
221#define PROTOPT_NONETWORK (1 << 4) /* protocol does not use the network! */
222#define PROTOPT_NEEDSPWD (1 << 5) /* needs a password, and if none is set it
223 gets a default */
224#define PROTOPT_NOURLQUERY (1 << 6) /* protocol cannot handle
225 URL query strings (?foo=bar) ! */
226#define PROTOPT_CREDSPERREQUEST (1 << 7) /* requires login credentials per
227 request instead of per
228 connection */
229#define PROTOPT_ALPN (1 << 8) /* set ALPN for this */
230/* (1 << 9) was PROTOPT_STREAM, now free */
231#define PROTOPT_URLOPTIONS (1 << 10) /* allow options part in the userinfo
232 field of the URL */
233#define PROTOPT_PROXY_AS_HTTP (1 << 11) /* allow this non-HTTP scheme over a
234 HTTP proxy as HTTP proxies may know
235 this protocol and act as
236 a gateway */
237#define PROTOPT_WILDCARD (1 << 12) /* protocol supports wildcard matching */
238#define PROTOPT_USERPWDCTRL (1 << 13) /* Allow "control bytes" (< 32 ASCII) in
239 username and password */
240#define PROTOPT_NOTCPPROXY (1 << 14) /* this protocol cannot proxy over TCP */
241#define PROTOPT_SSL_REUSE (1 << 15) /* this protocol may reuse an existing
242 SSL connection in the same family
243 without having PROTOPT_SSL. */
244#define PROTOPT_CONN_REUSE (1 << 16) /* this protocol can reuse connections */
245#define PROTOPT_NO_TRANSFER (1 << 17) /* this protocol is not for transfers */
246#define PROTOPT_HTTP_PROXY_TUNNEL (1 << 18) /* Using this protocol with a
247 * HTTP proxy requires tunneling */
249/* Everything about a URI scheme. */
250struct Curl_scheme {
251 const char *name; /* URL scheme name in lowercase */
252 const struct Curl_protocol *run; /* implementation, optional */
253 curl_prot_t protocol; /* See CURLPROTO_* - this needs to be the single
254 specific protocol bit */
255 curl_prot_t family; /* single bit for protocol family; the non-TLS name
256 of the protocol this is */
257 uint32_t flags; /* Extra particular characteristics, see PROTOPT_* */
258 uint16_t defport; /* Default port. */
259};
261/* Get scheme definition for a URI scheme name
262 * @param scheme URI scheme name, case-insensitive
263 * @return NULL if scheme is not known
264 */
265const struct Curl_scheme *Curl_get_scheme(const char *scheme);
266const struct Curl_scheme *Curl_getn_scheme(const char *scheme, size_t len);
268/* For direct access to a URI scheme */
269extern const struct Curl_scheme Curl_scheme_dict;
270extern const struct Curl_scheme Curl_scheme_file;
271extern const struct Curl_scheme Curl_scheme_ftp;
272extern const struct Curl_scheme Curl_scheme_ftps;
273extern const struct Curl_scheme Curl_scheme_gopher;
274extern const struct Curl_scheme Curl_scheme_gophers;
275extern const struct Curl_scheme Curl_scheme_http;
276extern const struct Curl_scheme Curl_scheme_https;
277extern const struct Curl_scheme Curl_scheme_imap;
278extern const struct Curl_scheme Curl_scheme_imaps;
279extern const struct Curl_scheme Curl_scheme_ldap;
280extern const struct Curl_scheme Curl_scheme_ldaps;
281extern const struct Curl_scheme Curl_scheme_mqtt;
282extern const struct Curl_scheme Curl_scheme_mqtts;
283extern const struct Curl_scheme Curl_scheme_pop3;
284extern const struct Curl_scheme Curl_scheme_pop3s;
285extern const struct Curl_scheme Curl_scheme_rtsp;
286extern const struct Curl_scheme Curl_scheme_scp;
287extern const struct Curl_scheme Curl_scheme_sftp;
288extern const struct Curl_scheme Curl_scheme_smtp;
289extern const struct Curl_scheme Curl_scheme_smtps;
290extern const struct Curl_scheme Curl_scheme_socks;
291extern const struct Curl_scheme Curl_scheme_socks4;
292extern const struct Curl_scheme Curl_scheme_socks4a;
293extern const struct Curl_scheme Curl_scheme_socks5;
294extern const struct Curl_scheme Curl_scheme_socks5h;
295extern const struct Curl_scheme Curl_scheme_telnet;
296extern const struct Curl_scheme Curl_scheme_tftp;
297extern const struct Curl_scheme Curl_scheme_ws;
298extern const struct Curl_scheme Curl_scheme_wss;
300#endif /* HEADER_CURL_PROTOCOL_H */
Diagnostics4 git calls · 23 ms
CallStatusSizeTime023 ms
discover200152 B2 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=19
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
fetch2004.4 KiB · hit19 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=4556
git.response.cache=HIT
git.response.duration_ms=19
git.fetch.wants=b762e188f79bf790bd762731c8e75b2d9ab79c44
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=4556
git.pkt.payload.max=4535
git.sideband.band1.bytes=4534
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
a5e18ffc29d15b65
Request
cfbd8644…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format