Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/pkg
Path: blob/main/external/curl/tests/http/test_18_methods.py
2066 views
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
#***************************************************************************
4
# _ _ ____ _
5
# Project ___| | | | _ \| |
6
# / __| | | | |_) | |
7
# | (__| |_| | _ <| |___
8
# \___|\___/|_| \_\_____|
9
#
10
# Copyright (C) Daniel Stenberg, <[email protected]>, et al.
11
#
12
# This software is licensed as described in the file COPYING, which
13
# you should have received as part of this distribution. The terms
14
# are also available at https://curl.se/docs/copyright.html.
15
#
16
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
17
# copies of the Software, and permit persons to whom the Software is
18
# furnished to do so, under the terms of the COPYING file.
19
#
20
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21
# KIND, either express or implied.
22
#
23
# SPDX-License-Identifier: curl
24
#
25
###########################################################################
26
#
27
import logging
28
import pytest
29
30
from testenv import Env, CurlClient
31
32
33
log = logging.getLogger(__name__)
34
35
36
class TestMethods:
37
38
@pytest.fixture(autouse=True, scope='class')
39
def _class_scope(self, env, httpd, nghttpx):
40
indir = httpd.docs_dir
41
env.make_data_file(indir=indir, fname="data-10k", fsize=10*1024)
42
env.make_data_file(indir=indir, fname="data-100k", fsize=100*1024)
43
env.make_data_file(indir=indir, fname="data-1m", fsize=1024*1024)
44
45
# download 1 file
46
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
47
def test_18_01_delete(self, env: Env, httpd, nghttpx, proto):
48
if proto == 'h3' and not env.have_h3():
49
pytest.skip("h3 not supported")
50
count = 1
51
curl = CurlClient(env=env)
52
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/tweak?id=[0-{count-1}]'
53
r = curl.http_delete(urls=[url], alpn_proto=proto)
54
r.check_stats(count=count, http_status=204, exitcode=0)
55
56
# make HTTP/2 in the server send
57
# - HEADER frame with 204 and eos=0
58
# - 10ms later DATA frame length=0 and eos=1
59
# should be accepted
60
def test_18_02_delete_h2_special(self, env: Env, httpd, nghttpx):
61
proto = 'h2'
62
count = 1
63
curl = CurlClient(env=env)
64
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/tweak?id=[0-{count-1}]'\
65
'&chunks=1&chunk_size=0&chunk_delay=10ms'
66
r = curl.http_delete(urls=[url], alpn_proto=proto)
67
r.check_stats(count=count, http_status=204, exitcode=0)
68
69