forked from benoitc/gunicorn
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
check if the header contains control characters
fix benoitc#1227 (cherry picked from commit 1e10a02)
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- encoding: utf-8 -*- | ||
|
||
import pytest | ||
from gunicorn.http.wsgi import Response | ||
from gunicorn.six import BytesIO | ||
from gunicorn.http.errors import InvalidHeader, InvalidHeaderName | ||
|
||
try: | ||
import unittest.mock as mock | ||
except ImportError: | ||
import mock | ||
|
||
|
||
def test_http_inalid_response_header(): | ||
""" tests whether http response headers are contains control chars """ | ||
|
||
mocked_socket = mock.MagicMock() | ||
mocked_socket.sendall = mock.MagicMock() | ||
|
||
mocked_request = mock.MagicMock() | ||
response = Response(mocked_request, mocked_socket) | ||
|
||
with pytest.raises(InvalidHeader): | ||
response.start_response("200 OK", [('foo', 'essai\r\n')]) | ||
|
||
response = Response(mocked_request, mocked_socket) | ||
with pytest.raises(InvalidHeaderName): | ||
response.start_response("200 OK", [('foo\r\n', 'essai')]) |