Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Client-sent Host header can include port as "None" #4039
Long story short
When the client forms the Host header, it is possible for it to include the port as "None".
This came up for me when using
At least, not to send "None" as a port number for the Host header.
According to RFC 7230 Section 5.4:
So perhaps it should be possible for the
At the moment though, I think, it doesn't seem possible to send such an "authority"-less URL to
The Host header includes the string "None" as the port when making requests whose URL registers as not
Steps to reproduce
This occurred for me while using the
A sort of silly example server/client that displays the behavior is as follows:
from aiohttp import web from asyncio import sleep, create_task import aiohttp SOCK_PATH = '/tmp/example.sock' async def hello(request): print('Host: '+request.headers['Host']) return web.Response() async def make_request(): await sleep(1) # Let the server become available. conn = aiohttp.UnixConnector(path=SOCK_PATH) async with aiohttp.ClientSession(connector=conn) as session: async with session.get('unix://localhost/'): pass # Produces a Host of "localhost:None" async with session.get('http://localhost/'): pass # Produces a Host of "localhost" async def schedule_request(_): create_task(make_request()) app = web.Application() app.add_routes([web.get('/', hello)]) app.on_startup.append(schedule_request) web.run_app(app, path=SOCK_PATH)
BTW the specific thing that I think make this appear where it didn't before was a security update to Go that make URL parsing more strict: https://github.com/golang/go/issues?q=milestone%3AGo1.12.8