Artifactspublic-v0

curl

master
ply4 git calls29 ms289 KiB3 cachedprotocol v2
193 lines5.3 KiBRaw
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 ***************************************************************************/
25/*
26 * This test sends data with CURLOPT_KEEP_SENDING_ON_ERROR.
27 * The server responds with an early error response.
28 * The test is successful if the connection can be reused for the next request,
29 * because this implies that the data has been sent completely to the server.
30 */
32#include "first.h"
34struct cb_data {
35 CURL *curl;
36 int response_received;
37 int paused;
38 size_t remaining_bytes;
39};
41static void reset_data(struct cb_data *data, CURL *curl)
43 data->curl = curl;
44 data->response_received = 0;
45 data->paused = 0;
46 data->remaining_bytes = 3;
49static size_t t1533_read_cb(char *ptr, size_t size, size_t nitems, void *userp)
51 struct cb_data *data = (struct cb_data *)userp;
53 /* wait until the server has sent all response headers */
54 if(data->response_received) {
55 size_t totalsize = nitems * size;
57 size_t bytes_to_send = data->remaining_bytes;
58 if(bytes_to_send > totalsize) {
59 bytes_to_send = totalsize;
60 }
62 memset(ptr, 'a', bytes_to_send);
63 data->remaining_bytes -= bytes_to_send;
65 return bytes_to_send;
66 }
67 else {
68 data->paused = 1;
69 return CURL_READFUNC_PAUSE;
70 }
73static size_t t1533_write_cb(char *ptr, size_t size, size_t nmemb, void *userp)
75 struct cb_data *data = (struct cb_data *)userp;
76 size_t totalsize = nmemb * size;
78 (void)ptr;
80 /* all response headers have been received */
81 data->response_received = 1;
83 if(data->paused) {
84 /* continue to send request body data */
85 data->paused = 0;
86 curl_easy_pause(data->curl, CURLPAUSE_CONT);
87 }
89 return totalsize;
92static CURLcode perform_and_check_connections(CURL *curl,
93 const char *description,
94 long expected_connections)
96 CURLcode result;
97 long connections = 0;
99 result = curl_easy_perform(curl);
100 if(result != CURLE_OK) {
101 curl_mfprintf(stderr, "curl_easy_perform() failed with %d\n", (int)result);
102 return TEST_ERR_MAJOR_BAD;
103 }
105 result = curl_easy_getinfo(curl, CURLINFO_NUM_CONNECTS, &connections);
106 if(result != CURLE_OK) {
107 curl_mfprintf(stderr, "curl_easy_getinfo() failed\n");
108 return TEST_ERR_MAJOR_BAD;
109 }
111 curl_mfprintf(stderr,
112 "%s: expected: %ld connections; actual: %ld connections\n",
113 description, expected_connections, connections);
115 if(connections != expected_connections) {
116 return TEST_ERR_FAILURE;
117 }
119 return TEST_ERR_SUCCESS;
122static CURLcode test_lib1533(const char *URL)
124 struct cb_data data;
125 CURL *curl = NULL;
126 CURLcode result = TEST_ERR_FAILURE;
128 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
129 curl_mfprintf(stderr, "curl_global_init() failed\n");
130 return TEST_ERR_MAJOR_BAD;
131 }
133 curl = curl_easy_init();
134 if(!curl) {
135 curl_mfprintf(stderr, "curl_easy_init() failed\n");
136 curl_global_cleanup();
137 return TEST_ERR_MAJOR_BAD;
138 }
140 reset_data(&data, curl);
142 easy_setopt(curl, CURLOPT_URL, URL);
143 easy_setopt(curl, CURLOPT_POST, 1L);
144 easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE,
145 (curl_off_t)data.remaining_bytes);
146 easy_setopt(curl, CURLOPT_VERBOSE, 1L);
147 easy_setopt(curl, CURLOPT_READFUNCTION, t1533_read_cb);
148 easy_setopt(curl, CURLOPT_READDATA, &data);
149 easy_setopt(curl, CURLOPT_WRITEFUNCTION, t1533_write_cb);
150 easy_setopt(curl, CURLOPT_WRITEDATA, &data);
152 result =
153 perform_and_check_connections(curl,
154 "First request without "
155 "CURLOPT_KEEP_SENDING_ON_ERROR", 1);
156 if(result != TEST_ERR_SUCCESS) {
157 goto test_cleanup;
158 }
160 reset_data(&data, curl);
162 result = perform_and_check_connections(curl,
163 "Second request without CURLOPT_KEEP_SENDING_ON_ERROR", 1);
164 if(result != TEST_ERR_SUCCESS) {
165 goto test_cleanup;
166 }
168 easy_setopt(curl, CURLOPT_KEEP_SENDING_ON_ERROR, 1L);
170 reset_data(&data, curl);
172 result = perform_and_check_connections(curl,
173 "First request with CURLOPT_KEEP_SENDING_ON_ERROR", 1);
174 if(result != TEST_ERR_SUCCESS) {
175 goto test_cleanup;
176 }
178 reset_data(&data, curl);
180 result = perform_and_check_connections(curl,
181 "Second request with CURLOPT_KEEP_SENDING_ON_ERROR", 0);
182 if(result != TEST_ERR_SUCCESS) {
183 goto test_cleanup;
184 }
186 result = TEST_ERR_SUCCESS;
188test_cleanup:
189 curl_easy_cleanup(curl);
190 curl_global_cleanup();
192 return result;
Diagnostics4 git calls · 29 ms
CallStatusSizeTime029 ms
discover200152 B4 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 · hit4 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=4
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=4
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=23
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
fetch2001.8 KiB · hit23 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1797
git.response.cache=HIT
git.response.duration_ms=23
git.fetch.wants=c0ad8e46cb9abcf53fccc4abb26268e2951d905c
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=1797
git.pkt.payload.max=1776
git.sideband.band1.bytes=1775
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
a5e32e0918548821
Request
53370882…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format