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"
28#ifndef CURL_DISABLE_WEBSOCKETS
30struct test_ws_pause_ctx {
31 CURL *easy;
32 int callback_count;
33 int paused;
34 int frames;
35 int errors;
36 int closed;
37};
39static size_t test_ws_pause_write_cb(char *ptr, size_t size, size_t nmemb,
40 void *userdata)
41{
42 struct test_ws_pause_ctx *ctx = userdata;
43 size_t nbytes = size * nmemb;
44 const struct curl_ws_frame *meta = curl_ws_meta(ctx->easy);
46 ctx->callback_count++;
47 if(!meta) {
48 curl_mfprintf(stderr, "write_cb: ERROR call #%d with meta=NULL\n",
49 ctx->callback_count);
50 ++ctx->errors;
51 return CURL_WRITEFUNC_ERROR;
52 }
54 ++ctx->frames;
55 if(meta->len < nbytes) {
56 curl_mfprintf(stderr, "write_cb: ERROR call #%d more data than current "
57 "frame, FRAME[flags=0x%x age=%d offset=%" FMT_OFF_T
58 " bytesleft=%" FMT_OFF_T " len=%zu], bytes=%zu\n",
59 ctx->callback_count,
60 (unsigned int)meta->flags, meta->age,
61 meta->offset, meta->bytesleft, meta->len, nbytes);
62 ++ctx->errors;
63 return CURL_WRITEFUNC_ERROR;
64 }
66 if(meta->flags == 0x1) { /* TEXT frame */
67 curl_mfprintf(stderr, "write_cb: call #%d FRAME[TEXT age=%d offset=%"
68 FMT_OFF_T " bytesleft=%" FMT_OFF_T " len=%zu] '%.*s'\n",
69 ctx->callback_count, meta->age,
70 meta->offset, meta->bytesleft, meta->len,
71 (int)nbytes, ptr);
72 }
73 else if(meta->flags == 0x8) {
74 curl_mfprintf(stderr, "write_cb: call #%d FRAME[CLOSE age=%d offset=%"
75 FMT_OFF_T " bytesleft=%" FMT_OFF_T " len=%zu] bytes=%zu\n",
76 ctx->callback_count, meta->age,
77 meta->offset, meta->bytesleft, meta->len, nbytes);
78 ctx->closed = TRUE;
79 }
80 else {
81 curl_mfprintf(stderr, "write_cb: call #%d FRAME[flags=0x%x age=%d offset=%"
82 FMT_OFF_T " bytesleft=%" FMT_OFF_T " len=%zu\n",
83 ctx->callback_count,
84 (unsigned int)meta->flags, meta->age,
85 meta->offset, meta->bytesleft, meta->len);
86 }
88 if(ctx->callback_count == 1 || ctx->callback_count == 3) {
89 ctx->paused = 1;
90 curl_mfprintf(stderr, "write_cb: call #%d PAUSING\n", ctx->callback_count);
91 return CURL_WRITEFUNC_PAUSE;
92 }
93 return nbytes;
94}
95#endif /* CURL_DISABLE_WEBSOCKETS */
97static CURLcode test_cli_ws_pause(const char *URL)
98{
99#ifndef CURL_DISABLE_WEBSOCKETS
100 struct test_ws_pause_ctx ctx;
101 CURLM *multi;
102 int still_running = 0;
103 int msgs_left = 0;
104 int done = 0;
106 memset(&ctx, 0, sizeof(ctx));
107 setbuf(stdout, NULL);
109 curl_global_init(CURL_GLOBAL_ALL);
111 ctx.easy = curl_easy_init();
112 multi = curl_multi_init();
113 if(!ctx.easy || !multi) {
114 curl_mfprintf(stderr, "main: ERROR creating easy/multi\n");
115 ctx.errors = 1;
116 goto out;
117 }
119 curl_easy_setopt(ctx.easy, CURLOPT_URL, URL);
120 curl_easy_setopt(ctx.easy, CURLOPT_WRITEFUNCTION, test_ws_pause_write_cb);
121 curl_easy_setopt(ctx.easy, CURLOPT_WRITEDATA, &ctx);
122 curl_easy_setopt(ctx.easy, CURLOPT_VERBOSE, 1L);
124 curl_multi_add_handle(multi, ctx.easy);
125 curl_multi_perform(multi, &still_running);
127 while(still_running && !ctx.closed && !ctx.errors) {
129 if(ctx.paused) {
130 curl_mfprintf(stderr, "main: wait and UNPAUSE\n");
131 curlx_wait_ms(500);
132 ctx.paused = 0;
133 curl_easy_pause(ctx.easy, CURLPAUSE_CONT);
134 }
136 curl_mfprintf(stderr, "main: poll\n");
137 curl_multi_poll(multi, NULL, 0, 100, NULL);
138 curl_mfprintf(stderr, "main: perform\n");
139 curl_multi_perform(multi, &still_running);
141 while(!done) {
142 CURLMsg *msg = curl_multi_info_read(multi, &msgs_left);
143 if(!msg)
144 break;
145 if(msg->msg == CURLMSG_DONE) {
146 curl_mfprintf(stderr, "main: done result=%d (%s)\n",
147 (int)msg->data.result,
148 curl_easy_strerror(msg->data.result));
149 done = 1;
150 }
151 }
152 }
154out:
155 if(ctx.easy) {
156 if(multi)
157 curl_multi_remove_handle(multi, ctx.easy);
158 curl_easy_cleanup(ctx.easy);
159 }
160 if(multi)
161 curl_multi_cleanup(multi);
162 curl_global_cleanup();
164 return ctx.errors ? CURLE_WRITE_ERROR : CURLE_OK;
166#else /* !CURL_DISABLE_WEBSOCKETS */
167 (void)URL;
168 curl_mfprintf(stderr, "WebSockets not enabled in libcurl\n");
169 return (CURLcode)1;
170#endif /* CURL_DISABLE_WEBSOCKETS */
171}
Diagnostics4 git calls · 246 ms
CallStatusSizeTime0246 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.8 KiB241 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=241 git.response.bytes=1809 git.response.cache=MISS git.response.duration_ms=241 git.fetch.wants=b42331400324094d6ee7d607292574f2643ec8b7 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=1809 git.pkt.payload.max=1788 git.sideband.band1.bytes=1787 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
- a5e2ba487d2bcf46
- Request
- 80b3e3ce…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format