diff --git a/doc/documentation.rst b/doc/documentation.rst index e4b2bac..4568d51 100644 --- a/doc/documentation.rst +++ b/doc/documentation.rst @@ -249,7 +249,7 @@ parameters or as constructor argument. return NotModifiedResponse(date=time_to_http()) return FileResponse(req.document_root+"/filename", - headers={'E-Tag': etag}) + headers={'ETag': etag}) Partial Content ``````````````` diff --git a/examples/simple.py b/examples/simple.py index 84109c7..6b0830d 100644 --- a/examples/simple.py +++ b/examples/simple.py @@ -269,7 +269,7 @@ def style(_): @app.route('/test/static') def test_dynamic(req, variable=None): """Test dynamics values.""" - if not variable and req.headers.get('E-Tag') == 'W/"0123"': + if not variable and req.headers.get('ETag') == 'W/"0123"': return not_modified(req) var_info = { @@ -299,7 +299,7 @@ def test_dynamic(req, variable=None): ("",) + \ get_footer() - response = Response(headers={'E-Tag': 'W/"0123"'}) + response = Response(headers={'ETag': 'W/"0123"'}) for line in buff: response.write(line + '\n') return response @@ -640,7 +640,7 @@ def simple_py(req): if last_modified <= if_modified: return NotModifiedResponse(date=time_to_http()) - response = FileResponse(__file__, headers={'E-Tag': etag}) + response = FileResponse(__file__, headers={'ETag': etag}) ranges = {} if 'Range' in req.headers: ranges = parse_range(req.headers['Range']) diff --git a/poorwsgi/response.py b/poorwsgi/response.py index 1443649..9821696 100644 --- a/poorwsgi/response.py +++ b/poorwsgi/response.py @@ -741,7 +741,7 @@ def __init__(self, super().__init__(status_code=HTTP_NOT_MODIFIED, headers=headers) if etag: - self.add_header('E-Tag', etag) + self.add_header('ETag', etag) if content_location: self.add_header('Content-Location', content_location) if isinstance(date, str) and date: diff --git a/poorwsgi/results.py b/poorwsgi/results.py index 974d146..cfecdbc 100644 --- a/poorwsgi/results.py +++ b/poorwsgi/results.py @@ -88,11 +88,11 @@ def handlers_view(handlers, sort=True): def not_modified(req): """Return NotModifiedResponse. - Headers E-Tag, Content-Location is return from request. + Headers ETag, Content-Location is return from request. Date header will be set. """ return NotModifiedResponse( - etag=req.headers.get('E-Tag'), + etag=req.headers.get('ETag'), content_location=req.headers.get('Content-Location'), date=time_to_http()) diff --git a/tests/test_responses.py b/tests/test_responses.py index ba24ae8..eab32cf 100644 --- a/tests/test_responses.py +++ b/tests/test_responses.py @@ -550,7 +550,7 @@ def test_params(self): content_location="content-location", date="22 Apr 2022", vary="yrav") - assert res.headers.get('E-Tag') == 'W/"etag"' + assert res.headers.get('ETag') == 'W/"etag"' assert res.headers.get('Content-Location') == "content-location" assert res.headers.get('Date') == "22 Apr 2022" assert res.headers.get('Vary') == "yrav" diff --git a/tests_integrity/support.py b/tests_integrity/support.py index 8881cf5..b63071a 100644 --- a/tests_integrity/support.py +++ b/tests_integrity/support.py @@ -19,7 +19,7 @@ class TestError(RuntimeError): """Support exception.""" -def start_server(request, example, env=None): +def start_server(request, example, env=None, close=True): """Start web server with example.""" process = None @@ -27,10 +27,12 @@ def start_server(request, example, env=None): if request.config.getoption("--with-uwsgi"): env = env or {} env = [["--env", "=".join(items)] for items in env.items()] - env = list(chain.from_iterable(env)) + params = list(chain.from_iterable(env)) + if close: + params += ["--add-header", "Connection: Close"] process = Popen(["uwsgi", "--plugin", "python3", - "--http-socket", "localhost:8080", "--wsgi-file", - example] + env) + "--http-socket", "localhost:8080", + "--wsgi-file", example] + params) else: # pylint: disable=consider-using-with process = Popen([executable, example], env=env) diff --git a/tests_integrity/test_simple.py b/tests_integrity/test_simple.py index 4650bcc..ae2ab9a 100644 --- a/tests_integrity/test_simple.py +++ b/tests_integrity/test_simple.py @@ -53,7 +53,7 @@ def test_static(self, url): def test_static_not_modified(self, url): res = check_url(url+"/test/static") check_url(url+"/test/static", status_code=304, - headers={'E-Tag': res.headers.get('E-Tag')}) + headers={'ETag': res.headers.get('ETag')}) def test_variable_int(self, url): check_url(url+"/test/123") @@ -116,7 +116,7 @@ def test_file_response_304_last_modified(self, url): def test_file_response_304_etag(self, url): res = check_url(url+"/simple.py") - etag = res.headers.get('E-Tag') + etag = res.headers.get('ETag') res = check_url(url+"/simple.py", headers={'If-None-Match': etag}, status_code=304) diff --git a/tests_integrity/test_websocket.py b/tests_integrity/test_websocket.py index 101afff..99bf8cb 100644 --- a/tests_integrity/test_websocket.py +++ b/tests_integrity/test_websocket.py @@ -24,7 +24,8 @@ def server(request): process = start_server( request, - join(dirname(__file__), pardir, 'examples/websocket.py')) + join(dirname(__file__), pardir, 'examples/websocket.py'), + close=False) yield "localhost:8080" # server is running process.kill()