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#include "testtrace.h"
28static size_t write_h2_upg_extreme_cb(char *ptr, size_t size, size_t nmemb,
29 void *opaque)
30{
31 (void)ptr;
32 (void)opaque;
33 return size * nmemb;
34}
36static CURLcode test_cli_h2_upgrade_extreme(const char *URL)
37{
38 CURLM *multi = NULL;
39 CURL *curl;
40 CURLMcode mresult;
41 int running_handles = 0, start_count, numfds;
42 CURLMsg *msg;
43 int msgs_in_queue;
44 char range[128];
45 CURLcode result = (CURLcode)1;
47 if(!URL) {
48 curl_mfprintf(stderr, "need URL as argument\n");
49 return (CURLcode)2;
50 }
52 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
53 curl_mfprintf(stderr, "curl_global_init() failed\n");
54 return (CURLcode)3;
55 }
57 multi = curl_multi_init();
58 if(!multi) {
59 curl_mfprintf(stderr, "curl_multi_init failed\n");
60 goto cleanup;
61 }
63 start_count = 200;
64 do {
65 if(start_count) {
66 curl = curl_easy_init();
67 if(!curl) {
68 curl_mfprintf(stderr, "curl_easy_init failed\n");
69 goto cleanup;
70 }
71 curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
72 curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, cli_debug_cb);
73 curl_easy_setopt(curl, CURLOPT_URL, URL);
74 curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L);
75 curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1L);
76 curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
77 curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
78 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_h2_upg_extreme_cb);
79 curl_easy_setopt(curl, CURLOPT_WRITEDATA, NULL);
80 curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
81 curl_msnprintf(range, sizeof(range),
82 "%" CURL_FORMAT_CURL_OFF_T "-"
83 "%" CURL_FORMAT_CURL_OFF_T,
84 (curl_off_t)0,
85 (curl_off_t)16384);
86 curl_easy_setopt(curl, CURLOPT_RANGE, range);
88 mresult = curl_multi_add_handle(multi, curl);
89 if(mresult != CURLM_OK) {
90 curl_mfprintf(stderr, "curl_multi_add_handle: %s\n",
91 curl_multi_strerror(mresult));
92 curl_easy_cleanup(curl);
93 goto cleanup;
94 }
95 --start_count;
96 }
98 mresult = curl_multi_perform(multi, &running_handles);
99 if(mresult != CURLM_OK) {
100 curl_mfprintf(stderr, "curl_multi_perform: %s\n",
101 curl_multi_strerror(mresult));
102 goto cleanup;
103 }
105 if(running_handles) {
106 mresult = curl_multi_poll(multi, NULL, 0, 1000000, &numfds);
107 if(mresult != CURLM_OK) {
108 curl_mfprintf(stderr, "curl_multi_poll: %s\n",
109 curl_multi_strerror(mresult));
110 goto cleanup;
111 }
112 }
114 /* Check for finished handles and remove. */
115 /* !checksrc! disable EQUALSNULL 1 */
116 while((msg = curl_multi_info_read(multi, &msgs_in_queue)) != NULL) {
117 if(msg->msg == CURLMSG_DONE) {
118 long status = 0;
119 curl_off_t xfer_id;
120 curl_easy_getinfo(msg->easy_handle, CURLINFO_XFER_ID, &xfer_id);
121 curl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE, &status);
122 if(msg->data.result == CURLE_SEND_ERROR ||
123 msg->data.result == CURLE_RECV_ERROR) {
124 /* We get these if the server had a GOAWAY in transit on
125 * reusing a connection */
126 }
127 else if(msg->data.result) {
128 curl_mfprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T
129 ": failed with %d\n", xfer_id, (int)msg->data.result);
130 goto cleanup;
131 }
132 else if(status != 206) {
133 curl_mfprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T
134 ": wrong http status %ld (expected 206)\n", xfer_id,
135 status);
136 goto cleanup;
137 }
138 curl_multi_remove_handle(multi, msg->easy_handle);
139 curl_easy_cleanup(msg->easy_handle);
140 curl_mfprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T " retiring "
141 "(%d now running)\n", xfer_id, running_handles);
142 }
143 }
145 curl_mfprintf(stderr, "running_handles=%d, yet_to_start=%d\n",
146 running_handles, start_count);
148 } while(running_handles > 0 || start_count);
150 curl_mfprintf(stderr, "exiting\n");
151 result = CURLE_OK;
153cleanup:
155 if(multi) {
156 CURL **list = curl_multi_get_handles(multi);
157 if(list) {
158 int i;
159 for(i = 0; list[i]; i++) {
160 curl_multi_remove_handle(multi, list[i]);
161 curl_easy_cleanup(list[i]);
162 }
163 curl_free(list);
164 }
165 curl_multi_cleanup(multi);
166 }
168 curl_global_cleanup();
170 return result;
171}
Diagnostics4 git calls · 38 ms
CallStatusSizeTime038 ms
discover200152 B5 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch 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 · hit5 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=5 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=5 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 · hit4 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=28 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=4 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 · hit29 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=1958 git.response.cache=HIT git.response.duration_ms=29 git.fetch.wants=9df8640cffececdcffb533a0d0531b3f2a921ada 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=1958 git.pkt.payload.max=1937 git.sideband.band1.bytes=1936 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
- a5e3503dae2714c2
- Request
- 05550394…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format