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#
25import logging
26import os
28import pytest
29from testenv import CurlClient, Env
31log = logging.getLogger(__name__)
34class TestInfo:
36 @pytest.fixture(autouse=True, scope='class')
37 @classmethod
38 def _class_scope(cls, env, httpd):
39 indir = httpd.docs_dir
40 env.make_data_file(indir=indir, fname="data-10k", fsize=10 * 1024)
41 env.make_data_file(indir=indir, fname="data-100k", fsize=100 * 1024)
42 env.make_data_file(indir=indir, fname="data-1m", fsize=1024 * 1024)
43 env.make_data_file(indir=env.gen_dir, fname="data-100k", fsize=100 * 1024)
45 # download plain file
46 @pytest.mark.parametrize("proto", Env.http_protos())
47 def test_16_01_info_download(self, env: Env, httpd, nghttpx, proto):
48 count = 2
49 curl = CurlClient(env=env)
50 url = f'https://{env.authority_for(env.domain1, proto)}/data.json?[0-{count-1}]'
51 r = curl.http_download(urls=[url], alpn_proto=proto, with_stats=True)
52 r.check_stats(count=count, http_status=200, exitcode=0,
53 remote_port=env.port_for(alpn_proto=proto),
54 remote_ip='127.0.0.1')
55 for idx, s in enumerate(r.stats):
56 self.check_stat(idx, s, r, dl_size=30, ul_size=0)
57 r.check_stats_timeline(idx)
59 # download plain file with a 302 redirect
60 @pytest.mark.parametrize("proto", Env.http_protos())
61 def test_16_02_info_302_download(self, env: Env, httpd, nghttpx, proto):
62 count = 2
63 curl = CurlClient(env=env)
64 url = f'https://{env.authority_for(env.domain1, proto)}/data.json.302?[0-{count-1}]'
65 r = curl.http_download(urls=[url], alpn_proto=proto, with_stats=True, extra_args=[
66 '--location'
67 ])
68 r.check_stats(count=count, http_status=200, exitcode=0,
69 remote_port=env.port_for(alpn_proto=proto),
70 remote_ip='127.0.0.1')
71 for idx, s in enumerate(r.stats):
72 self.check_stat(idx, s, r, dl_size=30, ul_size=0)
73 r.check_stats_timeline(idx)
75 @pytest.mark.parametrize("proto", Env.http_protos())
76 def test_16_03_info_upload(self, env: Env, httpd, nghttpx, proto):
77 count = 2
78 fdata = os.path.join(env.gen_dir, 'data-100k')
79 fsize = 100 * 1024
80 curl = CurlClient(env=env)
81 url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-{count-1}]'
82 r = curl.http_upload(urls=[url], data=f'@{fdata}', alpn_proto=proto,
83 with_headers=True, extra_args=[
84 '--trace-config', 'http/2,http/3'
85 ])
86 r.check_response(count=count, http_status=200)
87 r.check_stats(count=count, http_status=200, exitcode=0,
88 remote_port=env.port_for(alpn_proto=proto),
89 remote_ip='127.0.0.1')
90 for idx, s in enumerate(r.stats):
91 self.check_stat(idx, s, r, dl_size=fsize, ul_size=fsize)
92 r.check_stats_timeline(idx)
94 # download plain file via http: ('time_appconnect' is 0)
95 @pytest.mark.parametrize("proto", ['http/1.1'])
96 def test_16_04_info_http_download(self, env: Env, httpd, nghttpx, proto):
97 count = 2
98 curl = CurlClient(env=env)
99 url = f'http://{env.domain1}:{env.http_port}/data.json?[0-{count-1}]'
100 r = curl.http_download(urls=[url], alpn_proto=proto, with_stats=True)
101 r.check_stats(count=count, http_status=200, exitcode=0,
102 remote_port=env.http_port, remote_ip='127.0.0.1')
103 for idx, s in enumerate(r.stats):
104 self.check_stat(idx, s, r, dl_size=30, ul_size=0)
105 r.check_stats_timeline(idx)
107 def check_stat(self, idx, s, r, dl_size=None, ul_size=None):
108 # we always send something
109 self.check_stat_positive(s, idx, 'size_request')
110 # we always receive response headers
111 self.check_stat_positive(s, idx, 'size_header')
112 if ul_size is not None:
113 assert s['size_upload'] == ul_size, f'stat #{idx}\n{r.dump_logs()}' # the file we sent
114 assert s['size_request'] >= s['size_upload'], \
115 f'stat #{idx}, "size_request" smaller than "size_upload", {s}\n{r.dump_logs()}'
116 if dl_size is not None:
117 assert s['size_download'] == dl_size, f'stat #{idx}\n{r.dump_logs()}' # the file we received
119 def check_stat_positive(self, s, idx, key):
120 assert key in s, f'stat #{idx} "{key}" missing: {s}'
121 assert s[key] > 0, f'stat #{idx} "{key}" not positive: {s}'
Diagnostics4 git calls · 23 ms
CallStatusSizeTime023 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 · 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 · 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.6 KiB · hit17 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=17 git.response.bytes=1664 git.response.cache=HIT git.response.duration_ms=17 git.fetch.wants=a7160badc7f0381bb6f3833854b9fa33c3c28d5e 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=1664 git.pkt.payload.max=1643 git.sideband.band1.bytes=1642 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
- a5e2e9228a6cecfa
- Request
- 2c41d8d9…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format