@@ -459,6 +459,11 @@ class HTTPServerRequest:
459459
460460 .. versionchanged:: 4.0
461461 Moved from ``tornado.httpserver.HTTPRequest``.
462+
463+ .. deprecated:: 6.5.2
464+ The ``host`` argument to the ``HTTPServerRequest`` constructor is deprecated. Use
465+ ``headers["Host"]`` instead. This argument was mistakenly removed in Tornado 6.5.0 and
466+ temporarily restored in 6.5.2.
462467 """
463468
464469 path = None # type: str
@@ -474,7 +479,7 @@ def __init__(
474479 version : str = "HTTP/1.0" ,
475480 headers : Optional [HTTPHeaders ] = None ,
476481 body : Optional [bytes ] = None ,
477- # host: Optional[str] = None,
482+ host : Optional [str ] = None ,
478483 files : Optional [Dict [str , List ["HTTPFile" ]]] = None ,
479484 connection : Optional ["HTTPConnection" ] = None ,
480485 start_line : Optional ["RequestStartLine" ] = None ,
@@ -494,15 +499,14 @@ def __init__(
494499 self .protocol = getattr (context , "protocol" , "http" )
495500
496501 try :
497- self .host = self .headers ["Host" ]
502+ self .host = host or self .headers ["Host" ]
498503 except KeyError :
499504 if version == "HTTP/1.0" :
500505 # HTTP/1.0 does not require the Host header.
501506 self .host = "127.0.0.1"
502507 else :
503508 raise HTTPInputError ("Missing Host header" )
504509 if not _ABNF .host .fullmatch (self .host ):
505- print (_ABNF .host .pattern )
506510 raise HTTPInputError ("Invalid Host header: %r" % self .host )
507511 if "," in self .host :
508512 # https://www.rfc-editor.org/rfc/rfc9112.html#name-request-target
0 commit comments