#127 Target net451 and use Marshal.SizeOf<T>.
This commit is contained in:
parent
fa3b98f113
commit
cdf8072c83
|
|
@ -38,13 +38,8 @@ namespace Microsoft.Net.Http.Server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class AuthenticationManager
|
public sealed class AuthenticationManager
|
||||||
{
|
{
|
||||||
#if DNXCORE50
|
|
||||||
private static readonly int AuthInfoSize =
|
private static readonly int AuthInfoSize =
|
||||||
Marshal.SizeOf<UnsafeNclNativeMethods.HttpApi.HTTP_SERVER_AUTHENTICATION_INFO>();
|
Marshal.SizeOf<UnsafeNclNativeMethods.HttpApi.HTTP_SERVER_AUTHENTICATION_INFO>();
|
||||||
#else
|
|
||||||
private static readonly int AuthInfoSize =
|
|
||||||
Marshal.SizeOf(typeof(UnsafeNclNativeMethods.HttpApi.HTTP_SERVER_AUTHENTICATION_INFO));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private WebListener _server;
|
private WebListener _server;
|
||||||
private AuthenticationSchemes _authSchemes;
|
private AuthenticationSchemes _authSchemes;
|
||||||
|
|
|
||||||
|
|
@ -667,12 +667,7 @@ namespace Microsoft.Net.Http.Server
|
||||||
}
|
}
|
||||||
|
|
||||||
knownHeaderInfo[_nativeResponse.ResponseInfoCount].Type = HttpApi.HTTP_RESPONSE_INFO_TYPE.HttpResponseInfoTypeMultipleKnownHeaders;
|
knownHeaderInfo[_nativeResponse.ResponseInfoCount].Type = HttpApi.HTTP_RESPONSE_INFO_TYPE.HttpResponseInfoTypeMultipleKnownHeaders;
|
||||||
knownHeaderInfo[_nativeResponse.ResponseInfoCount].Length =
|
knownHeaderInfo[_nativeResponse.ResponseInfoCount].Length = (uint)Marshal.SizeOf<HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS>();
|
||||||
#if DNXCORE50
|
|
||||||
(uint)Marshal.SizeOf<HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS>();
|
|
||||||
#else
|
|
||||||
(uint)Marshal.SizeOf(typeof(HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS header = new HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS();
|
HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS header = new HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,13 +35,9 @@ namespace Microsoft.Net.Http.Server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class TimeoutManager
|
public sealed class TimeoutManager
|
||||||
{
|
{
|
||||||
#if DNXCORE50
|
|
||||||
private static readonly int TimeoutLimitSize =
|
private static readonly int TimeoutLimitSize =
|
||||||
Marshal.SizeOf<UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_LIMIT_INFO>();
|
Marshal.SizeOf<UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_LIMIT_INFO>();
|
||||||
#else
|
|
||||||
private static readonly int TimeoutLimitSize =
|
|
||||||
Marshal.SizeOf(typeof(UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_LIMIT_INFO));
|
|
||||||
#endif
|
|
||||||
private WebListener _server;
|
private WebListener _server;
|
||||||
private int[] _timeouts;
|
private int[] _timeouts;
|
||||||
private uint _minSendBytesPerSecond;
|
private uint _minSendBytesPerSecond;
|
||||||
|
|
|
||||||
|
|
@ -41,18 +41,10 @@ namespace Microsoft.Net.Http.Server
|
||||||
public sealed class WebListener : IDisposable
|
public sealed class WebListener : IDisposable
|
||||||
{
|
{
|
||||||
private const long DefaultRequestQueueLength = 1000; // Http.sys default.
|
private const long DefaultRequestQueueLength = 1000; // Http.sys default.
|
||||||
#if DNXCORE50
|
|
||||||
private static readonly int RequestChannelBindStatusSize =
|
private static readonly int RequestChannelBindStatusSize =
|
||||||
Marshal.SizeOf<UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_CHANNEL_BIND_STATUS>();
|
Marshal.SizeOf<UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_CHANNEL_BIND_STATUS>();
|
||||||
private static readonly int BindingInfoSize =
|
private static readonly int BindingInfoSize =
|
||||||
Marshal.SizeOf<UnsafeNclNativeMethods.HttpApi.HTTP_BINDING_INFO>();
|
Marshal.SizeOf<UnsafeNclNativeMethods.HttpApi.HTTP_BINDING_INFO>();
|
||||||
#else
|
|
||||||
private static readonly Type ChannelBindingStatusType = typeof(UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_CHANNEL_BIND_STATUS);
|
|
||||||
private static readonly int RequestChannelBindStatusSize =
|
|
||||||
Marshal.SizeOf(typeof(UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_CHANNEL_BIND_STATUS));
|
|
||||||
private static readonly int BindingInfoSize =
|
|
||||||
Marshal.SizeOf(typeof(UnsafeNclNativeMethods.HttpApi.HTTP_BINDING_INFO));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Win8# 559317 fixed a bug in Http.sys's HttpReceiveClientCertificate method.
|
// Win8# 559317 fixed a bug in Http.sys's HttpReceiveClientCertificate method.
|
||||||
// Without this fix IOCP callbacks were not being called although ERROR_IO_PENDING was
|
// Without this fix IOCP callbacks were not being called although ERROR_IO_PENDING was
|
||||||
|
|
@ -244,7 +236,7 @@ namespace Microsoft.Net.Http.Server
|
||||||
long length = _requestQueueLength.Value;
|
long length = _requestQueueLength.Value;
|
||||||
uint result = UnsafeNclNativeMethods.HttpApi.HttpSetRequestQueueProperty(_requestQueueHandle,
|
uint result = UnsafeNclNativeMethods.HttpApi.HttpSetRequestQueueProperty(_requestQueueHandle,
|
||||||
UnsafeNclNativeMethods.HttpApi.HTTP_SERVER_PROPERTY.HttpServerQueueLengthProperty,
|
UnsafeNclNativeMethods.HttpApi.HTTP_SERVER_PROPERTY.HttpServerQueueLengthProperty,
|
||||||
new IntPtr((void*)&length), (uint)Marshal.SizeOf(length), 0, IntPtr.Zero);
|
new IntPtr((void*)&length), (uint)Marshal.SizeOf<long>(), 0, IntPtr.Zero);
|
||||||
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
|
|
@ -766,11 +758,7 @@ namespace Microsoft.Net.Http.Server
|
||||||
|
|
||||||
knownHeaderInfo[httpResponse.ResponseInfoCount].Type = UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE_INFO_TYPE.HttpResponseInfoTypeMultipleKnownHeaders;
|
knownHeaderInfo[httpResponse.ResponseInfoCount].Type = UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE_INFO_TYPE.HttpResponseInfoTypeMultipleKnownHeaders;
|
||||||
knownHeaderInfo[httpResponse.ResponseInfoCount].Length =
|
knownHeaderInfo[httpResponse.ResponseInfoCount].Length =
|
||||||
#if DNXCORE50
|
(uint)Marshal.SizeOf<UnsafeNclNativeMethods.HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS>();
|
||||||
(uint)Marshal.SizeOf<UnsafeNclNativeMethods.HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS>();
|
|
||||||
#else
|
|
||||||
(uint)Marshal.SizeOf(typeof(UnsafeNclNativeMethods.HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
UnsafeNclNativeMethods.HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS header = new UnsafeNclNativeMethods.HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS();
|
UnsafeNclNativeMethods.HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS header = new UnsafeNclNativeMethods.HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS();
|
||||||
|
|
||||||
|
|
@ -858,11 +846,7 @@ namespace Microsoft.Net.Http.Server
|
||||||
private static int GetTokenOffsetFromBlob(IntPtr blob)
|
private static int GetTokenOffsetFromBlob(IntPtr blob)
|
||||||
{
|
{
|
||||||
Debug.Assert(blob != IntPtr.Zero);
|
Debug.Assert(blob != IntPtr.Zero);
|
||||||
#if DNXCORE50
|
|
||||||
IntPtr tokenPointer = Marshal.ReadIntPtr(blob, (int)Marshal.OffsetOf<UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_CHANNEL_BIND_STATUS>("ChannelToken"));
|
IntPtr tokenPointer = Marshal.ReadIntPtr(blob, (int)Marshal.OffsetOf<UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_CHANNEL_BIND_STATUS>("ChannelToken"));
|
||||||
#else
|
|
||||||
IntPtr tokenPointer = Marshal.ReadIntPtr(blob, (int)Marshal.OffsetOf(ChannelBindingStatusType, "ChannelToken"));
|
|
||||||
#endif
|
|
||||||
Debug.Assert(tokenPointer != IntPtr.Zero);
|
Debug.Assert(tokenPointer != IntPtr.Zero);
|
||||||
return (int)IntPtrHelper.Subtract(tokenPointer, blob);
|
return (int)IntPtrHelper.Subtract(tokenPointer, blob);
|
||||||
}
|
}
|
||||||
|
|
@ -870,11 +854,7 @@ namespace Microsoft.Net.Http.Server
|
||||||
private static int GetTokenSizeFromBlob(IntPtr blob)
|
private static int GetTokenSizeFromBlob(IntPtr blob)
|
||||||
{
|
{
|
||||||
Debug.Assert(blob != IntPtr.Zero);
|
Debug.Assert(blob != IntPtr.Zero);
|
||||||
#if DNXCORE50
|
|
||||||
return Marshal.ReadInt32(blob, (int)Marshal.OffsetOf<UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_CHANNEL_BIND_STATUS>("ChannelTokenSize"));
|
return Marshal.ReadInt32(blob, (int)Marshal.OffsetOf<UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_CHANNEL_BIND_STATUS>("ChannelTokenSize"));
|
||||||
#else
|
|
||||||
return Marshal.ReadInt32(blob, (int)Marshal.OffsetOf(ChannelBindingStatusType, "ChannelTokenSize"));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal ChannelBinding GetChannelBinding(ulong connectionId, bool isSecureConnection)
|
internal ChannelBinding GetChannelBinding(ulong connectionId, bool isSecureConnection)
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
"allowUnsafe": true
|
"allowUnsafe": true
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"net45": { },
|
"net451": { },
|
||||||
"dnx451": { },
|
"dnx451": { },
|
||||||
"dnxcore50": {
|
"dnxcore50": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
||||||
|
|
@ -50,13 +50,8 @@ namespace Microsoft.Net.WebSockets
|
||||||
public const int MinSendBufferSize = 16;
|
public const int MinSendBufferSize = 16;
|
||||||
internal const int MinReceiveBufferSize = 256;
|
internal const int MinReceiveBufferSize = 256;
|
||||||
internal const int MaxBufferSize = 64 * 1024;
|
internal const int MaxBufferSize = 64 * 1024;
|
||||||
#if DNXCORE50
|
|
||||||
private static readonly int SizeOfUInt = Marshal.SizeOf<uint>();
|
private static readonly int SizeOfUInt = Marshal.SizeOf<uint>();
|
||||||
private static readonly int SizeOfBool = Marshal.SizeOf<bool>();
|
private static readonly int SizeOfBool = Marshal.SizeOf<bool>();
|
||||||
#else
|
|
||||||
private static readonly int SizeOfUInt = Marshal.SizeOf(typeof(uint));
|
|
||||||
private static readonly int SizeOfBool = Marshal.SizeOf(typeof(bool));
|
|
||||||
#endif
|
|
||||||
private static readonly int PropertyBufferSize = (2 * SizeOfUInt) + SizeOfBool + IntPtr.Size;
|
private static readonly int PropertyBufferSize = (2 * SizeOfUInt) + SizeOfBool + IntPtr.Size;
|
||||||
|
|
||||||
private readonly int _ReceiveBufferSize;
|
private readonly int _ReceiveBufferSize;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@
|
||||||
},
|
},
|
||||||
"compilationOptions": { "allowUnsafe": true },
|
"compilationOptions": { "allowUnsafe": true },
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"net45": { },
|
"net451": { },
|
||||||
|
"dnx451": { },
|
||||||
"dnxcore50": {
|
"dnxcore50": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"System.Collections": "4.0.10-beta-*",
|
"System.Collections": "4.0.10-beta-*",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue