squeaky-pl / japronto

Screaming-fast Python 3.5+ HTTP toolkit integrated with pipelining HTTP server based on uvloop and picohttpparser.
MIT License
8.61k stars 581 forks source link

request.hostname fails when bound to port 80 #69

Open J-N opened 7 years ago

J-N commented 7 years ago

Most browsers will not set hostname port header if they are connecting on the standard port 80. This breaks request.hostname.

Traceback (most recent call last):
  File "./test.py", line 215, in hello
    url = request.hostname+request.path
  File "/usr/local/lib/python3.6/site-packages/japronto/request/__init__.py", line 128, in hostname
    return hostname_and_port(request)[0]
  File "/usr/local/lib/python3.6/site-packages/japronto/request/__init__.py", line 39, in wrapper
    result = func(request)
  File "/usr/local/lib/python3.6/site-packages/japronto/request/__init__.py", line 120, in hostname_and_port
    return encodings.idna.ToUnicode(hostname), int(port)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'