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, Dante, Env
31log = logging.getLogger(__name__)
34@pytest.mark.skipif(condition=not Env.has_danted(), reason="missing danted")
35class TestSocks:
37 @pytest.fixture(autouse=True, scope='class')
38 @classmethod
39 def _class_scope(cls, env, httpd):
40 indir = httpd.docs_dir
41 env.make_data_file(indir=indir, fname="data-10m", fsize=10 * 1024 * 1024)
42 env.make_data_file(indir=env.gen_dir, fname="data-10m", fsize=10 * 1024 * 1024)
44 @pytest.mark.parametrize("sproto", ['socks4', 'socks5'])
45 def test_40_01_socks_http(self, env: Env, sproto, danted: Dante, httpd):
46 curl = CurlClient(env=env, socks_args=[
47 f'--{sproto}', f'127.0.0.1:{danted.port}'
48 ])
49 url = f'http://{env.domain1}:{env.http_port}/data.json'
50 r = curl.http_get(url=url)
51 r.check_response(http_status=200)
53 @pytest.mark.parametrize("sproto", ['socks4', 'socks5'])
54 @pytest.mark.parametrize("proto", Env.http_protos())
55 def test_40_02_socks_https(self, env: Env, sproto, proto, danted: Dante, httpd):
56 curl = CurlClient(env=env, socks_args=[
57 f'--{sproto}', f'127.0.0.1:{danted.port}'
58 ])
59 url = f'https://{env.authority_for(env.domain1, proto)}/data.json'
60 r = curl.http_get(url=url, alpn_proto=proto)
61 if proto == 'h3':
62 assert r.exit_code == 3 # unsupported combination
63 else:
64 r.check_response(http_status=200)
66 # download via socks to https: proxy (no tunnel)
67 @pytest.mark.parametrize("sproto", ['socks4', 'socks5'])
68 @pytest.mark.parametrize("proto", Env.http_h1_h2_protos())
69 def test_40_02b_socks_https_proxy(self, env: Env, sproto, proto, danted: Dante, httpd):
70 if proto == 'h2' and not env.curl_uses_lib('nghttp2'):
71 pytest.skip('only supported with nghttp2')
72 curl = CurlClient(env=env, socks_args=[
73 f'--{sproto}', f'127.0.0.1:{danted.port}'
74 ])
75 url = f'http://localhost:{env.http_port}/data.json'
76 xargs = curl.get_proxy_args(proto=proto, tunnel=False)
77 r = curl.http_download(urls=[url], alpn_proto=proto, with_stats=True,
78 extra_args=xargs)
79 r.check_response(http_status=200)
80 exp_http_version = '2' if proto == 'h2' else '1.1'
81 assert r.stats[0]['proxy_used'] == 1, f'{r}'
82 assert r.stats[0]['http_version'] == exp_http_version, f'{r}'
84 @pytest.mark.parametrize("sproto", ['socks4', 'socks5'])
85 @pytest.mark.parametrize("proto", Env.http_h1_h2_protos())
86 def test_40_03_dl_serial(self, env: Env, httpd, danted, proto, sproto):
87 count = 3
88 urln = f'https://{env.authority_for(env.domain1, proto)}/data-10m?[0-{count-1}]'
89 curl = CurlClient(env=env, socks_args=[
90 f'--{sproto}', f'127.0.0.1:{danted.port}'
91 ])
92 r = curl.http_download(urls=[urln], alpn_proto=proto)
93 r.check_response(count=count, http_status=200)
95 @pytest.mark.parametrize("sproto", ['socks4', 'socks5'])
96 @pytest.mark.parametrize("proto", Env.http_h1_h2_protos())
97 def test_40_04_ul_serial(self, env: Env, httpd, danted, proto, sproto):
98 fdata = os.path.join(env.gen_dir, 'data-10m')
99 count = 2
100 curl = CurlClient(env=env, socks_args=[
101 f'--{sproto}', f'127.0.0.1:{danted.port}'
102 ])
103 url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-{count-1}]'
104 r = curl.http_upload(urls=[url], data=f'@{fdata}', alpn_proto=proto)
105 r.check_stats(count=count, http_status=200, exitcode=0)
106 with open(fdata) as fi:
107 indata = fi.readlines()
108 for i in range(count):
109 with open(curl.response_file(i)) as fr:
110 respdata = fr.readlines()
111 assert respdata == indata
Diagnostics4 git calls · 26 ms
CallStatusSizeTime026 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=3 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=20 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 · hit20 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=1643 git.response.cache=HIT git.response.duration_ms=20 git.fetch.wants=d29e03314367fed1067de0fda9d9e87e104dc34b 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=1643 git.pkt.payload.max=1622 git.sideband.band1.bytes=1621 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
- a5e2df8658c92308
- Request
- 78fc3d1a…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format