test_18_methods.py 2.9 KB

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