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 difflib 28import filecmp 29import logging 30import os 31from datetime import timedelta 32import pytest 33 34from testenv import Env, CurlClient, LocalClient 35 36 37log = logging.getLogger(__name__) 38 39 40class TestMethods: 41 42 @pytest.fixture(autouse=True, scope='class') 43 def _class_scope(self, env, httpd, nghttpx): 44 if env.have_h3(): 45 nghttpx.start_if_needed() 46 httpd.clear_extra_configs() 47 httpd.reload() 48 49 @pytest.fixture(autouse=True, scope='class') 50 def _class_scope(self, env, httpd): 51 indir = httpd.docs_dir 52 env.make_data_file(indir=indir, fname="data-10k", fsize=10*1024) 53 env.make_data_file(indir=indir, fname="data-100k", fsize=100*1024) 54 env.make_data_file(indir=indir, fname="data-1m", fsize=1024*1024) 55 56 # download 1 file 57 @pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3']) 58 def test_18_01_delete(self, env: Env, httpd, nghttpx, repeat, proto): 59 if proto == 'h3' and not env.have_h3(): 60 pytest.skip("h3 not supported") 61 count = 1 62 curl = CurlClient(env=env) 63 url = f'https://{env.authority_for(env.domain1, proto)}/curltest/tweak?id=[0-{count-1}]' 64 r = curl.http_delete(urls=[url], alpn_proto=proto) 65 r.check_stats(count=count, http_status=204, exitcode=0) 66 67 # make HTTP/2 in the server send 68 # - HEADER frame with 204 and eos=0 69 # - 10ms later DATA frame length=0 and eos=1 70 # should be accepted 71 def test_18_02_delete_h2_special(self, env: Env, httpd, nghttpx, repeat): 72 proto = 'h2' 73 count = 1 74 curl = CurlClient(env=env) 75 url = f'https://{env.authority_for(env.domain1, proto)}/curltest/tweak?id=[0-{count-1}]'\ 76 '&chunks=1&chunk_size=0&chunk_delay=10ms' 77 r = curl.http_delete(urls=[url], alpn_proto=proto) 78 r.check_stats(count=count, http_status=204, exitcode=0) 79 80