Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit 10793db

Browse files
committed
Review feedback 2
1 parent 98fd274 commit 10793db

File tree

2 files changed

+19
-24
lines changed

2 files changed

+19
-24
lines changed

src/Microsoft.AspNet.Server.Kestrel/Http/Frame.cs

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -116,24 +116,19 @@ public void Reset()
116116
DuplexStream = null;
117117

118118
var httpConnectionFeature = this as IHttpConnectionFeature;
119-
if (httpConnectionFeature != null)
120-
{
121-
if (_remoteEndPoint != null)
122-
{
123-
httpConnectionFeature.RemoteIpAddress = _remoteEndPoint.Address;
124-
httpConnectionFeature.RemotePort = _remoteEndPoint.Port;
125-
}
119+
httpConnectionFeature.RemoteIpAddress = _remoteEndPoint?.Address;
120+
httpConnectionFeature.RemotePort = _remoteEndPoint?.Port ?? 0;
126121

127-
if (_localEndPoint != null)
128-
{
129-
httpConnectionFeature.LocalIpAddress = _localEndPoint.Address;
130-
httpConnectionFeature.LocalPort = _localEndPoint.Port;
131-
}
122+
httpConnectionFeature.LocalIpAddress = _localEndPoint?.Address;
123+
httpConnectionFeature.LocalPort = _localEndPoint?.Port ?? 0;
132124

133-
if (_remoteEndPoint != null && _localEndPoint != null)
134-
{
135-
httpConnectionFeature.IsLocal = _remoteEndPoint.Address.Equals(_localEndPoint.Address);
136-
}
125+
if (_remoteEndPoint != null && _localEndPoint != null)
126+
{
127+
httpConnectionFeature.IsLocal = _remoteEndPoint.Address.Equals(_localEndPoint.Address);
128+
}
129+
else
130+
{
131+
httpConnectionFeature.IsLocal = false;
137132
}
138133
}
139134

@@ -159,7 +154,7 @@ public void Start()
159154
/// <summary>
160155
/// Should be called when the server wants to initiate a shutdown. The Task returned will
161156
/// become complete when the RequestProcessingAsync function has exited. It is expected that
162-
/// Stop will be called on all active connections, and Task.WaitAll() will be called on every
157+
/// Stop will be called on all active connections, and Task.WaitAll() will be called on every
163158
/// return value.
164159
/// </summary>
165160
public Task Stop()
@@ -172,7 +167,7 @@ public Task Stop()
172167
}
173168

174169
/// <summary>
175-
/// Primary loop which consumes socket input, parses it for protocol framing, and invokes the
170+
/// Primary loop which consumes socket input, parses it for protocol framing, and invokes the
176171
/// application delegate for as long as the socket is intended to remain open.
177172
/// The resulting Task from this loop is preserved in a field which is used when the server needs
178173
/// to drain and close all currently active connections.
@@ -767,7 +762,7 @@ public static bool TakeMessageHeaders(SocketInput input, FrameRequestHeaders req
767762

768763
if (chSecond != '\n')
769764
{
770-
// "\r" was all by itself, move just after it and try again
765+
// "\r" was all by itself, move just after it and try again
771766
scan = endValue;
772767
scan.Take();
773768
continue;
@@ -776,7 +771,7 @@ public static bool TakeMessageHeaders(SocketInput input, FrameRequestHeaders req
776771
var chThird = scan.Peek();
777772
if (chThird == ' ' || chThird == '\t')
778773
{
779-
// special case, "\r\n " or "\r\n\t".
774+
// special case, "\r\n " or "\r\n\t".
780775
// this is considered wrapping"linear whitespace" and is actually part of the header value
781776
// continue past this for the next
782777
wrapping = true;

src/Microsoft.AspNet.Server.Kestrel/Networking/SockAddr.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ public IPEndPoint GetIPEndPoint()
3434
// 0000 0000 0000 0000
3535
//
3636
// Example 2: 10.135.34.141:39178 when adopt dual-stack sockets, IPv4 is mapped to IPv6
37-
//
37+
//
3838
// 0000 0000 0a99 0017 => The port representation are the same
3939
// 0000 0000 0000 0000
40-
// 8d22 870a ffff 0000 => IPv4 occupies the last 32 bit: 0A.87.22.8d is the actual address.
40+
// 8d22 870a ffff 0000 => IPv4 occupies the last 32 bit: 0A.87.22.8d is the actual address.
4141
// 0000 0000 0000 0000
42-
//
42+
//
4343
// Example 3: 10.135.34.141:12804, not dual-stack sockets
4444
// 8d22 870a fd31 0002 => sa_family == AF_INET (02)
4545
// 0000 0000 0000 0000
@@ -81,7 +81,7 @@ public IPEndPoint GetIPEndPoint()
8181

8282
private bool IsIPv4MappedToIPv6()
8383
{
84-
// If the IPAddress is an IPv4 mapped to IPv6, returns the IPv4 representation instead.
84+
// If the IPAddress is an IPv4 mapped to IPv6, return the IPv4 representation instead.
8585
// For example [::FFFF:127.0.0.1] will be transform to IPAddress of 127.0.0.1
8686
if (_field1 != 0)
8787
{

0 commit comments

Comments
 (0)