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"
26struct t554_WriteThis {
27 const char *readptr;
28 size_t sizeleft;
29};
31static size_t t554_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
32{
33 struct t554_WriteThis *pooh = (struct t554_WriteThis *)userp;
35 if(size * nmemb < 1)
36 return 0;
38 if(pooh->sizeleft) {
39 *ptr = pooh->readptr[0]; /* copy one single byte */
40 pooh->readptr++; /* advance pointer */
41 pooh->sizeleft--; /* less data left */
42 return 1; /* we return 1 byte at a time! */
43 }
45 return 0; /* no more data left to deliver */
46}
48static size_t t587_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
49{
50 (void)ptr;
51 (void)size;
52 (void)nmemb;
53 (void)userp;
54 return CURL_READFUNC_ABORT;
55}
57static CURLcode t554_test_once(const char *URL, bool oldstyle)
58{
59 static const char testdata[] =
60 "this is what we post to the silly web server\n";
62 CURL *curl;
63 CURLcode result = CURLE_OK;
64 CURLFORMcode formrc;
66 struct curl_httppost *formpost = NULL;
67 struct curl_httppost *lastptr = NULL;
68 struct t554_WriteThis pooh;
69 struct t554_WriteThis pooh2;
71 pooh.readptr = testdata;
72 pooh.sizeleft = CURL_CSTRLEN(testdata);
74 /* Fill in the file upload field */
75 if(oldstyle) {
76 formrc = curl_formadd(&formpost,
77 &lastptr,
78 CURLFORM_COPYNAME, "sendfile",
79 CURLFORM_STREAM, &pooh,
80 CURLFORM_CONTENTSLENGTH, (long)pooh.sizeleft,
81 CURLFORM_FILENAME, "postit2.c",
82 CURLFORM_END);
83 }
84 else {
85 /* new style */
86 formrc = curl_formadd(&formpost,
87 &lastptr,
88 CURLFORM_COPYNAME, "sendfile alternative",
89 CURLFORM_STREAM, &pooh,
90 CURLFORM_CONTENTLEN, (curl_off_t)pooh.sizeleft,
91 CURLFORM_FILENAME, "filename 2 ",
92 CURLFORM_END);
93 }
95 if(formrc)
96 curl_mprintf("curl_formadd(1) = %d\n", (int)formrc);
98 /* Now add the same data with another name and make it not look like
99 a file upload but still using the callback */
101 pooh2.readptr = testdata;
102 pooh2.sizeleft = CURL_CSTRLEN(testdata);
104 /* Fill in the file upload field */
105 formrc = curl_formadd(&formpost,
106 &lastptr,
107 CURLFORM_COPYNAME, "callbackdata",
108 CURLFORM_STREAM, &pooh2,
109 CURLFORM_CONTENTSLENGTH, (long)pooh2.sizeleft,
110 CURLFORM_END);
112 if(formrc)
113 curl_mprintf("curl_formadd(2) = %d\n", (int)formrc);
115 /* Fill in the filename field */
116 formrc = curl_formadd(&formpost,
117 &lastptr,
118 CURLFORM_COPYNAME, "filename",
119 CURLFORM_COPYCONTENTS, "postit2.c",
120 CURLFORM_END);
121 if(formrc)
122 curl_mprintf("curl_formadd(3) = %d\n", (int)formrc);
124 /* Fill in a submit field too */
125 formrc = curl_formadd(&formpost,
126 &lastptr,
127 CURLFORM_COPYNAME, "submit",
128 CURLFORM_COPYCONTENTS, "send",
129 CURLFORM_CONTENTTYPE, "text/plain",
130 CURLFORM_END);
132 if(formrc)
133 curl_mprintf("curl_formadd(4) = %d\n", (int)formrc);
135 formrc = curl_formadd(&formpost, &lastptr,
136 CURLFORM_COPYNAME, "somename",
137 CURLFORM_BUFFER, "somefile.txt",
138 CURLFORM_BUFFERPTR, "blah blah",
139 CURLFORM_BUFFERLENGTH, 9L,
140 CURLFORM_END);
142 if(formrc)
143 curl_mprintf("curl_formadd(5) = %d\n", (int)formrc);
145 curl = curl_easy_init();
146 if(!curl) {
147 curl_mfprintf(stderr, "curl_easy_init() failed\n");
148 curl_formfree(formpost);
149 curl_global_cleanup();
150 return TEST_ERR_MAJOR_BAD;
151 }
153 /* First set the URL that is about to receive our POST. */
154 easy_setopt(curl, CURLOPT_URL, URL);
156 /* Now specify we want to POST data */
157 easy_setopt(curl, CURLOPT_POST, 1L);
159 /* Set the expected POST size */
160 easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft);
162 /* we want to use our own read function */
163 if(testnum == 587) {
164 easy_setopt(curl, CURLOPT_READFUNCTION, t587_read_cb);
165 }
166 else {
167 easy_setopt(curl, CURLOPT_READFUNCTION, t554_read_cb);
168 }
170 /* send a multi-part formpost */
171 easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
173 /* get verbose debug output please */
174 easy_setopt(curl, CURLOPT_VERBOSE, 1L);
176 /* include headers in the output */
177 easy_setopt(curl, CURLOPT_HEADER, 1L);
179 /* Perform the request, result gets the return code */
180 result = curl_easy_perform(curl);
182test_cleanup:
184 /* always cleanup */
185 curl_easy_cleanup(curl);
187 /* now cleanup the formpost chain */
188 curl_formfree(formpost);
190 return result;
191}
193static CURLcode test_lib554(const char *URL)
194{
195 CURLcode result;
197 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
198 curl_mfprintf(stderr, "curl_global_init() failed\n");
199 return TEST_ERR_MAJOR_BAD;
200 }
202 result = t554_test_once(URL, TRUE); /* old */
203 if(!result)
204 result = t554_test_once(URL, FALSE); /* new */
206 curl_global_cleanup();
208 return result;
209}
Diagnostics4 git calls · 34 ms
CallStatusSizeTime034 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 · hit2 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=2 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=86Open pack map
fetch2001.9 KiB · hit29 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=29 git.response.bytes=1969 git.response.cache=HIT git.response.duration_ms=29 git.fetch.wants=ce4348a8d733aa8fb190f10c1c2dbd5ae3d71c39 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=1969 git.pkt.payload.max=1948 git.sideband.band1.bytes=1947 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
- a5e30176aa3e7929
- Request
- 5adb7af8…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format