mirror of
https://github.com/curl/curl.git
synced 2026-08-26 00:23:32 +03:00
http2: polish things around POST
- added test cases for various code paths
- fixed handling of blocked write when stream had
been closed inbetween attempts
- re-enabled DEBUGASSERT on send with smaller data size
- in debug builds, environment variables can be set to simulate a slow
network when sending data. cf-socket.c and vquic.c support
* CURL_DBG_SOCK_WBLOCK: percentage of send() calls that should be
answered with a EAGAIN. TCP/UNIX sockets.
This is chosen randomly.
* CURL_DBG_SOCK_WPARTIAL: percentage of data that shall be written
to the network. TCP/UNIX sockets.
Example: 80 means a send with 1000 bytes would only send 800
This is applied to every send.
* CURL_DBG_QUIC_WBLOCK: percentage of send() calls that should be
answered with EAGAIN. QUIC only.
This is chosen randomly.
Closes #11756
This commit is contained in:
parent
c9260cf9fe
commit
331b89a319
23 changed files with 897 additions and 164 deletions
|
|
@ -81,6 +81,6 @@ class TestBasic:
|
|||
def test_01_05_h3_get(self, env: Env, httpd, nghttpx):
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.domain1}:{env.h3_port}/data.json'
|
||||
r = curl.http_get(url=url, extra_args=['--http3'])
|
||||
r = curl.http_get(url=url, extra_args=['--http3-only'])
|
||||
r.check_response(http_status=200, protocol='HTTP/3')
|
||||
assert r.json['server'] == env.domain1
|
||||
|
|
|
|||
|
|
@ -200,6 +200,7 @@ class TestDownload:
|
|||
])
|
||||
r.check_response(count=count, http_status=200)
|
||||
|
||||
@pytest.mark.skipif(condition=Env.slow_network, reason="not suitable for slow network tests")
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_02_10_10MB_serial(self, env: Env,
|
||||
httpd, nghttpx, repeat, proto):
|
||||
|
|
@ -211,6 +212,7 @@ class TestDownload:
|
|||
r = curl.http_download(urls=[urln], alpn_proto=proto)
|
||||
r.check_response(count=count, http_status=200)
|
||||
|
||||
@pytest.mark.skipif(condition=Env.slow_network, reason="not suitable for slow network tests")
|
||||
@pytest.mark.parametrize("proto", ['h2', 'h3'])
|
||||
def test_02_11_10MB_parallel(self, env: Env,
|
||||
httpd, nghttpx, repeat, proto):
|
||||
|
|
@ -252,6 +254,7 @@ class TestDownload:
|
|||
])
|
||||
r.check_response(count=count, http_status=200)
|
||||
|
||||
@pytest.mark.skipif(condition=Env.slow_network, reason="not suitable for slow network tests")
|
||||
def test_02_20_h2_small_frames(self, env: Env, httpd, repeat):
|
||||
# Test case to reproduce content corruption as observed in
|
||||
# https://github.com/curl/curl/issues/10525
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
###########################################################################
|
||||
#
|
||||
import logging
|
||||
import os
|
||||
from typing import Tuple, List, Dict
|
||||
import pytest
|
||||
|
||||
|
|
@ -34,6 +35,7 @@ from testenv import Env, CurlClient
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@pytest.mark.skipif(condition=Env.slow_network, reason="not suitable for slow network tests")
|
||||
class TestStuttered:
|
||||
|
||||
@pytest.fixture(autouse=True, scope='class')
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ class TestUpload:
|
|||
def _class_scope(self, env, httpd, nghttpx):
|
||||
if env.have_h3():
|
||||
nghttpx.start_if_needed()
|
||||
env.make_data_file(indir=env.gen_dir, fname="data-63k", fsize=63*1024)
|
||||
env.make_data_file(indir=env.gen_dir, fname="data-64k", fsize=64*1024)
|
||||
env.make_data_file(indir=env.gen_dir, fname="data-100k", fsize=100*1024)
|
||||
env.make_data_file(indir=env.gen_dir, fname="data-10m", fsize=10*1024*1024)
|
||||
httpd.clear_extra_configs()
|
||||
|
|
@ -58,7 +60,7 @@ class TestUpload:
|
|||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-0]'
|
||||
r = curl.http_upload(urls=[url], data=data, alpn_proto=proto)
|
||||
r.check_response(count=1, http_status=200)
|
||||
r.check_stats(count=1, http_status=200, exitcode=0)
|
||||
respdata = open(curl.response_file(0)).readlines()
|
||||
assert respdata == [data]
|
||||
|
||||
|
|
@ -73,7 +75,7 @@ class TestUpload:
|
|||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-0]'
|
||||
r = curl.http_upload(urls=[url], data=f'@{fdata}', alpn_proto=proto)
|
||||
r.check_response(count=1, http_status=200)
|
||||
r.check_stats(count=1, http_status=200, exitcode=0)
|
||||
indata = open(fdata).readlines()
|
||||
respdata = open(curl.response_file(0)).readlines()
|
||||
assert respdata == indata
|
||||
|
|
@ -90,7 +92,7 @@ class TestUpload:
|
|||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-{count-1}]'
|
||||
r = curl.http_upload(urls=[url], data=data, alpn_proto=proto)
|
||||
r.check_response(count=count, http_status=200)
|
||||
r.check_stats(count=count, http_status=200, exitcode=0)
|
||||
for i in range(count):
|
||||
respdata = open(curl.response_file(i)).readlines()
|
||||
assert respdata == [data]
|
||||
|
|
@ -109,14 +111,14 @@ class TestUpload:
|
|||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-{count-1}]'
|
||||
r = curl.http_upload(urls=[url], data=data, alpn_proto=proto,
|
||||
extra_args=['--parallel'])
|
||||
r.check_response(count=count, http_status=200)
|
||||
r.check_stats(count=count, http_status=200, exitcode=0)
|
||||
for i in range(count):
|
||||
respdata = open(curl.response_file(i)).readlines()
|
||||
assert respdata == [data]
|
||||
|
||||
# upload large data sequentially, check that this is what was echoed
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_07_20_upload_seq_large(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
def test_07_12_upload_seq_large(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
if proto == 'h3' and env.curl_uses_lib('msh3'):
|
||||
|
|
@ -128,14 +130,14 @@ class TestUpload:
|
|||
r = curl.http_upload(urls=[url], data=f'@{fdata}', alpn_proto=proto)
|
||||
r.check_response(count=count, http_status=200)
|
||||
indata = open(fdata).readlines()
|
||||
r.check_response(count=count, http_status=200)
|
||||
r.check_stats(count=count, http_status=200, exitcode=0)
|
||||
for i in range(count):
|
||||
respdata = open(curl.response_file(i)).readlines()
|
||||
assert respdata == indata
|
||||
|
||||
# upload very large data sequentially, check that this is what was echoed
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_07_12_upload_seq_large(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
def test_07_13_upload_seq_large(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
if proto == 'h3' and env.curl_uses_lib('msh3'):
|
||||
|
|
@ -145,7 +147,7 @@ class TestUpload:
|
|||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-{count-1}]'
|
||||
r = curl.http_upload(urls=[url], data=f'@{fdata}', alpn_proto=proto)
|
||||
r.check_response(count=count, http_status=200)
|
||||
r.check_stats(count=count, http_status=200, exitcode=0)
|
||||
indata = open(fdata).readlines()
|
||||
for i in range(count):
|
||||
respdata = open(curl.response_file(i)).readlines()
|
||||
|
|
@ -165,7 +167,7 @@ class TestUpload:
|
|||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-{count-1}]'
|
||||
r = curl.http_upload(urls=[url], data=data, alpn_proto=proto,
|
||||
extra_args=['--parallel'])
|
||||
r.check_response(count=count, http_status=200)
|
||||
r.check_stats(count=count, http_status=200, exitcode=0)
|
||||
for i in range(count):
|
||||
respdata = open(curl.response_file(i)).readlines()
|
||||
assert respdata == [data]
|
||||
|
|
@ -200,7 +202,7 @@ class TestUpload:
|
|||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/put?id=[0-{count-1}]'
|
||||
r = curl.http_put(urls=[url], fdata=fdata, alpn_proto=proto,
|
||||
extra_args=['--parallel'])
|
||||
r.check_response(count=count, http_status=200)
|
||||
r.check_stats(count=count, http_status=200, exitcode=0)
|
||||
exp_data = [f'{os.path.getsize(fdata)}']
|
||||
r.check_response(count=count, http_status=200)
|
||||
for i in range(count):
|
||||
|
|
@ -220,7 +222,7 @@ class TestUpload:
|
|||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/put?id=[0-{count-1}]&chunk_delay=10ms'
|
||||
r = curl.http_put(urls=[url], fdata=fdata, alpn_proto=proto,
|
||||
extra_args=['--parallel'])
|
||||
r.check_response(count=count, http_status=200)
|
||||
r.check_stats(count=count, http_status=200, exitcode=0)
|
||||
exp_data = [f'{os.path.getsize(fdata)}']
|
||||
r.check_response(count=count, http_status=200)
|
||||
for i in range(count):
|
||||
|
|
@ -239,7 +241,7 @@ class TestUpload:
|
|||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/put?id=[0-{count-1}]'
|
||||
r = curl.http_put(urls=[url], fdata=fdata, alpn_proto=proto)
|
||||
r.check_response(count=count, http_status=200)
|
||||
r.check_stats(count=count, http_status=200, exitcode=0)
|
||||
|
||||
# issue #11157, upload that is 404'ed by server, needs to terminate
|
||||
# correctly and not time out on sending
|
||||
|
|
@ -272,6 +274,7 @@ class TestUpload:
|
|||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/put?chunk_delay=2ms'
|
||||
curl = CurlClient(env=env)
|
||||
r = curl.run_direct(with_stats=True, args=[
|
||||
'--verbose', '--trace-config', 'ids,time',
|
||||
'--resolve', f'{env.authority_for(env.domain1, proto)}:127.0.0.1',
|
||||
'--cacert', env.ca.cert_file,
|
||||
'--request', 'PUT',
|
||||
|
|
@ -293,7 +296,7 @@ class TestUpload:
|
|||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/put'
|
||||
curl = CurlClient(env=env)
|
||||
r = curl.run_direct(with_stats=True, args=[
|
||||
'--verbose',
|
||||
'--verbose', '--trace-config', 'ids,time',
|
||||
'--resolve', f'{env.authority_for(env.domain1, proto)}:127.0.0.1',
|
||||
'--cacert', env.ca.cert_file,
|
||||
'--request', 'PUT',
|
||||
|
|
@ -319,6 +322,91 @@ class TestUpload:
|
|||
respdata = open(curl.response_file(0)).readlines()
|
||||
assert respdata == indata
|
||||
|
||||
# upload to a 301,302,303 response
|
||||
@pytest.mark.parametrize("redir", ['301', '302', '303'])
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_07_36_upload_30x(self, env: Env, httpd, nghttpx, repeat, redir, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
if proto == 'h3' and env.curl_uses_lib('msh3'):
|
||||
pytest.skip("msh3 fails here")
|
||||
data = '0123456789' * 10
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo{redir}?id=[0-0]'
|
||||
r = curl.http_upload(urls=[url], data=data, alpn_proto=proto, extra_args=[
|
||||
'-L', '--trace-config', 'http/2,http/3'
|
||||
])
|
||||
r.check_response(count=1, http_status=200)
|
||||
respdata = open(curl.response_file(0)).readlines()
|
||||
assert respdata == [] # was transformed to a GET
|
||||
|
||||
# upload to a 307 response
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_07_37_upload_307(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
if proto == 'h3' and env.curl_uses_lib('msh3'):
|
||||
pytest.skip("msh3 fails here")
|
||||
data = '0123456789' * 10
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo307?id=[0-0]'
|
||||
r = curl.http_upload(urls=[url], data=data, alpn_proto=proto, extra_args=[
|
||||
'-L', '--trace-config', 'http/2,http/3'
|
||||
])
|
||||
r.check_response(count=1, http_status=200)
|
||||
respdata = open(curl.response_file(0)).readlines()
|
||||
assert respdata == [data] # was POST again
|
||||
|
||||
# POST form data, yet another code path in transfer
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_07_38_form_small(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
if proto == 'h3' and env.curl_uses_lib('msh3'):
|
||||
pytest.skip("msh3 fails here")
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-0]'
|
||||
r = curl.http_form(urls=[url], alpn_proto=proto, form={
|
||||
'name1': 'value1',
|
||||
})
|
||||
r.check_stats(count=1, http_status=200, exitcode=0)
|
||||
|
||||
# POST data urlencoded, small enough to be sent with request headers
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_07_39_post_urlenc_small(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
if proto == 'h3' and env.curl_uses_lib('msh3'):
|
||||
pytest.skip("msh3 fails here")
|
||||
fdata = os.path.join(env.gen_dir, 'data-63k')
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-0]'
|
||||
r = curl.http_upload(urls=[url], data=f'@{fdata}', alpn_proto=proto, extra_args=[
|
||||
'--trace-config', 'http/2,http/3'
|
||||
])
|
||||
r.check_stats(count=1, http_status=200, exitcode=0)
|
||||
indata = open(fdata).readlines()
|
||||
respdata = open(curl.response_file(0)).readlines()
|
||||
assert respdata == indata
|
||||
|
||||
# POST data urlencoded, large enough to be sent separate from request headers
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_07_40_post_urlenc_large(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
if proto == 'h3' and env.curl_uses_lib('msh3'):
|
||||
pytest.skip("msh3 fails here")
|
||||
fdata = os.path.join(env.gen_dir, 'data-64k')
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-0]'
|
||||
r = curl.http_upload(urls=[url], data=f'@{fdata}', alpn_proto=proto, extra_args=[
|
||||
'--trace-config', 'http/2,http/3'
|
||||
])
|
||||
r.check_stats(count=1, http_status=200, exitcode=0)
|
||||
indata = open(fdata).readlines()
|
||||
respdata = open(curl.response_file(0)).readlines()
|
||||
assert respdata == indata
|
||||
|
||||
def check_download(self, count, srcfile, curl):
|
||||
for i in range(count):
|
||||
dfile = curl.download_file(i)
|
||||
|
|
|
|||
366
tests/http/test_07_upload.py.orig
Normal file
366
tests/http/test_07_upload.py.orig
Normal file
|
|
@ -0,0 +1,366 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#***************************************************************************
|
||||
# _ _ ____ _
|
||||
# Project ___| | | | _ \| |
|
||||
# / __| | | | |_) | |
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
#
|
||||
# This software is licensed as described in the file COPYING, which
|
||||
# you should have received as part of this distribution. The terms
|
||||
# are also available at https://curl.se/docs/copyright.html.
|
||||
#
|
||||
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
# copies of the Software, and permit persons to whom the Software is
|
||||
# furnished to do so, under the terms of the COPYING file.
|
||||
#
|
||||
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
# KIND, either express or implied.
|
||||
#
|
||||
# SPDX-License-Identifier: curl
|
||||
#
|
||||
###########################################################################
|
||||
#
|
||||
import difflib
|
||||
import filecmp
|
||||
import logging
|
||||
import os
|
||||
import pytest
|
||||
|
||||
from testenv import Env, CurlClient
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TestUpload:
|
||||
|
||||
@pytest.fixture(autouse=True, scope='class')
|
||||
def _class_scope(self, env, httpd, nghttpx):
|
||||
if env.have_h3():
|
||||
nghttpx.start_if_needed()
|
||||
env.make_data_file(indir=env.gen_dir, fname="data-63k", fsize=63*1024)
|
||||
env.make_data_file(indir=env.gen_dir, fname="data-64k", fsize=64*1024)
|
||||
env.make_data_file(indir=env.gen_dir, fname="data-100k", fsize=100*1024)
|
||||
env.make_data_file(indir=env.gen_dir, fname="data-10m", fsize=10*1024*1024)
|
||||
httpd.clear_extra_configs()
|
||||
httpd.reload()
|
||||
|
||||
# upload small data, check that this is what was echoed
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_07_01_upload_1_small(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
if proto == 'h3' and env.curl_uses_lib('msh3'):
|
||||
pytest.skip("msh3 fails here")
|
||||
data = '0123456789'
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-0]'
|
||||
r = curl.http_upload(urls=[url], data=data, alpn_proto=proto)
|
||||
r.check_stats(count=1, http_status=200, exitcode=0)
|
||||
respdata = open(curl.response_file(0)).readlines()
|
||||
assert respdata == [data]
|
||||
|
||||
# upload large data, check that this is what was echoed
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_07_02_upload_1_large(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
if proto == 'h3' and env.curl_uses_lib('msh3'):
|
||||
pytest.skip("msh3 fails here")
|
||||
fdata = os.path.join(env.gen_dir, 'data-100k')
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-0]'
|
||||
r = curl.http_upload(urls=[url], data=f'@{fdata}', alpn_proto=proto)
|
||||
r.check_stats(count=1, http_status=200, exitcode=0)
|
||||
indata = open(fdata).readlines()
|
||||
respdata = open(curl.response_file(0)).readlines()
|
||||
assert respdata == indata
|
||||
|
||||
# upload data sequentially, check that they were echoed
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_07_10_upload_sequential(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
if proto == 'h3' and env.curl_uses_lib('msh3'):
|
||||
pytest.skip("msh3 stalls here")
|
||||
count = 50
|
||||
data = '0123456789'
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-{count-1}]'
|
||||
r = curl.http_upload(urls=[url], data=data, alpn_proto=proto)
|
||||
r.check_stats(count=count, http_status=200, exitcode=0)
|
||||
for i in range(count):
|
||||
respdata = open(curl.response_file(i)).readlines()
|
||||
assert respdata == [data]
|
||||
|
||||
# upload data parallel, check that they were echoed
|
||||
@pytest.mark.parametrize("proto", ['h2', 'h3'])
|
||||
def test_07_11_upload_parallel(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
if proto == 'h3' and env.curl_uses_lib('msh3'):
|
||||
pytest.skip("msh3 stalls here")
|
||||
# limit since we use a separate connection in h1
|
||||
count = 50
|
||||
data = '0123456789'
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-{count-1}]'
|
||||
r = curl.http_upload(urls=[url], data=data, alpn_proto=proto,
|
||||
extra_args=['--parallel'])
|
||||
r.check_stats(count=count, http_status=200, exitcode=0)
|
||||
for i in range(count):
|
||||
respdata = open(curl.response_file(i)).readlines()
|
||||
assert respdata == [data]
|
||||
|
||||
# upload large data sequentially, check that this is what was echoed
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_07_20_upload_seq_large(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
if proto == 'h3' and env.curl_uses_lib('msh3'):
|
||||
pytest.skip("msh3 stalls here")
|
||||
fdata = os.path.join(env.gen_dir, 'data-100k')
|
||||
count = 50
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-{count-1}]'
|
||||
r = curl.http_upload(urls=[url], data=f'@{fdata}', alpn_proto=proto)
|
||||
r.check_response(count=count, http_status=200)
|
||||
indata = open(fdata).readlines()
|
||||
r.check_stats(count=count, http_status=200, exitcode=0)
|
||||
for i in range(count):
|
||||
respdata = open(curl.response_file(i)).readlines()
|
||||
assert respdata == indata
|
||||
|
||||
# upload very large data sequentially, check that this is what was echoed
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_07_12_upload_seq_large(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
if proto == 'h3' and env.curl_uses_lib('msh3'):
|
||||
pytest.skip("msh3 stalls here")
|
||||
fdata = os.path.join(env.gen_dir, 'data-10m')
|
||||
count = 2
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-{count-1}]'
|
||||
r = curl.http_upload(urls=[url], data=f'@{fdata}', alpn_proto=proto)
|
||||
r.check_stats(count=count, http_status=200, exitcode=0)
|
||||
indata = open(fdata).readlines()
|
||||
for i in range(count):
|
||||
respdata = open(curl.response_file(i)).readlines()
|
||||
assert respdata == indata
|
||||
|
||||
# upload data parallel, check that they were echoed
|
||||
@pytest.mark.parametrize("proto", ['h2', 'h3'])
|
||||
def test_07_20_upload_parallel(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
if proto == 'h3' and env.curl_uses_lib('msh3'):
|
||||
pytest.skip("msh3 stalls here")
|
||||
# limit since we use a separate connection in h1
|
||||
count = 50
|
||||
data = '0123456789'
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-{count-1}]'
|
||||
r = curl.http_upload(urls=[url], data=data, alpn_proto=proto,
|
||||
extra_args=['--parallel'])
|
||||
r.check_stats(count=count, http_status=200, exitcode=0)
|
||||
for i in range(count):
|
||||
respdata = open(curl.response_file(i)).readlines()
|
||||
assert respdata == [data]
|
||||
|
||||
# upload large data parallel, check that this is what was echoed
|
||||
@pytest.mark.parametrize("proto", ['h2', 'h3'])
|
||||
def test_07_21_upload_parallel_large(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
if proto == 'h3' and env.curl_uses_lib('msh3'):
|
||||
pytest.skip("msh3 stalls here")
|
||||
fdata = os.path.join(env.gen_dir, 'data-100k')
|
||||
# limit since we use a separate connection in h1
|
||||
count = 50
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-{count-1}]'
|
||||
r = curl.http_upload(urls=[url], data=f'@{fdata}', alpn_proto=proto,
|
||||
extra_args=['--parallel'])
|
||||
r.check_response(count=count, http_status=200)
|
||||
self.check_download(count, fdata, curl)
|
||||
|
||||
# PUT 100k
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_07_30_put_100k(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
if proto == 'h3' and env.curl_uses_lib('msh3'):
|
||||
pytest.skip("msh3 fails here")
|
||||
fdata = os.path.join(env.gen_dir, 'data-100k')
|
||||
count = 1
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/put?id=[0-{count-1}]'
|
||||
r = curl.http_put(urls=[url], fdata=fdata, alpn_proto=proto,
|
||||
extra_args=['--parallel'])
|
||||
r.check_stats(count=count, http_status=200, exitcode=0)
|
||||
exp_data = [f'{os.path.getsize(fdata)}']
|
||||
r.check_response(count=count, http_status=200)
|
||||
for i in range(count):
|
||||
respdata = open(curl.response_file(i)).readlines()
|
||||
assert respdata == exp_data
|
||||
|
||||
# PUT 10m
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_07_31_put_10m(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
if proto == 'h3' and env.curl_uses_lib('msh3'):
|
||||
pytest.skip("msh3 fails here")
|
||||
fdata = os.path.join(env.gen_dir, 'data-10m')
|
||||
count = 1
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/put?id=[0-{count-1}]&chunk_delay=10ms'
|
||||
r = curl.http_put(urls=[url], fdata=fdata, alpn_proto=proto,
|
||||
extra_args=['--parallel'])
|
||||
r.check_stats(count=count, http_status=200, exitcode=0)
|
||||
exp_data = [f'{os.path.getsize(fdata)}']
|
||||
r.check_response(count=count, http_status=200)
|
||||
for i in range(count):
|
||||
respdata = open(curl.response_file(i)).readlines()
|
||||
assert respdata == exp_data
|
||||
|
||||
# issue #10591
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_07_32_issue_10591(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
if proto == 'h3' and env.curl_uses_lib('msh3'):
|
||||
pytest.skip("msh3 fails here")
|
||||
fdata = os.path.join(env.gen_dir, 'data-10m')
|
||||
count = 1
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/put?id=[0-{count-1}]'
|
||||
r = curl.http_put(urls=[url], fdata=fdata, alpn_proto=proto)
|
||||
r.check_stats(count=count, http_status=200, exitcode=0)
|
||||
|
||||
# issue #11157, upload that is 404'ed by server, needs to terminate
|
||||
# correctly and not time out on sending
|
||||
def test_07_33_issue_11157a(self, env: Env, httpd, nghttpx, repeat):
|
||||
proto = 'h2'
|
||||
fdata = os.path.join(env.gen_dir, 'data-10m')
|
||||
# send a POST to our PUT handler which will send immediately a 404 back
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/put'
|
||||
curl = CurlClient(env=env)
|
||||
r = curl.run_direct(with_stats=True, args=[
|
||||
'--resolve', f'{env.authority_for(env.domain1, proto)}:127.0.0.1',
|
||||
'--cacert', env.ca.cert_file,
|
||||
'--request', 'POST',
|
||||
'--max-time', '5', '-v',
|
||||
'--url', url,
|
||||
'--form', 'idList=12345678',
|
||||
'--form', 'pos=top',
|
||||
'--form', 'name=mr_test',
|
||||
'--form', f'fileSource=@{fdata};type=application/pdf',
|
||||
])
|
||||
assert r.exit_code == 0, f'{r}'
|
||||
r.check_stats(1, 404)
|
||||
|
||||
# issue #11157, send upload that is slowly read in
|
||||
def test_07_33_issue_11157b(self, env: Env, httpd, nghttpx, repeat):
|
||||
proto = 'h2'
|
||||
fdata = os.path.join(env.gen_dir, 'data-10m')
|
||||
# tell our test PUT handler to read the upload more slowly, so
|
||||
# that the send buffering and transfer loop needs to wait
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/put?chunk_delay=2ms'
|
||||
curl = CurlClient(env=env)
|
||||
r = curl.run_direct(with_stats=True, args=[
|
||||
'--resolve', f'{env.authority_for(env.domain1, proto)}:127.0.0.1',
|
||||
'--cacert', env.ca.cert_file,
|
||||
'--request', 'PUT',
|
||||
'--max-time', '10', '-v',
|
||||
'--url', url,
|
||||
'--form', 'idList=12345678',
|
||||
'--form', 'pos=top',
|
||||
'--form', 'name=mr_test',
|
||||
'--form', f'fileSource=@{fdata};type=application/pdf',
|
||||
])
|
||||
assert r.exit_code == 0, r.dump_logs()
|
||||
r.check_stats(1, 200)
|
||||
|
||||
def test_07_34_issue_11194(self, env: Env, httpd, nghttpx, repeat):
|
||||
proto = 'h2'
|
||||
fdata = os.path.join(env.gen_dir, 'data-10m')
|
||||
# tell our test PUT handler to read the upload more slowly, so
|
||||
# that the send buffering and transfer loop needs to wait
|
||||
fdata = os.path.join(env.gen_dir, 'data-100k')
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/put'
|
||||
curl = CurlClient(env=env)
|
||||
r = curl.run_direct(with_stats=True, args=[
|
||||
'--verbose',
|
||||
'--resolve', f'{env.authority_for(env.domain1, proto)}:127.0.0.1',
|
||||
'--cacert', env.ca.cert_file,
|
||||
'--request', 'PUT',
|
||||
'--digest', '--user', 'test:test',
|
||||
'--data-binary', f'@{fdata}'
|
||||
'--url', url,
|
||||
])
|
||||
assert r.exit_code == 0, r.dump_logs()
|
||||
r.check_stats(1, 200)
|
||||
|
||||
# upload large data on a h1 to h2 upgrade
|
||||
def test_07_35_h1_h2_upgrade_upload(self, env: Env, httpd, nghttpx, repeat):
|
||||
fdata = os.path.join(env.gen_dir, 'data-100k')
|
||||
curl = CurlClient(env=env)
|
||||
url = f'http://{env.domain1}:{env.http_port}/curltest/echo?id=[0-0]'
|
||||
r = curl.http_upload(urls=[url], data=f'@{fdata}', extra_args=[
|
||||
'--http2'
|
||||
])
|
||||
r.check_response(count=1, http_status=200)
|
||||
# apache does not Upgrade on request with a body
|
||||
assert r.stats[0]['http_version'] == '1.1', f'{r}'
|
||||
indata = open(fdata).readlines()
|
||||
respdata = open(curl.response_file(0)).readlines()
|
||||
assert respdata == indata
|
||||
|
||||
# POST form data, yet another code path in transfer
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_07_40_form_small(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
if proto == 'h3' and env.curl_uses_lib('msh3'):
|
||||
pytest.skip("msh3 fails here")
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-0]'
|
||||
r = curl.http_form(urls=[url], alpn_proto=proto, form={
|
||||
'name1': 'value1',
|
||||
})
|
||||
r.check_stats(count=1, http_status=200, exitcode=0)
|
||||
|
||||
# POST data urlencoded, just as large to be still written together
|
||||
# with the request headers
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_07_41_upload_small(self, env: Env, httpd, nghttpx, repeat, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
if proto == 'h3' and env.curl_uses_lib('msh3'):
|
||||
pytest.skip("msh3 fails here")
|
||||
fdata = os.path.join(env.gen_dir, 'data-63k')
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-0]'
|
||||
r = curl.http_upload(urls=[url], data=f'@{fdata}', alpn_proto=proto)
|
||||
r.check_stats(count=1, http_status=200, exitcode=0)
|
||||
indata = open(fdata).readlines()
|
||||
respdata = open(curl.response_file(0)).readlines()
|
||||
assert respdata == indata
|
||||
|
||||
def check_download(self, count, srcfile, curl):
|
||||
for i in range(count):
|
||||
dfile = curl.download_file(i)
|
||||
assert os.path.exists(dfile)
|
||||
if not filecmp.cmp(srcfile, dfile, shallow=False):
|
||||
diff = "".join(difflib.unified_diff(a=open(srcfile).readlines(),
|
||||
b=open(dfile).readlines(),
|
||||
fromfile=srcfile,
|
||||
tofile=dfile,
|
||||
n=1))
|
||||
assert False, f'download {dfile} differs:\n{diff}'
|
||||
|
|
@ -110,6 +110,7 @@ class TestCaddy:
|
|||
assert r.total_connects == 1, r.dump_logs()
|
||||
|
||||
# download 5MB files sequentially
|
||||
@pytest.mark.skipif(condition=Env.slow_network, reason="not suitable for slow network tests")
|
||||
@pytest.mark.parametrize("proto", ['h2', 'h3'])
|
||||
def test_08_04a_download_10mb_sequential(self, env: Env, caddy: Caddy,
|
||||
repeat, proto):
|
||||
|
|
@ -124,6 +125,7 @@ class TestCaddy:
|
|||
r.check_response(count=count, http_status=200, connect_count=1)
|
||||
|
||||
# download 10MB files sequentially
|
||||
@pytest.mark.skipif(condition=Env.slow_network, reason="not suitable for slow network tests")
|
||||
@pytest.mark.parametrize("proto", ['h2', 'h3'])
|
||||
def test_08_04b_download_10mb_sequential(self, env: Env, caddy: Caddy,
|
||||
repeat, proto):
|
||||
|
|
@ -138,6 +140,7 @@ class TestCaddy:
|
|||
r.check_response(count=count, http_status=200, connect_count=1)
|
||||
|
||||
# download 10MB files parallel
|
||||
@pytest.mark.skipif(condition=Env.slow_network, reason="not suitable for slow network tests")
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_08_05_download_1mb_parallel(self, env: Env, caddy: Caddy,
|
||||
repeat, proto):
|
||||
|
|
|
|||
|
|
@ -139,7 +139,6 @@ class TestProxy:
|
|||
url = f'https://localhost:{env.https_port}/data.json'
|
||||
xargs = curl.get_proxy_args(proxys=False, tunnel=True)
|
||||
r = curl.http_download(urls=[url], alpn_proto=proto, with_stats=True,
|
||||
with_headers=True,
|
||||
extra_args=xargs)
|
||||
r.check_response(count=1, http_status=200,
|
||||
protocol='HTTP/2' if proto == 'h2' else 'HTTP/1.1')
|
||||
|
|
@ -157,7 +156,7 @@ class TestProxy:
|
|||
url = f'https://localhost:{env.https_port}/data.json?[0-0]'
|
||||
xargs = curl.get_proxy_args(tunnel=True, proto=tunnel)
|
||||
r = curl.http_download(urls=[url], alpn_proto=proto, with_stats=True,
|
||||
with_headers=True, extra_args=xargs)
|
||||
extra_args=xargs)
|
||||
r.check_response(count=1, http_status=200,
|
||||
protocol='HTTP/2' if proto == 'h2' else 'HTTP/1.1')
|
||||
assert self.get_tunnel_proto_used(r) == 'HTTP/2' \
|
||||
|
|
@ -185,7 +184,7 @@ class TestProxy:
|
|||
url = f'https://localhost:{env.https_port}/{fname}?[0-{count-1}]'
|
||||
xargs = curl.get_proxy_args(tunnel=True, proto=tunnel)
|
||||
r = curl.http_download(urls=[url], alpn_proto=proto, with_stats=True,
|
||||
with_headers=True, extra_args=xargs)
|
||||
extra_args=xargs)
|
||||
r.check_response(count=count, http_status=200,
|
||||
protocol='HTTP/2' if proto == 'h2' else 'HTTP/1.1')
|
||||
assert self.get_tunnel_proto_used(r) == 'HTTP/2' \
|
||||
|
|
@ -237,7 +236,7 @@ class TestProxy:
|
|||
url2 = f'http://localhost:{env.http_port}/data.json'
|
||||
xargs = curl.get_proxy_args(tunnel=True, proto=tunnel)
|
||||
r = curl.http_download(urls=[url1, url2], alpn_proto='http/1.1', with_stats=True,
|
||||
with_headers=True, extra_args=xargs)
|
||||
extra_args=xargs)
|
||||
r.check_response(count=2, http_status=200)
|
||||
assert self.get_tunnel_proto_used(r) == 'HTTP/2' \
|
||||
if tunnel == 'h2' else 'HTTP/1.1'
|
||||
|
|
|
|||
|
|
@ -131,7 +131,6 @@ class TestProxyAuth:
|
|||
url = f'https://localhost:{env.https_port}/data.json'
|
||||
xargs = curl.get_proxy_args(proxys=True, tunnel=True, proto=tunnel)
|
||||
r = curl.http_download(urls=[url], alpn_proto=proto, with_stats=True,
|
||||
with_headers=True, with_trace=True,
|
||||
extra_args=xargs)
|
||||
# expect "COULD_NOT_CONNECT"
|
||||
r.check_response(exitcode=56, http_status=None)
|
||||
|
|
@ -151,7 +150,6 @@ class TestProxyAuth:
|
|||
xargs = curl.get_proxy_args(proxys=True, tunnel=True, proto=tunnel)
|
||||
xargs.extend(['--proxy-user', 'proxy:proxy'])
|
||||
r = curl.http_download(urls=[url], alpn_proto=proto, with_stats=True,
|
||||
with_headers=True, with_trace=True,
|
||||
extra_args=xargs)
|
||||
r.check_response(count=1, http_status=200,
|
||||
protocol='HTTP/2' if proto == 'h2' else 'HTTP/1.1')
|
||||
|
|
|
|||
|
|
@ -91,7 +91,8 @@ class TestAuth:
|
|||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/restricted/digest/data.json'
|
||||
r = curl.http_upload(urls=[url], data=data, alpn_proto=proto, extra_args=[
|
||||
'--digest', '--user', f'test:{password}'
|
||||
'--digest', '--user', f'test:{password}',
|
||||
'--trace-config', 'http/2,http/3'
|
||||
])
|
||||
# digest does not submit the password, but a hash of it, so all
|
||||
# works and, since the pw is not correct, we get a 401
|
||||
|
|
@ -111,7 +112,8 @@ class TestAuth:
|
|||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/restricted/digest/data.json'
|
||||
r = curl.http_upload(urls=[url], data=f'@{fdata}', alpn_proto=proto, extra_args=[
|
||||
'--basic', '--user', f'test:{password}'
|
||||
'--basic', '--user', f'test:{password}',
|
||||
'--trace-config', 'http/2,http/3'
|
||||
])
|
||||
# but apache denies on length limit
|
||||
r.check_response(http_status=431)
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ class ExecResult:
|
|||
|
||||
def __init__(self, args: List[str], exit_code: int,
|
||||
stdout: List[str], stderr: List[str],
|
||||
trace: Optional[List[str]] = None,
|
||||
duration: Optional[timedelta] = None,
|
||||
with_stats: bool = False,
|
||||
exception: Optional[str] = None):
|
||||
|
|
@ -54,7 +53,6 @@ class ExecResult:
|
|||
self._exception = exception
|
||||
self._stdout = stdout
|
||||
self._stderr = stderr
|
||||
self._trace = trace
|
||||
self._duration = duration if duration is not None else timedelta()
|
||||
self._response = None
|
||||
self._responses = []
|
||||
|
|
@ -113,7 +111,7 @@ class ExecResult:
|
|||
|
||||
@property
|
||||
def trace_lines(self) -> List[str]:
|
||||
return self._trace if self._trace else self._stderr
|
||||
return self._stderr
|
||||
|
||||
@property
|
||||
def duration(self) -> timedelta:
|
||||
|
|
@ -258,12 +256,8 @@ class ExecResult:
|
|||
lines = []
|
||||
lines.append('>>--stdout ----------------------------------------------\n')
|
||||
lines.extend(self._stdout)
|
||||
if self._trace:
|
||||
lines.append('>>--trace ----------------------------------------------\n')
|
||||
lines.extend(self._trace)
|
||||
else:
|
||||
lines.append('>>--stderr ----------------------------------------------\n')
|
||||
lines.extend(self._stderr)
|
||||
lines.append('>>--stderr ----------------------------------------------\n')
|
||||
lines.extend(self._stderr)
|
||||
lines.append('<<-------------------------------------------------------\n')
|
||||
return ''.join(lines)
|
||||
|
||||
|
|
@ -288,7 +282,6 @@ class CurlClient:
|
|||
self._stdoutfile = f'{self._run_dir}/curl.stdout'
|
||||
self._stderrfile = f'{self._run_dir}/curl.stderr'
|
||||
self._headerfile = f'{self._run_dir}/curl.headers'
|
||||
self._tracefile = f'{self._run_dir}/curl.trace'
|
||||
self._log_path = f'{self._run_dir}/curl.log'
|
||||
self._silent = silent
|
||||
self._rmrf(self._run_dir)
|
||||
|
|
@ -301,10 +294,6 @@ class CurlClient:
|
|||
def download_file(self, i: int) -> str:
|
||||
return os.path.join(self.run_dir, f'download_{i}.data')
|
||||
|
||||
@property
|
||||
def trace_file(self) -> str:
|
||||
return self._tracefile
|
||||
|
||||
def _rmf(self, path):
|
||||
if os.path.exists(path):
|
||||
return os.remove(path)
|
||||
|
|
@ -347,7 +336,6 @@ class CurlClient:
|
|||
with_stats: bool = True,
|
||||
with_headers: bool = False,
|
||||
no_save: bool = False,
|
||||
with_trace: bool = False,
|
||||
extra_args: List[str] = None):
|
||||
if extra_args is None:
|
||||
extra_args = []
|
||||
|
|
@ -368,14 +356,12 @@ class CurlClient:
|
|||
])
|
||||
return self._raw(urls, alpn_proto=alpn_proto, options=extra_args,
|
||||
with_stats=with_stats,
|
||||
with_headers=with_headers,
|
||||
with_trace=with_trace)
|
||||
with_headers=with_headers)
|
||||
|
||||
def http_upload(self, urls: List[str], data: str,
|
||||
alpn_proto: Optional[str] = None,
|
||||
with_stats: bool = True,
|
||||
with_headers: bool = False,
|
||||
with_trace: bool = False,
|
||||
extra_args: Optional[List[str]] = None):
|
||||
if extra_args is None:
|
||||
extra_args = []
|
||||
|
|
@ -388,14 +374,12 @@ class CurlClient:
|
|||
])
|
||||
return self._raw(urls, alpn_proto=alpn_proto, options=extra_args,
|
||||
with_stats=with_stats,
|
||||
with_headers=with_headers,
|
||||
with_trace=with_trace)
|
||||
with_headers=with_headers)
|
||||
|
||||
def http_put(self, urls: List[str], data=None, fdata=None,
|
||||
alpn_proto: Optional[str] = None,
|
||||
with_stats: bool = True,
|
||||
with_headers: bool = False,
|
||||
with_trace: bool = False,
|
||||
extra_args: Optional[List[str]] = None):
|
||||
if extra_args is None:
|
||||
extra_args = []
|
||||
|
|
@ -413,8 +397,27 @@ class CurlClient:
|
|||
return self._raw(urls, intext=data,
|
||||
alpn_proto=alpn_proto, options=extra_args,
|
||||
with_stats=with_stats,
|
||||
with_headers=with_headers,
|
||||
with_trace=with_trace)
|
||||
with_headers=with_headers)
|
||||
|
||||
def http_form(self, urls: List[str], form: Dict[str, str],
|
||||
alpn_proto: Optional[str] = None,
|
||||
with_stats: bool = True,
|
||||
with_headers: bool = False,
|
||||
extra_args: Optional[List[str]] = None):
|
||||
if extra_args is None:
|
||||
extra_args = []
|
||||
for key, val in form.items():
|
||||
extra_args.extend(['-F', f'{key}={val}'])
|
||||
extra_args.extend([
|
||||
'-o', 'download_#1.data',
|
||||
])
|
||||
if with_stats:
|
||||
extra_args.extend([
|
||||
'-w', '%{json}\\n'
|
||||
])
|
||||
return self._raw(urls, alpn_proto=alpn_proto, options=extra_args,
|
||||
with_stats=with_stats,
|
||||
with_headers=with_headers)
|
||||
|
||||
def response_file(self, idx: int):
|
||||
return os.path.join(self._run_dir, f'download_{idx}.data')
|
||||
|
|
@ -435,7 +438,6 @@ class CurlClient:
|
|||
self._rmf(self._stdoutfile)
|
||||
self._rmf(self._stderrfile)
|
||||
self._rmf(self._headerfile)
|
||||
self._rmf(self._tracefile)
|
||||
start = datetime.now()
|
||||
exception = None
|
||||
try:
|
||||
|
|
@ -452,11 +454,8 @@ class CurlClient:
|
|||
exception = 'TimeoutExpired'
|
||||
coutput = open(self._stdoutfile).readlines()
|
||||
cerrput = open(self._stderrfile).readlines()
|
||||
ctrace = None
|
||||
if os.path.exists(self._tracefile):
|
||||
ctrace = open(self._tracefile).readlines()
|
||||
return ExecResult(args=args, exit_code=exitcode, exception=exception,
|
||||
stdout=coutput, stderr=cerrput, trace=ctrace,
|
||||
stdout=coutput, stderr=cerrput,
|
||||
duration=datetime.now() - start,
|
||||
with_stats=with_stats)
|
||||
|
||||
|
|
@ -465,13 +464,11 @@ class CurlClient:
|
|||
force_resolve=True,
|
||||
with_stats=False,
|
||||
with_headers=True,
|
||||
with_trace=False,
|
||||
def_tracing=True):
|
||||
args = self._complete_args(
|
||||
urls=urls, timeout=timeout, options=options, insecure=insecure,
|
||||
alpn_proto=alpn_proto, force_resolve=force_resolve,
|
||||
with_headers=with_headers, with_trace=with_trace,
|
||||
def_tracing=def_tracing)
|
||||
with_headers=with_headers, def_tracing=def_tracing)
|
||||
r = self._run(args, intext=intext, with_stats=with_stats)
|
||||
if r.exit_code == 0 and with_headers:
|
||||
self._parse_headerfile(self._headerfile, r=r)
|
||||
|
|
@ -483,24 +480,18 @@ class CurlClient:
|
|||
insecure=False, force_resolve=True,
|
||||
alpn_proto: Optional[str] = None,
|
||||
with_headers: bool = True,
|
||||
with_trace: bool = False,
|
||||
def_tracing: bool = True):
|
||||
if not isinstance(urls, list):
|
||||
urls = [urls]
|
||||
|
||||
args = [self._curl, "-s", "--path-as-is"]
|
||||
if def_tracing:
|
||||
args.extend(['--trace-time', '--trace-ids'])
|
||||
if with_headers:
|
||||
args.extend(["-D", self._headerfile])
|
||||
if with_trace or self.env.verbose > 2:
|
||||
args.extend(['--trace', self._tracefile])
|
||||
elif def_tracing is False:
|
||||
pass
|
||||
elif self.env.verbose > 1:
|
||||
args.extend(['--trace-ascii', self._tracefile])
|
||||
elif not self._silent:
|
||||
args.extend(['-v'])
|
||||
if def_tracing is not False:
|
||||
args.extend(['-v', '--trace-config', 'ids,time'])
|
||||
if self.env.verbose > 1:
|
||||
args.extend(['--trace-config', 'http/2,http/3,h2-proxy,h1-proxy'])
|
||||
pass
|
||||
|
||||
for url in urls:
|
||||
u = urlparse(urls[0])
|
||||
|
|
|
|||
|
|
@ -439,6 +439,11 @@ class Env:
|
|||
def nghttpx(self) -> Optional[str]:
|
||||
return self.CONFIG.nghttpx
|
||||
|
||||
@property
|
||||
def slow_network(self) -> bool:
|
||||
return "CURL_DBG_SOCK_WBLOCK" in os.environ or \
|
||||
"CURL_DBG_SOCK_WPARTIAL" in os.environ
|
||||
|
||||
def authority_for(self, domain: str, alpn_proto: Optional[str] = None):
|
||||
if alpn_proto is None or \
|
||||
alpn_proto in ['h2', 'http/1.1', 'http/1.0', 'http/0.9']:
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class Httpd:
|
|||
'authn_core', 'authn_file',
|
||||
'authz_user', 'authz_core', 'authz_host',
|
||||
'auth_basic', 'auth_digest',
|
||||
'env', 'filter', 'headers', 'mime',
|
||||
'alias', 'env', 'filter', 'headers', 'mime',
|
||||
'socache_shmcb',
|
||||
'rewrite', 'http2', 'ssl', 'proxy', 'proxy_http', 'proxy_connect',
|
||||
'mpm_event',
|
||||
|
|
@ -372,6 +372,10 @@ class Httpd:
|
|||
lines = []
|
||||
if Httpd.MOD_CURLTEST is not None:
|
||||
lines.extend([
|
||||
f' Redirect 301 /curltest/echo301 /curltest/echo',
|
||||
f' Redirect 302 /curltest/echo302 /curltest/echo',
|
||||
f' Redirect 303 /curltest/echo303 /curltest/echo',
|
||||
f' Redirect 307 /curltest/echo307 /curltest/echo',
|
||||
f' <Location /curltest/echo>',
|
||||
f' SetHandler curltest-echo',
|
||||
f' </Location>',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue