Removed ifdefs around RemoteIP and ClientCerts.

This commit is contained in:
David Fowler 2014-04-19 16:40:58 -07:00
parent f8b1679240
commit 93aa23b6ab
5 changed files with 15 additions and 45 deletions

View File

@ -19,9 +19,6 @@
<ItemGroup> <ItemGroup>
<Content Include="Project.json" /> <Content Include="Project.json" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
</ItemGroup> </ItemGroup>

View File

@ -170,7 +170,7 @@ namespace Microsoft.AspNet.Server.WebListener
} }
return _hash; return _hash;
} }
#if NET45
internal IPAddress GetIPAddress() internal IPAddress GetIPAddress()
{ {
if (Family == AddressFamily.InterNetworkV6) if (Family == AddressFamily.InterNetworkV6)
@ -200,7 +200,7 @@ namespace Microsoft.AspNet.Server.WebListener
Contract.Assert(Size >= IPv4AddressSize); Contract.Assert(Size >= IPv4AddressSize);
return new IPAddress(new byte[] { _buffer[4], _buffer[5], _buffer[6], _buffer[7] }); return new IPAddress(new byte[] { _buffer[4], _buffer[5], _buffer[6], _buffer[7] });
} }
#endif
public override string ToString() public override string ToString()
{ {
StringBuilder bytes = new StringBuilder(); StringBuilder bytes = new StringBuilder();

View File

@ -4,8 +4,6 @@
// </copyright> // </copyright>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
#if NET45
using System; using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
@ -343,5 +341,3 @@ namespace Microsoft.AspNet.Server.WebListener
} }
} }
} }
#endif

View File

@ -2,9 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net; using System.Net;
#if NET45
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
#endif
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.FeatureModel; using Microsoft.AspNet.FeatureModel;
@ -12,10 +10,7 @@ using Microsoft.AspNet.HttpFeature;
namespace Microsoft.AspNet.Server.WebListener namespace Microsoft.AspNet.Server.WebListener
{ {
internal class FeatureContext : IHttpRequestInformation, IHttpConnection, IHttpResponseInformation, IHttpSendFile internal class FeatureContext : IHttpRequestInformation, IHttpConnection, IHttpResponseInformation, IHttpSendFile, IHttpTransportLayerSecurity
#if NET45
, IHttpTransportLayerSecurity
#endif
{ {
private RequestContext _requestContext; private RequestContext _requestContext;
private FeatureCollection _features; private FeatureCollection _features;
@ -28,16 +23,12 @@ namespace Microsoft.AspNet.Server.WebListener
private string _query; private string _query;
private string _pathBase; private string _pathBase;
private string _path; private string _path;
#if NET45
private IPAddress _remoteIpAddress; private IPAddress _remoteIpAddress;
private IPAddress _localIpAddress; private IPAddress _localIpAddress;
#endif
private int? _remotePort; private int? _remotePort;
private int? _localPort; private int? _localPort;
private bool? _isLocal; private bool? _isLocal;
#if NET45
private X509Certificate _clientCert; private X509Certificate _clientCert;
#endif
private Stream _responseStream; private Stream _responseStream;
private IDictionary<string, string[]> _responseHeaders; private IDictionary<string, string[]> _responseHeaders;
@ -69,10 +60,8 @@ namespace Microsoft.AspNet.Server.WebListener
_features.Add(typeof(IHttpConnection), this); _features.Add(typeof(IHttpConnection), this);
if (Request.IsSecureConnection) if (Request.IsSecureConnection)
{ {
#if NET45
// TODO: Should this feature be conditional? Should we add this for HTTP requests? // TODO: Should this feature be conditional? Should we add this for HTTP requests?
_features.Add(typeof(IHttpTransportLayerSecurity), this); _features.Add(typeof(IHttpTransportLayerSecurity), this);
#endif
} }
_features.Add(typeof(IHttpResponseInformation), this); _features.Add(typeof(IHttpResponseInformation), this);
_features.Add(typeof(IHttpSendFile), this); _features.Add(typeof(IHttpSendFile), this);
@ -90,7 +79,7 @@ namespace Microsoft.AspNet.Server.WebListener
*/ */
} }
#region IHttpRequestInformation #region IHttpRequestInformation
Stream IHttpRequestInformation.Body Stream IHttpRequestInformation.Body
{ {
@ -207,8 +196,8 @@ namespace Microsoft.AspNet.Server.WebListener
} }
set { _scheme = value; } set { _scheme = value; }
} }
#endregion #endregion
#region IHttpConnection #region IHttpConnection
bool IHttpConnection.IsLocal bool IHttpConnection.IsLocal
{ {
get get
@ -221,7 +210,7 @@ namespace Microsoft.AspNet.Server.WebListener
} }
set { _isLocal = value; } set { _isLocal = value; }
} }
#if NET45
IPAddress IHttpConnection.LocalIpAddress IPAddress IHttpConnection.LocalIpAddress
{ {
get get
@ -247,7 +236,7 @@ namespace Microsoft.AspNet.Server.WebListener
} }
set { _remoteIpAddress = value; } set { _remoteIpAddress = value; }
} }
#endif
int IHttpConnection.LocalPort int IHttpConnection.LocalPort
{ {
get get
@ -273,9 +262,8 @@ namespace Microsoft.AspNet.Server.WebListener
} }
set { _remotePort = value; } set { _remotePort = value; }
} }
#endregion #endregion
#region IHttpTransportLayerSecurity #region IHttpTransportLayerSecurity
#if NET45
X509Certificate IHttpTransportLayerSecurity.ClientCertificate X509Certificate IHttpTransportLayerSecurity.ClientCertificate
{ {
get get
@ -296,9 +284,8 @@ namespace Microsoft.AspNet.Server.WebListener
_clientCert = await Request.GetClientCertificateAsync(); _clientCert = await Request.GetClientCertificateAsync();
} }
} }
#endif #endregion
#endregion #region IHttpResponseInformation
#region IHttpResponseInformation
Stream IHttpResponseInformation.Body Stream IHttpResponseInformation.Body
{ {
get get
@ -341,7 +328,7 @@ namespace Microsoft.AspNet.Server.WebListener
get { return Response.StatusCode; } get { return Response.StatusCode; }
set { Response.StatusCode = value; } set { Response.StatusCode = value; }
} }
#endregion #endregion
Task IHttpSendFile.SendFileAsync(string path, long offset, long? length, CancellationToken cancellation) Task IHttpSendFile.SendFileAsync(string path, long offset, long? length, CancellationToken cancellation)
{ {
return Response.SendFileAsync(path, offset, length, cancellation); return Response.SendFileAsync(path, offset, length, cancellation);

View File

@ -10,9 +10,7 @@ using System.Globalization;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
#if NET45
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
#endif
using System.Security.Principal; using System.Security.Principal;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -41,9 +39,7 @@ namespace Microsoft.AspNet.Server.WebListener
private string _pathBase; private string _pathBase;
private string _path; private string _path;
#if NET45
private X509Certificate _clientCert; private X509Certificate _clientCert;
#endif
private IDictionary<string, string[]> _headers; private IDictionary<string, string[]> _headers;
private BoundaryType _contentBoundaryType; private BoundaryType _contentBoundaryType;
@ -270,11 +266,7 @@ namespace Microsoft.AspNet.Server.WebListener
{ {
get get
{ {
#if NET45
return LocalEndPoint.GetIPAddress().Equals(RemoteEndPoint.GetIPAddress()); return LocalEndPoint.GetIPAddress().Equals(RemoteEndPoint.GetIPAddress());
#else
throw new NotImplementedException();
#endif
} }
} }
@ -337,7 +329,7 @@ namespace Microsoft.AspNet.Server.WebListener
return _localEndPoint; return _localEndPoint;
} }
} }
#if NET45
public IPAddress RemoteIpAddress public IPAddress RemoteIpAddress
{ {
get { return RemoteEndPoint.GetIPAddress(); } get { return RemoteEndPoint.GetIPAddress(); }
@ -347,7 +339,7 @@ namespace Microsoft.AspNet.Server.WebListener
{ {
get { return LocalEndPoint.GetIPAddress(); } get { return LocalEndPoint.GetIPAddress(); }
} }
#endif
public int RemotePort public int RemotePort
{ {
get { return RemoteEndPoint.GetPort(); } get { return RemoteEndPoint.GetPort(); }
@ -432,7 +424,6 @@ namespace Microsoft.AspNet.Server.WebListener
return UnsafeNclNativeMethods.HttpApi.GetKnownVerb(RequestBuffer, OriginalBlobAddress); return UnsafeNclNativeMethods.HttpApi.GetKnownVerb(RequestBuffer, OriginalBlobAddress);
} }
#if NET45
// Populates the client certificate. The result may be null if there is no client cert. // Populates the client certificate. The result may be null if there is no client cert.
// TODO: Does it make sense for this to be invoked multiple times (e.g. renegotiate)? Client and server code appear to // TODO: Does it make sense for this to be invoked multiple times (e.g. renegotiate)? Client and server code appear to
// enable this, but it's unclear what Http.Sys would do. // enable this, but it's unclear what Http.Sys would do.
@ -470,7 +461,6 @@ namespace Microsoft.AspNet.Server.WebListener
} }
return _clientCert; return _clientCert;
} }
#endif
// Use this to save the blob from dispose if this object was never used (never given to a user) and is about to be // Use this to save the blob from dispose if this object was never used (never given to a user) and is about to be
// disposed. // disposed.