Skip to content

Commit ef91318

Browse files
authored
reverting HostAndPort property
1 parent 7ea8a11 commit ef91318

File tree

3 files changed

+8
-23
lines changed

3 files changed

+8
-23
lines changed

src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,8 @@ private void RecordRequestStartMetrics(HttpContext httpContext)
392392
var tagsForCreation = new TagList();
393393
if (_activitySource.HasListeners() && httpContext.Request.Host.HasValue)
394394
{
395-
var (host, port) = httpContext.Request.Host.HostAndPort;
395+
var host = httpContext.Request.Host.Host;
396+
var port = httpContext.Request.Host.Port;
396397
tags.Add("server.address", host);
397398
if (port is not null)
398399
{

src/Http/Http.Abstractions/src/HostString.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,22 +118,6 @@ public int? Port
118118
}
119119
}
120120

121-
internal (string host, int? port) HostAndPort
122-
{
123-
get
124-
{
125-
GetParts(_value, out var host, out var port);
126-
127-
if (!StringSegment.IsNullOrEmpty(port)
128-
&& int.TryParse(port.AsSpan(), NumberStyles.None, CultureInfo.InvariantCulture, out var p))
129-
{
130-
return (host.ToString(), p);
131-
}
132-
133-
return (host.ToString(), null);
134-
}
135-
}
136-
137121
/// <summary>
138122
/// Returns the value as normalized by ToUriComponent().
139123
/// </summary>

src/Http/Routing/src/Matching/HostMatcherPolicy.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,22 +332,22 @@ private static int GetScore(in EdgeKey key)
332332

333333
private static (string host, int? port) GetHostAndPort(HttpContext httpContext)
334334
{
335-
var (host, port) = httpContext.Request.Host.HostAndPort;
336-
if (port != null)
335+
var hostString = httpContext.Request.Host;
336+
if (hostString.Port != null)
337337
{
338-
return (host, port);
338+
return (hostString.Host, hostString.Port);
339339
}
340340
else if (string.Equals("https", httpContext.Request.Scheme, StringComparison.OrdinalIgnoreCase))
341341
{
342-
return (host, 443);
342+
return (hostString.Host, 443);
343343
}
344344
else if (string.Equals("http", httpContext.Request.Scheme, StringComparison.OrdinalIgnoreCase))
345345
{
346-
return (host, 80);
346+
return (hostString.Host, 80);
347347
}
348348
else
349349
{
350-
return (host, null);
350+
return (hostString.Host, null);
351351
}
352352
}
353353

0 commit comments

Comments
 (0)