Artifactspublic-v0

curl

master
ply4 git calls26 ms290 KiB3 cachedprotocol v2
275 lines10 KiBRaw
1#ifndef HEADER_CURL_HTTP_H
2#define HEADER_CURL_HTTP_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#include "curl_setup.h"
28#include "bufq.h"
29#include "dynhds.h"
31typedef enum {
32 HTTPREQ_GET,
33 HTTPREQ_POST,
34 HTTPREQ_POST_FORM, /* we make a difference internally */
35 HTTPREQ_POST_MIME, /* we make a difference internally */
36 HTTPREQ_PUT,
37 HTTPREQ_HEAD
38} Curl_HttpReq;
40#define CURL_HTTP_V1x (1 << 0)
41#define CURL_HTTP_V2x (1 << 1)
42#define CURL_HTTP_V3x (1 << 2)
43/* bitmask of CURL_HTTP_V* values */
44typedef unsigned char http_majors;
46#ifndef CURL_DISABLE_HTTP
48extern const struct Curl_protocol Curl_protocol_http;
50struct dynhds;
52struct http_negotiation {
53 unsigned char rcvd_min; /* minimum version seen in responses, 09, 10, 11 */
54 http_majors wanted; /* wanted major versions when talking to server */
55 http_majors allowed; /* allowed major versions when talking to server */
56 http_majors preferred; /* preferred major version when talking to server */
57 BIT(h2_upgrade); /* Do HTTP Upgrade from 1.1 to 2 */
58 BIT(h2_prior_knowledge); /* Directly do HTTP/2 without ALPN/SSL */
59 BIT(accept_09); /* Accept an HTTP/0.9 response */
60 BIT(only_10); /* When using major version 1x, use only 1.0 */
61};
63void Curl_http_neg_init(struct Curl_easy *data, struct http_negotiation *neg);
65CURLcode Curl_bump_headersize(struct Curl_easy *data,
66 size_t delta,
67 bool connect_only);
69/* Header specific functions */
70bool Curl_compareheader(const char *headerline, /* line to check */
71 const char *header, /* header keyword _with_ colon */
72 const size_t hlen, /* len of the keyword in bytes */
73 const char *content, /* content string to find */
74 const size_t clen); /* len of the content in bytes */
76char *Curl_copy_header_value(const char *header);
78char *Curl_checkProxyheaders(struct Curl_easy *data,
79 const struct connectdata *conn,
80 const char *thisheader,
81 const size_t thislen);
83CURLcode Curl_add_timecondition(struct Curl_easy *data, struct dynbuf *req);
84CURLcode Curl_add_custom_headers(struct Curl_easy *data, bool is_connect,
85 int httpversion, struct dynbuf *req);
87void Curl_http_to_fold(struct dynbuf *bf);
89void Curl_http_method(struct Curl_easy *data,
90 const char **method, Curl_HttpReq *reqp);
92/* protocol-specific functions set up to be called by the main engine */
93CURLcode Curl_http_setup_conn(struct Curl_easy *data,
94 struct connectdata *conn);
95CURLcode Curl_http_setup_filters(struct Curl_easy *data,
96 struct Curl_cfilter *cf);
97CURLcode Curl_http(struct Curl_easy *data, bool *done);
98CURLcode Curl_http_done(struct Curl_easy *data,
99 CURLcode status, bool premature);
100CURLcode Curl_http_doing_pollset(struct Curl_easy *data,
101 struct easy_pollset *ps);
102CURLcode Curl_http_perform_pollset(struct Curl_easy *data,
103 struct easy_pollset *ps);
104CURLcode Curl_http_write_resp(struct Curl_easy *data,
105 const char *buf, size_t blen,
106 bool is_eos);
107CURLcode Curl_http_write_resp_hd(struct Curl_easy *data,
108 const char *hd, size_t hdlen,
109 bool is_eos);
111/* check a received header line for forbidden bytes/format, the same checks
112 applied to regular response headers */
113CURLcode Curl_verify_header(struct Curl_easy *data,
114 const char *hd, size_t hdlen);
116/* These functions are in http.c */
117CURLcode Curl_http_input_auth(struct Curl_easy *data, bool proxy,
118 const char *auth);
120CURLcode Curl_http_auth_act(struct Curl_easy *data);
122/* follow a redirect or not */
123CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl,
124 followtype type);
126/* If only the PICKNONE bit is set, there has been a round-trip and we
127 selected to use no auth at all. Ie, we actively select no auth, as opposed
128 to not having one selected. The other CURLAUTH_* defines are present in the
129 public curl/curl.h header. */
130#define CURLAUTH_PICKNONE (1 << 30) /* do not use auth */
132/* MAX_INITIAL_POST_SIZE indicates the number of bytes that will make the POST
133 data get included in the initial data chunk sent to the server. If the
134 data is larger than this, it will automatically get split up in multiple
135 system calls.
137 This value used to be fairly big (100K), but we must take into account that
138 if the server rejects the POST due for authentication reasons, this data
139 will always be unconditionally sent and thus it may not be larger than can
140 always be afforded to send twice.
142 It must not be greater than 64K to work on VMS. */
143#ifndef MAX_INITIAL_POST_SIZE
144#define MAX_INITIAL_POST_SIZE (64 * 1024)
145#endif
147/* EXPECT_100_THRESHOLD is the request body size limit for when libcurl will
148 * automatically add an "Expect: 100-continue" header in HTTP requests. When
149 * the size is unknown, it will always add it.
150 *
151 */
152#ifndef EXPECT_100_THRESHOLD
153#define EXPECT_100_THRESHOLD (1024 * 1024)
154#endif
156/* MAX_HTTP_RESP_HEADER_SIZE is the maximum size of all response headers
157 combined that libcurl allows for a single HTTP response, any HTTP
158 version. This count includes CONNECT response headers. */
159#define MAX_HTTP_RESP_HEADER_SIZE (300 * 1024)
161/* MAX_HTTP_RESP_HEADER_COUNT is the maximum number of response headers that
162 libcurl allows for a single HTTP response, including CONNECT and
163 redirects. */
164#define MAX_HTTP_RESP_HEADER_COUNT 5000
166#endif /* CURL_DISABLE_HTTP */
168/****************************************************************************
169 * HTTP unique setup
170 ***************************************************************************/
172CURLcode Curl_http_write_resp_hds(struct Curl_easy *data,
173 const char *buf, size_t blen,
174 size_t *pconsumed);
176/**
177 * Curl_http_output_auth() setups the authentication headers for the
178 * host/proxy and the correct authentication
179 * method. data->state.authdone is set to TRUE when authentication is
180 * done.
181 *
182 * @param data all information about the current transfer
183 * @param conn all information about the current connection
184 * @param request pointer to the request keyword
185 * @param httpreq is the request type
186 * @param path pointer to the requested path
187 * @param query pointer to the requested query or NULL
188 * @param is_connect boolean if this is a CONNECT request
189 * (where httpreq is HTTPREQ_GET since there is no HTTPREQ_CONNECT)
190 *
191 * @returns CURLcode
192 */
193CURLcode Curl_http_output_auth(struct Curl_easy *data,
194 struct connectdata *conn,
195 const char *request,
196 Curl_HttpReq httpreq,
197 const char *path,
198 const char *query,
199 bool is_connect);
201/* Decode HTTP status code string. */
202CURLcode Curl_http_decode_status(int32_t *pstatus, const char *s, size_t len);
204/**
205 * All about a core HTTP request, excluding body and trailers
206 */
207struct httpreq {
208 struct dynhds headers;
209 struct dynhds trailers;
210 char *scheme;
211 char *authority;
212 char *path;
213 char method[1];
214};
216/**
217 * Create an HTTP request struct.
218 */
219CURLcode Curl_http_req_make(struct httpreq **preq,
220 const char *method, size_t m_len,
221 const char *scheme, size_t s_len,
222 const char *authority, size_t a_len,
223 const char *path, size_t p_len);
225CURLcode Curl_http_req_make2(struct httpreq **preq,
226 const char *method, size_t m_len,
227 CURLU *url, const char *scheme_default);
229void Curl_http_req_free(struct httpreq *req);
231#define HTTP_PSEUDO_METHOD ":method"
232#define HTTP_PSEUDO_SCHEME ":scheme"
233#define HTTP_PSEUDO_AUTHORITY ":authority"
234#define HTTP_PSEUDO_PATH ":path"
235#define HTTP_PSEUDO_STATUS ":status"
237/**
238 * Create the list of HTTP/2 headers which represent the request,
239 * using HTTP/2 pseudo headers preceding the `req->headers`.
240 *
241 * Applies the following transformations:
242 * - if `authority` is set, any "Host" header is removed.
243 * - if `authority` is unset and a "Host" header is present, use
244 * that as `authority` and remove "Host"
245 * - removes and Connection header fields as defined in rfc9113 ch. 8.2.2
246 * - lower-cases the header field names
247 *
248 * @param h2_headers will contain the HTTP/2 headers on success
249 * @param req the request to transform
250 * @param data the handle to lookup defaults like ' :scheme' from
251 */
252CURLcode Curl_http_req_to_h2(struct dynhds *h2_headers,
253 struct httpreq *req, struct Curl_easy *data);
255/**
256 * All about a core HTTP response, excluding body and trailers
257 */
258struct http_resp {
259 int status;
260 char *description;
261 struct dynhds headers;
262 struct dynhds trailers;
263 struct http_resp *prev;
264};
266/**
267 * Create an HTTP response struct.
268 */
269CURLcode Curl_http_resp_make(struct http_resp **presp,
270 int status,
271 const char *description);
273void Curl_http_resp_free(struct http_resp *resp);
275#endif /* HEADER_CURL_HTTP_H */
Diagnostics4 git calls · 26 ms
CallStatusSizeTime026 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 · hit3 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=3
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
fetch2003.5 KiB · hit20 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=20
git.response.bytes=3629
git.response.cache=HIT
git.response.duration_ms=20
git.fetch.wants=0e074a04faa8b7cf25d2b16d35dd4b98308984a0
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=3629
git.pkt.payload.max=3608
git.sideband.band1.bytes=3607
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
a5e1d7b9d846a151
Request
d16e22f2…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format