1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3#*************************************************************************** 4# _ _ ____ _ 5# Project ___| | | | _ \| | 6# / __| | | | |_) | | 7# | (__| |_| | _ <| |___ 8# \___|\___/|_| \_\_____| 9# 10# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, 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# 27import logging 28import pytest 29 30from testenv import Env, CurlClient 31 32 33log = logging.getLogger(__name__) 34 35 36class TestMethods: 37 38 @pytest.fixture(autouse=True, scope='class') 39 def _class_scope(self, env, httpd, nghttpx): 40 if env.have_h3(): 41 nghttpx.start_if_needed() 42 httpd.clear_extra_configs() 43 httpd.reload_if_config_changed() 44 indir = httpd.docs_dir 45 env.make_data_file(indir=indir, fname="data-10k", fsize=10*1024) 46 env.make_data_file(indir=indir, fname="data-100k", fsize=100*1024) 47 env.make_data_file(indir=indir, fname="data-1m", fsize=1024*1024) 48 49 # download 1 file 50 @pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3']) 51 def test_18_01_delete(self, env: Env, httpd, nghttpx, repeat, proto): 52 if proto == 'h3' and not env.have_h3(): 53 pytest.skip("h3 not supported") 54 count = 1 55 curl = CurlClient(env=env) 56 url = f'https://{env.authority_for(env.domain1, proto)}/curltest/tweak?id=[0-{count-1}]' 57 r = curl.http_delete(urls=[url], alpn_proto=proto) 58 r.check_stats(count=count, http_status=204, exitcode=0) 59 60 # make HTTP/2 in the server send 61 # - HEADER frame with 204 and eos=0 62 # - 10ms later DATA frame length=0 and eos=1 63 # should be accepted 64 def test_18_02_delete_h2_special(self, env: Env, httpd, nghttpx, repeat): 65 proto = 'h2' 66 count = 1 67 curl = CurlClient(env=env) 68 url = f'https://{env.authority_for(env.domain1, proto)}/curltest/tweak?id=[0-{count-1}]'\ 69 '&chunks=1&chunk_size=0&chunk_delay=10ms' 70 r = curl.http_delete(urls=[url], alpn_proto=proto) 71 r.check_stats(count=count, http_status=204, exitcode=0) 72