Artifactspublic-v0

curl

master
ply4 git calls47 ms289 KiB3 cachedprotocol v2
165 lines4.5 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 ***************************************************************************/
24#include "curl_setup.h"
26#if !defined(CURL_DISABLE_COOKIES) || !defined(CURL_DISABLE_ALTSVC) || \
27 !defined(CURL_DISABLE_HSTS)
29#include "urldata.h"
30#include "rand.h"
31#include "curl_fopen.h"
33/* The dirslash() function breaks a null-terminated pathname string into
34 directory and filename components then returns the directory component up
35 to, *AND INCLUDING*, a final '/'. If there is no directory in the path,
36 this instead returns a "" string.
38 This function returns a pointer to malloc'ed memory.
40 The input path to this function is expected to have a filename part.
41 */
43#ifdef _WIN32
44#define PATHSEP "\\"
45#define IS_SEP(x) (((x) == '/') || ((x) == '\\'))
46#elif defined(MSDOS) || defined(OS2)
47#define PATHSEP "\\"
48#define IS_SEP(x) ((x) == '\\')
49#else
50#define PATHSEP "/"
51#define IS_SEP(x) ((x) == '/')
52#endif
54static char *dirslash(const char *path)
56 size_t n;
57 struct dynbuf out;
58 DEBUGASSERT(path);
59 curlx_dyn_init(&out, CURL_MAX_INPUT_LENGTH);
60 n = strlen(path);
61 if(n) {
62 /* find the rightmost path separator, if any */
63 while(n && !IS_SEP(path[n - 1]))
64 --n;
65 /* skip over all the path separators, if any */
66 while(n && IS_SEP(path[n - 1]))
67 --n;
68 }
69 if(curlx_dyn_addn(&out, path, n))
70 return NULL;
71 /* if there was a directory, append a single trailing slash */
72 if(n && curlx_dyn_addn(&out, PATHSEP, 1))
73 return NULL;
74 return curlx_dyn_ptr(&out);
77/*
78 * Curl_fopen() opens a file for writing with a temp name, to be renamed
79 * to the final name when completed. If there is an existing file using this
80 * name at the time of the open, this function will clone the mode from that
81 * file. if 'tempname' is non-NULL, it needs a rename after the file is
82 * written.
83 */
84CURLcode Curl_fopen(struct Curl_easy *data, const char *filename,
85 FILE **fh, char **tempname)
87 CURLcode result = CURLE_WRITE_ERROR;
88 unsigned char randbuf[41];
89 char *tempstore = NULL;
90#ifndef _WIN32
91 curlx_struct_stat sb;
92#endif
93 int fd = -1;
94 char *dir = NULL;
95 *tempname = NULL;
97#ifndef _WIN32
98 *fh = curlx_fopen(filename, FOPEN_WRITETEXT);
99 if(!*fh)
100 goto fail;
101 if(curlx_fstat(fileno(*fh), &sb) == -1 || !S_ISREG(sb.st_mode)) {
102 return CURLE_OK;
103 }
104 curlx_fclose(*fh);
105#endif /* !_WIN32 */
106 *fh = NULL;
108 result = Curl_rand_alnum(data, randbuf, sizeof(randbuf));
109 if(result)
110 goto fail;
112 dir = dirslash(filename);
113 if(dir) {
114 /* The temp filename should not end up too long for the target file
115 system */
116 tempstore = curl_maprintf("%s%s.tmp", dir, randbuf);
117 curlx_free(dir);
118 }
120 if(!tempstore) {
121 result = CURLE_OUT_OF_MEMORY;
122 goto fail;
123 }
125 result = CURLE_WRITE_ERROR;
126#ifdef _WIN32
127 fd = curlx_open(tempstore, _O_WRONLY | _O_CREAT | _O_EXCL,
128 _S_IREAD | _S_IWRITE);
129#else
130 fd = curlx_open(tempstore, O_WRONLY | O_CREAT | O_EXCL,
131 (mode_t)(S_IRUSR | S_IWUSR | 0600));
132#endif
133 if(fd == -1)
134 goto fail;
136#ifdef HAVE_FCHMOD
137 {
138 curlx_struct_stat nsb;
139 if((curlx_fstat(fd, &nsb) != -1) &&
140 (nsb.st_uid == sb.st_uid) && (nsb.st_gid == sb.st_gid)) {
141 /* if the user and group are the same, clone the original mode */
142 if(fchmod(fd, (mode_t)sb.st_mode) == -1)
143 goto fail;
144 }
145 }
146#endif
148 *fh = curlx_fdopen(fd, FOPEN_WRITETEXT);
149 if(!*fh)
150 goto fail;
152 *tempname = tempstore;
153 return CURLE_OK;
155fail:
156 if(fd != -1) {
157 curlx_close(fd);
158 unlink(tempstore);
159 }
161 curlx_free(tempstore);
162 return result;
165#endif /* !disabled */
Diagnostics4 git calls · 47 ms
CallStatusSizeTime047 ms
discover200152 B3 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 · 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=41
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=86
Open pack map
fetch2002.0 KiB · hit41 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2038
git.response.cache=HIT
git.response.duration_ms=41
git.fetch.wants=10c04179443a4c2ed61097d29addc6ff53dfc345
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=2038
git.pkt.payload.max=2017
git.sideband.band1.bytes=2016
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
a5e2cc0218db7929
Request
19a1752e…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format