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 "first.h"
26/* Check range/resume returned error codes and data presence.
28 The input parameters are:
29 - CURLOPT_RANGE/CURLOPT_RESUME_FROM
30 - CURLOPT_FAILONERROR
31 - Returned http code (2xx/416)
32 - Content-Range header present in reply.
33 */
35#define F_RESUME (1 << 0) /* resume/range. */
36#define F_HTTP416 (1 << 1) /* Server returns http code 416. */
37#define F_FAIL (1 << 2) /* Fail on error. */
38#define F_CONTENTRANGE (1 << 3) /* Server sends content-range hdr. */
39#define F_IGNOREBODY (1 << 4) /* Body should be ignored. */
41struct testparams {
42 unsigned int flags; /* ORed flags as above. */
43 CURLcode result; /* Code that should be returned by curl_easy_perform(). */
44};
46static const struct testparams testparams[] = {
47 { 0, CURLE_OK },
48 { F_CONTENTRANGE, CURLE_OK },
49 { F_FAIL, CURLE_OK },
50 { F_FAIL | F_CONTENTRANGE, CURLE_OK },
51 { F_HTTP416, CURLE_OK },
52 { F_HTTP416 | F_CONTENTRANGE, CURLE_OK },
53 { F_HTTP416 | F_FAIL | F_IGNOREBODY,
54 CURLE_HTTP_RETURNED_ERROR },
55 { F_HTTP416 | F_FAIL | F_CONTENTRANGE | F_IGNOREBODY,
56 CURLE_HTTP_RETURNED_ERROR },
57 { F_RESUME | F_IGNOREBODY,
58 CURLE_RANGE_ERROR },
59 { F_RESUME | F_CONTENTRANGE, CURLE_OK },
60 { F_RESUME | F_FAIL | F_IGNOREBODY,
61 CURLE_RANGE_ERROR },
62 { F_RESUME | F_FAIL | F_CONTENTRANGE, CURLE_OK },
63 { F_RESUME | F_HTTP416 | F_IGNOREBODY, CURLE_OK },
64 { F_RESUME | F_HTTP416 | F_CONTENTRANGE | F_IGNOREBODY, CURLE_OK },
65 { F_RESUME | F_HTTP416 | F_FAIL | F_IGNOREBODY, CURLE_OK },
66 { F_RESUME | F_HTTP416 | F_FAIL | F_CONTENTRANGE | F_IGNOREBODY,
67 CURLE_OK }
68};
70static int hasbody;
72static size_t writedata(char *data, size_t size, size_t nmemb, void *userdata)
73{
74 (void)data;
75 (void)userdata;
77 if(size && nmemb)
78 hasbody = 1;
79 return size * nmemb;
80}
82static int onetest(CURL *curl, const char *url, const struct testparams *p,
83 size_t num)
84{
85 CURLcode result;
86 unsigned int replyselector;
87 char urlbuf[256];
89 replyselector = (p->flags & F_CONTENTRANGE) ? 1 : 0;
90 if(p->flags & F_HTTP416)
91 replyselector += 2;
92 curl_msnprintf(urlbuf, sizeof(urlbuf), "%s%04u", url, replyselector);
93 easy_setopt(curl, CURLOPT_URL, urlbuf);
94 easy_setopt(curl, CURLOPT_VERBOSE, 1L);
95 easy_setopt(curl, CURLOPT_RESUME_FROM, (p->flags & F_RESUME) ? 3L : 0L);
96 easy_setopt(curl, CURLOPT_RANGE, !(p->flags & F_RESUME) ?
97 "3-1000000" : (char *)NULL);
98 easy_setopt(curl, CURLOPT_FAILONERROR, (p->flags & F_FAIL) ? 1L : 0L);
99 hasbody = 0;
100 result = curl_easy_perform(curl);
101 if(result != p->result) {
102 curl_mprintf("%zu: bad error code (%d): resume=%s, fail=%s, http416=%s, "
103 "content-range=%s, expected=%d\n", num, (int)result,
104 (p->flags & F_RESUME) ? "yes" : "no",
105 (p->flags & F_FAIL) ? "yes" : "no",
106 (p->flags & F_HTTP416) ? "yes" : "no",
107 (p->flags & F_CONTENTRANGE) ? "yes" : "no",
108 (int)p->result);
109 return 1;
110 }
111 if(hasbody && (p->flags & F_IGNOREBODY)) {
112 curl_mprintf("body should be ignored and is not: resume=%s, fail=%s, "
113 "http416=%s, content-range=%s\n",
114 (p->flags & F_RESUME) ? "yes" : "no",
115 (p->flags & F_FAIL) ? "yes" : "no",
116 (p->flags & F_HTTP416) ? "yes" : "no",
117 (p->flags & F_CONTENTRANGE) ? "yes" : "no");
118 return 1;
119 }
120 return 0;
122test_cleanup:
124 return 1;
125}
127/* for debugging: */
128/* #define SINGLETEST 9 */
130static CURLcode test_lib1156(const char *URL)
131{
132 CURLcode result;
133 CURL *curl;
134 size_t i;
135 int status = 0;
137 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
138 curl_mfprintf(stderr, "curl_global_init() failed\n");
139 return TEST_ERR_MAJOR_BAD;
140 }
142 for(i = 0; i < CURL_ARRAYSIZE(testparams); i++) {
143 curl = curl_easy_init();
144 if(!curl) {
145 curl_mfprintf(stderr, "curl_easy_init() failed\n");
146 curl_global_cleanup();
147 return TEST_ERR_MAJOR_BAD;
148 }
150 easy_setopt(curl, CURLOPT_WRITEFUNCTION, writedata);
152#ifdef SINGLETEST
153 if(SINGLETEST == i)
154#endif
155 status |= onetest(curl, URL, testparams + i, i);
156 curl_easy_cleanup(curl);
157 }
159 curl_global_cleanup();
160 curl_mprintf("%d\n", status);
161 return status ? TEST_ERR_FAILURE : CURLE_OK;
163test_cleanup:
165 curl_easy_cleanup(curl);
166 curl_global_cleanup();
168 return result;
169}
Diagnostics4 git calls · 47 ms
CallStatusSizeTime047 ms
discover200152 B2 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs 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 · hit23 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=23 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
fetch2002.0 KiB · hit21 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=21 git.response.bytes=2007 git.response.cache=HIT git.response.duration_ms=21 git.fetch.wants=6b13374f0424d11816ac5fa9fe152fdfa89b3a2f 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=2007 git.pkt.payload.max=1986 git.sideband.band1.bytes=1985 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
- a5e339cd6debf162
- Request
- b68cc8a6…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format