2
0

test_18_methods.py 2.7 KB

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