Artifactspublic-v0

curl

master
ply4 git calls235 ms289 KiB2 cachedprotocol v2
139 lines6.7 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.
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.
18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19# KIND, either express or implied.
21# SPDX-License-Identifier: curl
23###########################################################################
25import logging
27import pytest
28from testenv import CurlClient, Env
30log = logging.getLogger(__name__)
33@pytest.mark.skipif(condition=not Env.have_ssl_curl(), reason="curl without SSL")
34class TestReuse:
36 # check if HTTP/1.1 handles 'Connection: close' correctly
37 @pytest.mark.parametrize("proto", ['http/1.1'])
38 def test_12_01_h1_conn_close(self, env: Env, httpd, configures_httpd, nghttpx, proto):
39 httpd.reset_config()
40 httpd.set_extra_config('base', [
41 'MaxKeepAliveRequests 1',
42 ])
43 httpd.reload_if_config_changed()
44 count = 100
45 curl = CurlClient(env=env)
46 urln = f'https://{env.authority_for(env.domain1, proto)}/data.json?[0-{count-1}]'
47 r = curl.http_download(urls=[urln], alpn_proto=proto)
48 r.check_response(count=count, http_status=200)
49 # Server sends `Connection: close` on every 2nd request, requiring
50 # a new connection
51 delta = 5
52 assert (count/2 - delta) < r.total_connects < (count/2 + delta)
54 @pytest.mark.skipif(condition=Env.httpd_is_at_least('2.5.0'),
55 reason="httpd 2.5+ handles KeepAlives different")
56 @pytest.mark.parametrize("proto", ['http/1.1'])
57 def test_12_02_h1_conn_timeout(self, env: Env, httpd, configures_httpd, nghttpx, proto):
58 httpd.reset_config()
59 httpd.set_extra_config('base', [
60 'KeepAliveTimeout 1',
61 ])
62 httpd.reload_if_config_changed()
63 count = 5
64 curl = CurlClient(env=env)
65 urln = f'https://{env.authority_for(env.domain1, proto)}/data.json?[0-{count-1}]'
66 r = curl.http_download(urls=[urln], alpn_proto=proto, extra_args=[
67 '--rate', '30/m',
68 ])
69 r.check_response(count=count, http_status=200)
70 # Connections time out on server before we send another request,
71 assert r.total_connects == count
73 # After a partial/aborted HTTP/1.1 response the connection must not be
74 # reused (multi_conn_should_close with premature on non-multiplexed conn).
75 @pytest.mark.parametrize("proto", ['http/1.1'])
76 def test_12_03_no_reuse_after_partial(self, env: Env, httpd, nghttpx, proto):
77 curl = CurlClient(env=env)
78 auth = env.authority_for(env.domain1, proto)
79 # Server promises more bytes than it sends, then resets.
80 partial = f'https://{auth}/curltest/tweak?id=0&chunks=1&chunk_size=100&body_error=reset'
81 ok = f'https://{auth}/data.json'
82 r = curl.http_download(urls=[partial, ok], alpn_proto=proto, extra_args=[
83 '--retry', '0',
84 ])
85 # First transfer fails (partial/reset); second succeeds on a new connection.
86 assert len(r.stats) == 2, r.dump_logs()
87 assert r.stats[0]['exitcode'] != 0, r.dump_logs()
88 assert r.stats[1].get('http_code') == 200, r.dump_logs()
89 # Both transfers must open their own connection.
90 assert r.stats[0]['num_connects'] == 1, r.dump_logs()
91 assert r.stats[1]['num_connects'] == 1, r.dump_logs()
92 assert r.total_connects == 2, r.dump_logs()
94 # HTTP uses PROTOPT_CREDSPERREQUEST: Basic credentials are per request, so
95 # different -u values still reuse the idle connection (unlike Negotiate
96 # which bind credentials onto the connection).
97 @pytest.mark.parametrize("proto", ['http/1.1'])
98 def test_12_04_reuse_different_basic_credentials(self, env: Env, httpd, nghttpx, proto):
99 curl = CurlClient(env=env)
100 url1 = f'https://{env.authority_for(env.domain1, proto)}/data.json?cred=1'
101 url2 = f'https://{env.authority_for(env.domain1, proto)}/data.json?cred=2'
102 r = curl.http_download(urls=[url1, url2], alpn_proto=proto, url_options={
103 url1: ['-u', 'user1:password1'],
104 url2: ['-u', 'user2:password2'],
105 })
106 assert len(r.stats) == 2, r.dump_logs()
107 assert r.stats[0].get('http_code') == 200, r.dump_logs()
108 assert r.stats[1].get('http_code') == 200, r.dump_logs()
109 assert r.stats[0]['num_connects'] == 1, r.dump_logs()
110 assert r.stats[1]['num_connects'] == 0, r.dump_logs()
111 assert r.total_connects == 1, r.dump_logs()
113 # Different target hostnames must not reuse even if they resolve to the
114 # same address (Curl_peer_same_destination matches hostname + port).
115 @pytest.mark.parametrize("proto", ['http/1.1'])
116 def test_12_05_no_reuse_different_host(self, env: Env, httpd, nghttpx, proto):
117 curl = CurlClient(env=env)
118 # domain1 and domain2 are both served by the same httpd instance.
119 url1 = f'https://{env.authority_for(env.domain1, proto)}/data.json'
120 url2 = f'https://{env.authority_for(env.domain2, proto)}/data.json'
121 r = curl.http_download(urls=[url1, url2], alpn_proto=proto)
122 r.check_response(count=2, http_status=200)
123 assert r.stats[0]['num_connects'] == 1, r.dump_logs()
124 assert r.stats[1]['num_connects'] == 1, r.dump_logs()
125 assert r.total_connects == 2, r.dump_logs()
127 # Positive control: same host reuses one connection.
128 @pytest.mark.parametrize("proto", ['http/1.1'])
129 def test_12_06_reuse_same_host(self, env: Env, httpd, nghttpx, proto):
130 curl = CurlClient(env=env)
131 url1 = f'https://{env.authority_for(env.domain1, proto)}/data.json?a=1'
132 url2 = f'https://{env.authority_for(env.domain1, proto)}/data.json?a=2'
133 r = curl.http_download(urls=[url1, url2], alpn_proto=proto)
134 assert len(r.stats) == 2, r.dump_logs()
135 assert r.stats[0].get('http_code') == 200, r.dump_logs()
136 assert r.stats[1].get('http_code') == 200, r.dump_logs()
137 assert r.stats[0]['num_connects'] == 1, r.dump_logs()
138 assert r.stats[1]['num_connects'] == 0, r.dump_logs()
139 assert r.total_connects == 1, r.dump_logs()
Diagnostics4 git calls · 235 ms
CallStatusSizeTime0235 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 · hit28 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=28
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 KiB205 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=205
git.response.bytes=2066
git.response.cache=MISS
git.response.duration_ms=205
git.fetch.wants=b9ac87f486e9c8b73908c1e946c44b876ebef6b7
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=2066
git.pkt.payload.max=2045
git.sideband.band1.bytes=2044
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
a5e2f48418847089
Request
c64812cd…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format