Artifactspublic-v0

curl

master
ply4 git calls28 ms289 KiB3 cachedprotocol v2
164 lines6.1 KiBRaw
1#ifndef HEADER_CURL_PINGPONG_H
2#define HEADER_CURL_PINGPONG_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.se/docs/copyright.html.
15 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 * SPDX-License-Identifier: curl
24 *
25 ***************************************************************************/
26#include "curl_setup.h"
28#if !defined(CURL_DISABLE_IMAP) || !defined(CURL_DISABLE_FTP) || \
29 !defined(CURL_DISABLE_POP3) || !defined(CURL_DISABLE_SMTP)
30#define USE_PINGPONG
31#endif
33/* forward-declaration, this is defined in urldata.h */
34struct connectdata;
36typedef enum {
37 PPTRANSFER_BODY, /* yes do transfer a body */
38 PPTRANSFER_INFO, /* do still go through to get info/headers */
39 PPTRANSFER_NONE /* do not get anything and do not get info */
40} curl_pp_transfer;
42/*
43 * 'pingpong' is the generic struct used for protocols doing server<->client
44 * conversations in a back-and-forth style such as FTP, IMAP, POP3, SMTP etc.
45 *
46 * It holds response cache and non-blocking sending data.
47 */
48struct pingpong {
49 size_t nread_resp; /* number of bytes currently read of a server response */
50 char *sendthis; /* pointer to a buffer that is to be sent to the server */
51 size_t sendleft; /* number of bytes left to send from the sendthis buffer */
52 size_t sendsize; /* total size of the sendthis buffer */
53 struct curltime response; /* set to Curl_now() when a command has been sent
54 off, used to time-out response reading */
55 struct dynbuf sendbuf;
56 struct dynbuf recvbuf;
57 size_t overflow; /* number of bytes left after a final response line */
58 size_t nfinal; /* number of bytes in the final response line, which
59 after a match is first in the receive buffer */
61 /* Function pointers the protocols MUST implement and provide for the
62 pingpong layer to function */
64 CURLcode (*statemachine)(struct Curl_easy *data, struct connectdata *conn);
65 bool (*endofresp)(struct Curl_easy *data, struct connectdata *conn,
66 const char *ptr, size_t len, int *code);
67 BIT(initialized);
68 BIT(pending_resp); /* set TRUE when a server response is pending or in
69 progress, and is cleared once the last response is
70 read */
71};
73/* Default pingpong response timeout in milliseconds, unless a transfer
74 * has CURLOPT_SERVER_RESPONSE_TIMEOUT(_MS) set. */
75#define PINGPONG_TIMEOUT_MS (60 * 1000)
77#define PINGPONG_SETUP(pp, s, e) \
78 do { \
79 (pp)->statemachine = s; \
80 (pp)->endofresp = e; \
81 } while(0)
83/*
84 * Curl_pp_statemach()
85 *
86 * called repeatedly until done. Set 'wait' to make it wait a while on the
87 * socket if there is no traffic.
88 */
89CURLcode Curl_pp_statemach(struct Curl_easy *data, struct pingpong *pp,
90 bool block, bool disconnecting);
92/* initialize stuff to prepare for reading a fresh new response */
93void Curl_pp_init(struct pingpong *pp, const struct curltime *pnow);
95/* Returns time remaining in ms. 0 or negative number means the
96 timeout has already triggered */
97timediff_t Curl_pp_state_timeleft_ms(struct Curl_easy *data,
98 struct pingpong *pp);
100/***********************************************************************
101 *
102 * Curl_pp_sendf()
103 *
104 * Send the formatted string as a command to a pingpong server. Note that
105 * the string should not have any CRLF appended, as this function will
106 * append the necessary things itself.
107 *
108 * made to never block
109 */
110CURLcode Curl_pp_sendf(struct Curl_easy *data,
111 struct pingpong *pp,
112 const char *fmt, ...) CURL_PRINTF(3, 4);
114/***********************************************************************
115 *
116 * Curl_pp_vsendf()
117 *
118 * Send the formatted string as a command to a pingpong server. Note that
119 * the string should not have any CRLF appended, as this function will
120 * append the necessary things itself.
121 * If `prefix` is non-NULL, prepend it with an added space before the format.
122 *
123 * made to never block
124 */
125CURLcode Curl_pp_vsendf(struct Curl_easy *data,
126 struct pingpong *pp,
127 const char *prefix,
128 const char *fmt,
129 va_list args) CURL_PRINTF(4, 0);
131/*
132 * Curl_pp_readresp()
133 *
134 * Reads a piece of a server response.
135 */
136CURLcode Curl_pp_readresp(struct Curl_easy *data,
137 int8_t sockindex,
138 struct pingpong *pp,
139 int *code, /* return the server code if done */
140 size_t *size); /* size of the response */
142bool Curl_pp_needs_flush(struct Curl_easy *data,
143 struct pingpong *pp);
145CURLcode Curl_pp_flushsend(struct Curl_easy *data,
146 struct pingpong *pp);
148/* call this when a pingpong connection is disconnected */
149CURLcode Curl_pp_disconnect(struct pingpong *pp);
151CURLcode Curl_pp_pollset(struct Curl_easy *data,
152 struct pingpong *pp,
153 struct easy_pollset *ps);
155/***********************************************************************
156 *
157 * Curl_pp_moredata()
158 *
159 * Returns whether there are still more data in the cache and so a call
160 * to Curl_pp_readresp() will not block.
161 */
162bool Curl_pp_moredata(struct pingpong *pp);
164#endif /* HEADER_CURL_PINGPONG_H */
Diagnostics4 git calls · 28 ms
CallStatusSizeTime028 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 · 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 · hit4 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=20
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=86
Open pack map
fetch2002.3 KiB · hit21 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2322
git.response.cache=HIT
git.response.duration_ms=21
git.fetch.wants=c1f9c27b2008354b99233ee7b66c4a0656cd1e5e
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=2322
git.pkt.payload.max=2301
git.sideband.band1.bytes=2300
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
a5e1b6d9e8385b65
Request
465d38e3…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format