Skip to content

Commit

Permalink
Merge pull request #20 from lorien/issue_19_utf_headers
Browse files Browse the repository at this point in the history
Issue 19 utf headers
  • Loading branch information
lorien committed May 5, 2018
2 parents 20ebe12 + aaf9aac commit e46b5f4
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.0.30
current_version = 0.0.31
files = setup.py test_server/__init__.py docs/conf.py
commit = True
tag = True
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Expand Up @@ -60,9 +60,9 @@
# built documents.
#
# The short X.Y version.
version = u'.'.join(u'0.0.30'.split('.')[:2])
version = u'.'.join(u'0.0.31'.split('.')[:2])
# The full version, including alpha/beta/rc tags.
release = u'0.0.30'
release = u'0.0.31'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -10,7 +10,7 @@
setup(
# Meta data
name='test-server',
version='0.0.30',
version='0.0.31',
author='Gregory Petukhov',
author_email='lorien@lorien.name',
maintainer="Gregory Petukhov",
Expand Down
25 changes: 25 additions & 0 deletions test/server.py
Expand Up @@ -5,6 +5,7 @@
# pylint: disable=redefined-outer-name
from threading import Thread
import time
#import socket
from six.moves.urllib.error import HTTPError, URLError
from six.moves.urllib.request import urlopen, Request
from six.moves.urllib.parse import unquote
Expand Down Expand Up @@ -275,3 +276,27 @@ def test_null_bytes(server):
res = urlopen(server.get_url())
assert res.read() == b'zzz'
assert unquote(server.request['path']) == '/\x00/'


#def send_get_request(host, port, path):
# sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# sock.connect((host, port))
# data = (
# b'GET %s HTTP/1.1\r\n'
# b'Host: %s\r\n'
# b'\r\n'
# #% (quote(path, safe='/').encode('utf-8'), host.encode('utf-8'))
# % (path, host.encode('utf-8'))
# )
# print(data)
# sock.send(data)
# data = sock.recv(1024 * 10)
# sock.close()
# return data


def test_utf_header(server):
server.response['headers'] = [
('Location', (server.get_url() + u'фыва').encode('utf-8'))
]
urlopen(server.get_url())
2 changes: 1 addition & 1 deletion test_server/__init__.py
@@ -1,4 +1,4 @@
from test_server.server import * # noqa pylint: disable=wildcard-import
from test_server.error import * # noqa pylint: disable=wildcard-import

__version__ = '0.0.30'
__version__ = '0.0.31'
6 changes: 6 additions & 0 deletions test_server/server.py
Expand Up @@ -10,13 +10,19 @@

import six
from webtest.http import StopableWSGIServer
from waitress import task
import bottle

from test_server.error import TestServerError

__all__ = ('TestServer', 'WaitTimeoutError')
logger = logging.getLogger('test_server.server') # pylint: disable=invalid-name

if six.PY3:
# Original (from waitress.compat.tobytes):
# def tobytes(s):
# return bytes(s, 'latin-1')
task.tobytes = lambda x: bytes(x, 'utf-8')


def _hval_custom(value):
Expand Down

0 comments on commit e46b5f4

Please sign in to comment.