Path: blob/main/external/curl/tests/http/test_18_methods.py
2066 views
#!/usr/bin/env python31# -*- coding: utf-8 -*-2#***************************************************************************3# _ _ ____ _4# Project ___| | | | _ \| |5# / __| | | | |_) | |6# | (__| |_| | _ <| |___7# \___|\___/|_| \_\_____|8#9# Copyright (C) Daniel Stenberg, <[email protected]>, et al.10#11# This software is licensed as described in the file COPYING, which12# you should have received as part of this distribution. The terms13# are also available at https://curl.se/docs/copyright.html.14#15# You may opt to use, copy, modify, merge, publish, distribute and/or sell16# copies of the Software, and permit persons to whom the Software is17# furnished to do so, under the terms of the COPYING file.18#19# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY20# KIND, either express or implied.21#22# SPDX-License-Identifier: curl23#24###########################################################################25#26import logging27import pytest2829from testenv import Env, CurlClient303132log = logging.getLogger(__name__)333435class TestMethods:3637@pytest.fixture(autouse=True, scope='class')38def _class_scope(self, env, httpd, nghttpx):39indir = httpd.docs_dir40env.make_data_file(indir=indir, fname="data-10k", fsize=10*1024)41env.make_data_file(indir=indir, fname="data-100k", fsize=100*1024)42env.make_data_file(indir=indir, fname="data-1m", fsize=1024*1024)4344# download 1 file45@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])46def test_18_01_delete(self, env: Env, httpd, nghttpx, proto):47if proto == 'h3' and not env.have_h3():48pytest.skip("h3 not supported")49count = 150curl = CurlClient(env=env)51url = f'https://{env.authority_for(env.domain1, proto)}/curltest/tweak?id=[0-{count-1}]'52r = curl.http_delete(urls=[url], alpn_proto=proto)53r.check_stats(count=count, http_status=204, exitcode=0)5455# make HTTP/2 in the server send56# - HEADER frame with 204 and eos=057# - 10ms later DATA frame length=0 and eos=158# should be accepted59def test_18_02_delete_h2_special(self, env: Env, httpd, nghttpx):60proto = 'h2'61count = 162curl = CurlClient(env=env)63url = f'https://{env.authority_for(env.domain1, proto)}/curltest/tweak?id=[0-{count-1}]'\64'&chunks=1&chunk_size=0&chunk_delay=10ms'65r = curl.http_delete(urls=[url], alpn_proto=proto)66r.check_stats(count=count, http_status=204, exitcode=0)676869