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/* This is the 'proxyauth.c' test app posted by Shmulik Regev on the libcurl
25 * mailing list on 10 Jul 2007, converted to a test case.
26 *
27 * argv1 = URL
28 * argv2 = proxy
29 * argv3 = proxyuser:password
30 * argv4 = hostname to use for the custom Host: header
31 */
33#include "first.h"
35static CURL *t540_curl[2];
37static CURLcode init(int num, CURLM *multi, const char *url,
38 const char *userpwd, struct curl_slist *headers)
39{
40 CURLcode result = CURLE_OK;
42 const char *proxy = libtest_arg2;
44 res_easy_init(t540_curl[num]);
45 if(result)
46 goto init_failed;
48 res_easy_setopt(t540_curl[num], CURLOPT_URL, url);
49 if(result)
50 goto init_failed;
52 res_easy_setopt(t540_curl[num], CURLOPT_PROXY, proxy);
53 if(result)
54 goto init_failed;
56 res_easy_setopt(t540_curl[num], CURLOPT_PROXYUSERPWD, userpwd);
57 if(result)
58 goto init_failed;
60 res_easy_setopt(t540_curl[num], CURLOPT_PROXYAUTH, CURLAUTH_ANY);
61 if(result)
62 goto init_failed;
64 res_easy_setopt(t540_curl[num], CURLOPT_VERBOSE, 1L);
65 if(result)
66 goto init_failed;
68 res_easy_setopt(t540_curl[num], CURLOPT_HEADER, 1L);
69 if(result)
70 goto init_failed;
72 /* custom Host: */
73 res_easy_setopt(t540_curl[num], CURLOPT_HTTPHEADER, headers);
74 if(result)
75 goto init_failed;
77 res_multi_add_handle(multi, t540_curl[num]);
78 if(result)
79 goto init_failed;
81 return CURLE_OK; /* success */
83init_failed:
85 curl_easy_cleanup(t540_curl[num]);
86 t540_curl[num] = NULL;
88 return result; /* failure */
89}
91static CURLcode loop(int num, CURLM *multi, const char *url,
92 const char *userpwd, struct curl_slist *headers)
93{
94 CURLMsg *msg;
95 long L;
96 int Q, U = -1;
97 fd_set R, W, E;
98 struct timeval T;
99 CURLcode result = CURLE_OK;
101 result = init(num, multi, url, userpwd, headers);
102 if(result)
103 return result;
105 while(U) {
107 int M = -99;
109 res_multi_perform(multi, &U);
110 if(result)
111 return result;
113 res_test_timedout();
114 if(result)
115 return result;
117 if(U) {
118 FD_ZERO(&R);
119 FD_ZERO(&W);
120 FD_ZERO(&E);
122 res_multi_fdset(multi, &R, &W, &E, &M);
123 if(result)
124 return result;
126 /* At this point, M is guaranteed to be greater or equal than -1. */
128 res_multi_timeout(multi, &L);
129 if(result)
130 return result;
132 /* At this point, L is guaranteed to be greater or equal than -1. */
134 if(L != -1) {
135 int itimeout;
136#if LONG_MAX > INT_MAX
137 itimeout = (L > INT_MAX) ? INT_MAX : (int)L;
138#else
139 itimeout = (int)L;
140#endif
141 T.tv_sec = itimeout / 1000;
142 T.tv_usec = (itimeout % 1000) * 1000;
143 }
144 else {
145 T.tv_sec = 5;
146 T.tv_usec = 0;
147 }
149 res_select_test(M + 1, &R, &W, &E, &T);
150 if(result)
151 return result;
152 }
154 while(1) {
155 msg = curl_multi_info_read(multi, &Q);
156 if(!msg)
157 break;
158 if(msg->msg == CURLMSG_DONE) {
159 size_t i;
160 CURL *curl = msg->easy_handle;
161 curl_mfprintf(stderr, "R: %d - %s\n", (int)msg->data.result,
162 curl_easy_strerror(msg->data.result));
163 curl_multi_remove_handle(multi, curl);
164 curl_easy_cleanup(curl);
165 for(i = 0; i < CURL_ARRAYSIZE(t540_curl); i++) {
166 if(t540_curl[i] == curl) {
167 t540_curl[i] = NULL;
168 break;
169 }
170 }
171 }
172 else
173 curl_mfprintf(stderr, "E: CURLMsg (%d)\n", (int)msg->msg);
174 }
176 res_test_timedout();
177 if(result)
178 return result;
179 }
181 return CURLE_OK;
182}
184static CURLcode test_lib540(const char *URL)
185{
186 CURLM *multi = NULL;
187 struct curl_slist *headers = NULL;
188 char buffer[246]; /* naively fixed-size */
189 CURLcode result = CURLE_OK;
190 size_t i;
192 const char *proxyuserpws = libtest_arg3;
193 const char *host;
195 for(i = 0; i < CURL_ARRAYSIZE(t540_curl); i++)
196 t540_curl[i] = NULL;
198 start_test_timing();
200 if(test_argc < 4)
201 return TEST_ERR_MAJOR_BAD;
203 host = test_argv[4];
204 curl_msnprintf(buffer, sizeof(buffer), "Host: %s", host);
206 /* now add a custom Host: header */
207 headers = curl_slist_append(headers, buffer);
208 if(!headers) {
209 curl_mfprintf(stderr, "curl_slist_append() failed\n");
210 return TEST_ERR_MAJOR_BAD;
211 }
213 res_global_init(CURL_GLOBAL_ALL);
214 if(result) {
215 curl_slist_free_all(headers);
216 return result;
217 }
219 res_multi_init(multi);
220 if(result) {
221 curl_global_cleanup();
222 curl_slist_free_all(headers);
223 return result;
224 }
226 result = loop(0, multi, URL, proxyuserpws, headers);
227 if(result)
228 goto test_cleanup;
230 curl_mfprintf(stderr, "lib540: now we do the request again\n");
232 result = loop(1, multi, URL, proxyuserpws, headers);
234test_cleanup:
236 /* proper cleanup sequence - type PB */
238 for(i = 0; i < CURL_ARRAYSIZE(t540_curl); i++) {
239 curl_multi_remove_handle(multi, t540_curl[i]);
240 curl_easy_cleanup(t540_curl[i]);
241 }
243 curl_multi_cleanup(multi);
244 curl_global_cleanup();
246 curl_slist_free_all(headers);
248 return result;
249}
Diagnostics4 git calls · 42 ms
CallStatusSizeTime042 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=2 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=86Open pack map
fetch2001.9 KiB · hit36 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=36 git.response.bytes=1996 git.response.cache=HIT git.response.duration_ms=36 git.fetch.wants=ec9d3da7c95b739a98c393a28606e366d30b233e 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=1996 git.pkt.payload.max=1975 git.sideband.band1.bytes=1974 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
- a5e31b8a6b558682
- Request
- 17b9033b…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format