@@ -153,9 +153,12 @@ public Task BadRequestIfHostHeaderDoesNotMatchRequestTarget(string requestTarget
153153    } 
154154
155155    [ Theory ] 
156-     [ InlineData ( "Host: www.foo.comConnection: keep-alive" ) ]  // Corrupted - missing line-break 
157-     [ InlineData ( "Host: www.notfoo.com" ) ]  // Syntactically correct but not matching 
158-     public  async  Task  CanOptOutOfBadRequestIfHostHeaderDoesNotMatchRequestTarget ( string  hostHeader ) 
156+     [ InlineData ( "http://www.foo.com" ,  "Host: www.foo.comConnection: keep-alive" ,  "www.foo.com" ) ]  // Corrupted - missing line-break 
157+     [ InlineData ( "http://www.foo.com/" ,  "Host: www.notfoo.com" ,  "www.foo.com" ) ]  // Syntactically correct but not matching 
158+     [ InlineData ( "http://www.foo.com:80" ,  "Host: www.notfoo.com" ,  "www.foo.com" ) ]  // Explicit default port in request string 
159+     [ InlineData ( "http://www.foo.com:5129" ,  "Host: www.foo.com" ,  "www.foo.com:5129" ) ]  // Non-default port in request string 
160+     [ InlineData ( "http://www.foo.com:5129" ,  "Host: www.foo.com:5128" ,  "www.foo.com:5129" ) ]  // Different port in host header 
161+     public  async  Task  CanOptOutOfBadRequestIfHostHeaderDoesNotMatchRequestTarget ( string  requestString ,  string  hostHeader ,  string  expectedHost ) 
159162    { 
160163        var  testMeterFactory  =  new  TestMeterFactory ( ) ; 
161164        using  var  connectionDuration  =  new  MetricCollector < double > ( testMeterFactory ,  "Microsoft.AspNetCore.Server.Kestrel" ,  "kestrel.connection.duration" ) ; 
@@ -175,13 +178,13 @@ public async Task CanOptOutOfBadRequestIfHostHeaderDoesNotMatchRequestTarget(str
175178        { 
176179            using  ( var  client  =  server . CreateConnection ( ) ) 
177180            { 
178-                 await  client . SendAll ( $ "GET http://www.foo.com/api/data  HTTP/1.1\r \n { hostHeader } \r \n \r \n ") ; 
181+                 await  client . SendAll ( $ "GET { requestString }  HTTP/1.1\r \n { hostHeader } \r \n \r \n ") ; 
179182
180183                await  client . Receive ( "HTTP/1.1 200 OK" ) ; 
181184            } 
182185        } 
183186
184-         Assert . Equal ( "www.foo.com:80" ,  receivedHost ) ; 
187+         Assert . Equal ( expectedHost ,  receivedHost ) ; 
185188
186189        Assert . Collection ( connectionDuration . GetMeasurementSnapshot ( ) ,  m =>  MetricsAssert . NoError ( m . Tags ) ) ; 
187190    } 
0 commit comments