Remove unused code. Reduce class nesting.

This commit is contained in:
Chris R 2016-08-08 13:18:01 -07:00
parent 4b36501bd8
commit ce06c0b241
24 changed files with 1208 additions and 1441 deletions

View File

@ -164,10 +164,10 @@ namespace Microsoft.Net.Http.Server
{
retry = false;
uint bytesTransferred = 0;
statusCode = UnsafeNclNativeMethods.HttpApi.HttpReceiveHttpRequest(
statusCode = HttpApi.HttpReceiveHttpRequest(
Server.RequestQueue.Handle,
_nativeRequestContext.RequestBlob->RequestId,
(uint)UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY,
(uint)HttpApi.HTTP_FLAGS.HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY,
_nativeRequestContext.RequestBlob,
_nativeRequestContext.Size,
&bytesTransferred,

View File

@ -40,7 +40,7 @@ namespace Microsoft.Net.Http.Server
public sealed class AuthenticationManager
{
private static readonly int AuthInfoSize =
Marshal.SizeOf<UnsafeNclNativeMethods.HttpApi.HTTP_SERVER_AUTHENTICATION_INFO>();
Marshal.SizeOf<HttpApi.HTTP_SERVER_AUTHENTICATION_INFO>();
private WebListener _server;
private AuthenticationSchemes _authSchemes;
@ -73,12 +73,12 @@ namespace Microsoft.Net.Http.Server
private unsafe void SetServerSecurity()
{
UnsafeNclNativeMethods.HttpApi.HTTP_SERVER_AUTHENTICATION_INFO authInfo =
new UnsafeNclNativeMethods.HttpApi.HTTP_SERVER_AUTHENTICATION_INFO();
HttpApi.HTTP_SERVER_AUTHENTICATION_INFO authInfo =
new HttpApi.HTTP_SERVER_AUTHENTICATION_INFO();
authInfo.Flags = UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.HTTP_PROPERTY_FLAG_PRESENT;
var authSchemes = (UnsafeNclNativeMethods.HttpApi.HTTP_AUTH_TYPES)_authSchemes;
if (authSchemes != UnsafeNclNativeMethods.HttpApi.HTTP_AUTH_TYPES.NONE)
authInfo.Flags = HttpApi.HTTP_FLAGS.HTTP_PROPERTY_FLAG_PRESENT;
var authSchemes = (HttpApi.HTTP_AUTH_TYPES)_authSchemes;
if (authSchemes != HttpApi.HTTP_AUTH_TYPES.NONE)
{
authInfo.AuthSchemes = authSchemes;
@ -92,7 +92,7 @@ namespace Microsoft.Net.Http.Server
IntPtr infoptr = new IntPtr(&authInfo);
_server.UrlGroup.SetProperty(
UnsafeNclNativeMethods.HttpApi.HTTP_SERVER_PROPERTY.HttpServerAuthenticationProperty,
HttpApi.HTTP_SERVER_PROPERTY.HttpServerAuthenticationProperty,
infoptr, (uint)AuthInfoSize);
}
}
@ -144,25 +144,25 @@ namespace Microsoft.Net.Http.Server
}
}
internal static unsafe bool CheckAuthenticated(UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_INFO* requestInfo)
internal static unsafe bool CheckAuthenticated(HttpApi.HTTP_REQUEST_INFO* requestInfo)
{
if (requestInfo != null
&& requestInfo->InfoType == UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_INFO_TYPE.HttpRequestInfoTypeAuth
&& requestInfo->pInfo->AuthStatus == UnsafeNclNativeMethods.HttpApi.HTTP_AUTH_STATUS.HttpAuthStatusSuccess)
&& requestInfo->InfoType == HttpApi.HTTP_REQUEST_INFO_TYPE.HttpRequestInfoTypeAuth
&& requestInfo->pInfo->AuthStatus == HttpApi.HTTP_AUTH_STATUS.HttpAuthStatusSuccess)
{
return true;
}
return false;
}
internal static unsafe ClaimsPrincipal GetUser(UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_INFO* requestInfo, int infoCount)
internal static unsafe ClaimsPrincipal GetUser(HttpApi.HTTP_REQUEST_INFO* requestInfo, int infoCount)
{
for (int i = 0; i < infoCount; i++)
{
var info = &requestInfo[i];
if (requestInfo != null
&& info->InfoType == UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_INFO_TYPE.HttpRequestInfoTypeAuth
&& info->pInfo->AuthStatus == UnsafeNclNativeMethods.HttpApi.HTTP_AUTH_STATUS.HttpAuthStatusSuccess)
&& info->InfoType == HttpApi.HTTP_REQUEST_INFO_TYPE.HttpRequestInfoTypeAuth
&& info->pInfo->AuthStatus == HttpApi.HTTP_AUTH_STATUS.HttpAuthStatusSuccess)
{
return new WindowsPrincipal(new WindowsIdentity(info->pInfo->AccessToken,
GetAuthTypeFromRequest(info->pInfo->AuthType).ToString()));
@ -171,19 +171,19 @@ namespace Microsoft.Net.Http.Server
return new ClaimsPrincipal(new ClaimsIdentity()); // Anonymous / !IsAuthenticated
}
private static AuthenticationSchemes GetAuthTypeFromRequest(UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_AUTH_TYPE input)
private static AuthenticationSchemes GetAuthTypeFromRequest(HttpApi.HTTP_REQUEST_AUTH_TYPE input)
{
switch (input)
{
case UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_AUTH_TYPE.HttpRequestAuthTypeBasic:
case HttpApi.HTTP_REQUEST_AUTH_TYPE.HttpRequestAuthTypeBasic:
return AuthenticationSchemes.Basic;
// case UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_AUTH_TYPE.HttpRequestAuthTypeDigest:
// case HttpApi.HTTP_REQUEST_AUTH_TYPE.HttpRequestAuthTypeDigest:
// return AuthenticationSchemes.Digest;
case UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_AUTH_TYPE.HttpRequestAuthTypeNTLM:
case HttpApi.HTTP_REQUEST_AUTH_TYPE.HttpRequestAuthTypeNTLM:
return AuthenticationSchemes.NTLM;
case UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_AUTH_TYPE.HttpRequestAuthTypeNegotiate:
case HttpApi.HTTP_REQUEST_AUTH_TYPE.HttpRequestAuthTypeNegotiate:
return AuthenticationSchemes.Negotiate;
case UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_AUTH_TYPE.HttpRequestAuthTypeKerberos:
case HttpApi.HTTP_REQUEST_AUTH_TYPE.HttpRequestAuthTypeKerberos:
return AuthenticationSchemes.Kerberos;
default:
throw new NotImplementedException(input.ToString());

View File

@ -105,7 +105,7 @@ namespace Microsoft.Net.Http.Server
uint statusCode;
try
{
statusCode = UnsafeNclNativeMethods.HttpApi.HttpWaitForDisconnectEx(requestQueueHandle: _requestQueue.Handle,
statusCode = HttpApi.HttpWaitForDisconnectEx(requestQueueHandle: _requestQueue.Handle,
connectionId: connectionId, reserved: 0, overlapped: nativeOverlapped);
}
catch (Win32Exception exception)

File diff suppressed because it is too large Load Diff

View File

@ -35,7 +35,7 @@ namespace Microsoft.Net.Http.Server
protected override bool ReleaseHandle()
{
return (UnsafeNclNativeMethods.SafeNetHandles.HttpCloseRequestQueue(handle) ==
return (HttpApi.HttpCloseRequestQueue(handle) ==
UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS);
}
}

View File

@ -55,7 +55,7 @@ namespace Microsoft.Net.Http.Server
if (Interlocked.Increment(ref disposed) == 1)
{
// Closing server session also closes all open url groups under that server session.
return (UnsafeNclNativeMethods.HttpApi.HttpCloseServerSession(serverSessionId) ==
return (HttpApi.HttpCloseServerSession(serverSessionId) ==
UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS);
}
}

View File

@ -28,7 +28,7 @@ namespace Microsoft.Net.Http.Server
internal class RequestQueue
{
private static readonly int BindingInfoSize =
Marshal.SizeOf<UnsafeNclNativeMethods.HttpApi.HTTP_BINDING_INFO>();
Marshal.SizeOf<HttpApi.HTTP_BINDING_INFO>();
private readonly UrlGroup _urlGroup;
private readonly ILogger _logger;
@ -39,8 +39,8 @@ namespace Microsoft.Net.Http.Server
_logger = logger;
HttpRequestQueueV2Handle requestQueueHandle = null;
var statusCode = UnsafeNclNativeMethods.SafeNetHandles.HttpCreateRequestQueue(
UnsafeNclNativeMethods.HttpApi.Version, null, null, 0, out requestQueueHandle);
var statusCode = HttpApi.HttpCreateRequestQueue(
HttpApi.Version, null, null, 0, out requestQueueHandle);
if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS)
{
@ -69,13 +69,13 @@ namespace Microsoft.Net.Http.Server
// Set the association between request queue and url group. After this, requests for registered urls will
// get delivered to this request queue.
var info = new UnsafeNclNativeMethods.HttpApi.HTTP_BINDING_INFO();
info.Flags = UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.HTTP_PROPERTY_FLAG_PRESENT;
var info = new HttpApi.HTTP_BINDING_INFO();
info.Flags = HttpApi.HTTP_FLAGS.HTTP_PROPERTY_FLAG_PRESENT;
info.RequestQueueHandle = Handle.DangerousGetHandle();
var infoptr = new IntPtr(&info);
_urlGroup.SetProperty(UnsafeNclNativeMethods.HttpApi.HTTP_SERVER_PROPERTY.HttpServerBindingProperty,
_urlGroup.SetProperty(HttpApi.HTTP_SERVER_PROPERTY.HttpServerBindingProperty,
infoptr, (uint)BindingInfoSize);
}
@ -87,21 +87,21 @@ namespace Microsoft.Net.Http.Server
// is fine since http.sys allows to set HttpServerBindingProperty multiple times for valid
// Url groups.
var info = new UnsafeNclNativeMethods.HttpApi.HTTP_BINDING_INFO();
info.Flags = UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.NONE;
var info = new HttpApi.HTTP_BINDING_INFO();
info.Flags = HttpApi.HTTP_FLAGS.NONE;
info.RequestQueueHandle = IntPtr.Zero;
var infoptr = new IntPtr(&info);
_urlGroup.SetProperty(UnsafeNclNativeMethods.HttpApi.HTTP_SERVER_PROPERTY.HttpServerBindingProperty,
_urlGroup.SetProperty(HttpApi.HTTP_SERVER_PROPERTY.HttpServerBindingProperty,
infoptr, (uint)BindingInfoSize, throwOnError: false);
}
// The listener must be active for this to work.
internal unsafe void SetLengthLimit(long length)
{
var result = UnsafeNclNativeMethods.HttpApi.HttpSetRequestQueueProperty(Handle,
UnsafeNclNativeMethods.HttpApi.HTTP_SERVER_PROPERTY.HttpServerQueueLengthProperty,
var result = HttpApi.HttpSetRequestQueueProperty(Handle,
HttpApi.HTTP_SERVER_PROPERTY.HttpServerQueueLengthProperty,
new IntPtr((void*)&length), (uint)Marshal.SizeOf<long>(), 0, IntPtr.Zero);
if (result != 0)

View File

@ -25,8 +25,8 @@ namespace Microsoft.Net.Http.Server
internal unsafe ServerSession()
{
ulong serverSessionId = 0;
var statusCode = UnsafeNclNativeMethods.HttpApi.HttpCreateServerSession(
UnsafeNclNativeMethods.HttpApi.Version, &serverSessionId, 0);
var statusCode = HttpApi.HttpCreateServerSession(
HttpApi.Version, &serverSessionId, 0);
if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS)
{

View File

@ -17,7 +17,7 @@
using System;
using System.Runtime.InteropServices;
using static Microsoft.Net.Http.Server.UnsafeNclNativeMethods.HttpApi;
using static Microsoft.Net.Http.Server.HttpApi;
using static Microsoft.Net.Http.Server.UnsafeNclNativeMethods.TokenBinding;
namespace Microsoft.Net.Http.Server

View File

@ -33,7 +33,7 @@ namespace Microsoft.Net.Http.Server
_logger = logger;
ulong urlGroupId = 0;
var statusCode = UnsafeNclNativeMethods.HttpApi.HttpCreateUrlGroup(
var statusCode = HttpApi.HttpCreateUrlGroup(
_serverSession.Id.DangerousGetServerSessionId(), &urlGroupId, 0);
if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS)
@ -47,11 +47,11 @@ namespace Microsoft.Net.Http.Server
internal ulong Id { get; private set; }
internal void SetProperty(UnsafeNclNativeMethods.HttpApi.HTTP_SERVER_PROPERTY property, IntPtr info, uint infosize, bool throwOnError = true)
internal void SetProperty(HttpApi.HTTP_SERVER_PROPERTY property, IntPtr info, uint infosize, bool throwOnError = true)
{
Debug.Assert(info != IntPtr.Zero, "SetUrlGroupProperty called with invalid pointer");
var statusCode = UnsafeNclNativeMethods.HttpApi.HttpSetUrlGroupProperty(Id, property, info, infosize);
var statusCode = HttpApi.HttpSetUrlGroupProperty(Id, property, info, infosize);
if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS)
{
@ -68,7 +68,7 @@ namespace Microsoft.Net.Http.Server
{
LogHelper.LogInfo(_logger, "Listening on prefix: " + uriPrefix);
var statusCode = UnsafeNclNativeMethods.HttpApi.HttpAddUrlToUrlGroup(Id, uriPrefix, (ulong)contextId, 0);
var statusCode = HttpApi.HttpAddUrlToUrlGroup(Id, uriPrefix, (ulong)contextId, 0);
if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS)
{
@ -87,7 +87,7 @@ namespace Microsoft.Net.Http.Server
{
LogHelper.LogInfo(_logger, "Stop listening on prefix: " + uriPrefix);
var statusCode = UnsafeNclNativeMethods.HttpApi.HttpRemoveUrlFromUrlGroup(Id, uriPrefix, 0);
var statusCode = HttpApi.HttpRemoveUrlFromUrlGroup(Id, uriPrefix, 0);
if (statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_NOT_FOUND)
{
@ -107,7 +107,7 @@ namespace Microsoft.Net.Http.Server
Debug.Assert(Id != 0, "HttpCloseUrlGroup called with invalid url group id");
uint statusCode = UnsafeNclNativeMethods.HttpApi.HttpCloseUrlGroup(Id);
uint statusCode = HttpApi.HttpCloseUrlGroup(Id);
if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS)
{

View File

@ -43,11 +43,11 @@ namespace Microsoft.Net.Http.Server
private const uint CertBoblSize = 1500;
private static readonly IOCompletionCallback IOCallback = new IOCompletionCallback(WaitCallback);
private static readonly int RequestChannelBindStatusSize =
Marshal.SizeOf<UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_CHANNEL_BIND_STATUS>();
Marshal.SizeOf<HttpApi.HTTP_REQUEST_CHANNEL_BIND_STATUS>();
private SafeNativeOverlapped _overlapped;
private byte[] _backingBuffer;
private UnsafeNclNativeMethods.HttpApi.HTTP_SSL_CLIENT_CERT_INFO* _memoryBlob;
private HttpApi.HTTP_SSL_CLIENT_CERT_INFO* _memoryBlob;
private uint _size;
private TaskCompletionSource<object> _tcs;
private RequestContext _requestContext;
@ -124,7 +124,7 @@ namespace Microsoft.Net.Http.Server
}
}
private UnsafeNclNativeMethods.HttpApi.HTTP_SSL_CLIENT_CERT_INFO* RequestBlob
private HttpApi.HTTP_SSL_CLIENT_CERT_INFO* RequestBlob
{
get
{
@ -154,7 +154,7 @@ namespace Microsoft.Net.Http.Server
var boundHandle = RequestContext.Server.RequestQueue.BoundHandle;
_overlapped = new SafeNativeOverlapped(boundHandle,
boundHandle.AllocateNativeOverlapped(IOCallback, this, _backingBuffer));
_memoryBlob = (UnsafeNclNativeMethods.HttpApi.HTTP_SSL_CLIENT_CERT_INFO*)Marshal.UnsafeAddrOfPinnedArrayElement(_backingBuffer, 0);
_memoryBlob = (HttpApi.HTTP_SSL_CLIENT_CERT_INFO*)Marshal.UnsafeAddrOfPinnedArrayElement(_backingBuffer, 0);
}
// When you use netsh to configure HTTP.SYS with clientcertnegotiation = enable
@ -185,10 +185,10 @@ namespace Microsoft.Net.Http.Server
uint bytesReceived = 0;
uint statusCode =
UnsafeNclNativeMethods.HttpApi.HttpReceiveClientCertificate(
HttpApi.HttpReceiveClientCertificate(
RequestQueueHandle,
RequestContext.Request.UConnectionId,
(uint)UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.NONE,
(uint)HttpApi.HTTP_FLAGS.NONE,
RequestBlob,
size,
&bytesReceived,
@ -196,7 +196,7 @@ namespace Microsoft.Net.Http.Server
if (statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_MORE_DATA)
{
UnsafeNclNativeMethods.HttpApi.HTTP_SSL_CLIENT_CERT_INFO* pClientCertInfo = RequestBlob;
HttpApi.HTTP_SSL_CLIENT_CERT_INFO* pClientCertInfo = RequestBlob;
size = bytesReceived + pClientCertInfo->CertEncodedSize;
Reset(size);
retry = true;
@ -259,15 +259,15 @@ namespace Microsoft.Net.Http.Server
// return the size of the initial cert structure. To get the full size,
// we need to add the certificate encoding size as well.
UnsafeNclNativeMethods.HttpApi.HTTP_SSL_CLIENT_CERT_INFO* pClientCertInfo = asyncResult.RequestBlob;
HttpApi.HTTP_SSL_CLIENT_CERT_INFO* pClientCertInfo = asyncResult.RequestBlob;
asyncResult.Reset(numBytes + pClientCertInfo->CertEncodedSize);
uint bytesReceived = 0;
errorCode =
UnsafeNclNativeMethods.HttpApi.HttpReceiveClientCertificate(
HttpApi.HttpReceiveClientCertificate(
requestContext.Server.RequestQueue.Handle,
requestContext.Request.UConnectionId,
(uint)UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.NONE,
(uint)HttpApi.HTTP_FLAGS.NONE,
asyncResult._memoryBlob,
asyncResult._size,
&bytesReceived,
@ -291,7 +291,7 @@ namespace Microsoft.Net.Http.Server
}
else
{
UnsafeNclNativeMethods.HttpApi.HTTP_SSL_CLIENT_CERT_INFO* pClientCertInfo = asyncResult._memoryBlob;
HttpApi.HTTP_SSL_CLIENT_CERT_INFO* pClientCertInfo = asyncResult._memoryBlob;
if (pClientCertInfo == null)
{
asyncResult.Complete(0, null);
@ -391,10 +391,10 @@ namespace Microsoft.Net.Http.Server
{
// Http.sys team: ServiceName will always be null if
// HTTP_RECEIVE_SECURE_CHANNEL_TOKEN flag is set.
statusCode = UnsafeNclNativeMethods.HttpApi.HttpReceiveClientCertificate(
statusCode = HttpApi.HttpReceiveClientCertificate(
requestQueue.Handle,
connectionId,
(uint)UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.HTTP_RECEIVE_SECURE_CHANNEL_TOKEN,
(uint)HttpApi.HTTP_FLAGS.HTTP_RECEIVE_SECURE_CHANNEL_TOKEN,
blobPtr,
(uint)size,
&bytesReceived,
@ -438,7 +438,7 @@ namespace Microsoft.Net.Http.Server
private static int GetTokenOffsetFromBlob(IntPtr blob)
{
Debug.Assert(blob != IntPtr.Zero);
IntPtr tokenPointer = Marshal.ReadIntPtr(blob, (int)Marshal.OffsetOf<UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_CHANNEL_BIND_STATUS>("ChannelToken"));
IntPtr tokenPointer = Marshal.ReadIntPtr(blob, (int)Marshal.OffsetOf<HttpApi.HTTP_REQUEST_CHANNEL_BIND_STATUS>("ChannelToken"));
Debug.Assert(tokenPointer != IntPtr.Zero);
return (int)IntPtrHelper.Subtract(tokenPointer, blob);
}
@ -446,7 +446,7 @@ namespace Microsoft.Net.Http.Server
private static int GetTokenSizeFromBlob(IntPtr blob)
{
Debug.Assert(blob != IntPtr.Zero);
return Marshal.ReadInt32(blob, (int)Marshal.OffsetOf<UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_CHANNEL_BIND_STATUS>("ChannelTokenSize"));
return Marshal.ReadInt32(blob, (int)Marshal.OffsetOf<HttpApi.HTTP_REQUEST_CHANNEL_BIND_STATUS>("ChannelTokenSize"));
}
}
}

View File

@ -32,7 +32,7 @@ namespace Microsoft.Net.Http.Server
{
private const int DefaultBufferSize = 4096;
private const int AlignmentPadding = 8;
private UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST* _memoryBlob;
private HttpApi.HTTP_REQUEST* _memoryBlob;
private IntPtr _originalBlobAddress;
private byte[] _backingBuffer;
private int _bufferAlignment;
@ -42,7 +42,7 @@ namespace Microsoft.Net.Http.Server
internal NativeRequestContext(AsyncAcceptContext result)
{
_acceptResult = result;
UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST* requestBlob = Allocate(0);
HttpApi.HTTP_REQUEST* requestBlob = Allocate(0);
if (requestBlob == null)
{
GC.SuppressFinalize(this);
@ -61,7 +61,7 @@ namespace Microsoft.Net.Http.Server
}
}
internal UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST* RequestBlob
internal HttpApi.HTTP_REQUEST* RequestBlob
{
get
{
@ -98,7 +98,7 @@ namespace Microsoft.Net.Http.Server
{
get
{
UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST* blob = _memoryBlob;
HttpApi.HTTP_REQUEST* blob = _memoryBlob;
return blob == null ? _originalBlobAddress : (IntPtr)blob;
}
}
@ -138,7 +138,7 @@ namespace Microsoft.Net.Http.Server
}
}
private void SetBlob(UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST* requestBlob)
private void SetBlob(HttpApi.HTTP_REQUEST* requestBlob)
{
Debug.Assert(_memoryBlob != null || _backingBuffer == null, "RequestContextBase::Dispose()|SetBlob() called after ReleasePins().");
if (requestBlob == null)
@ -170,7 +170,7 @@ namespace Microsoft.Net.Http.Server
_backingBuffer = new byte[size + AlignmentPadding];
}
private UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST* Allocate(uint size)
private HttpApi.HTTP_REQUEST* Allocate(uint size)
{
// We can't reuse overlapped objects
if (_nativeOverlapped != null)
@ -191,7 +191,7 @@ namespace Microsoft.Net.Http.Server
var requestAddress = Marshal.UnsafeAddrOfPinnedArrayElement(RequestBuffer, 0);
_bufferAlignment = (int)(requestAddress.ToInt64() & 0x07);
return (UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST*)(requestAddress + _bufferAlignment);
return (HttpApi.HTTP_REQUEST*)(requestAddress + _bufferAlignment);
}
internal void Reset(ulong requestId, uint size)

View File

@ -68,7 +68,7 @@ namespace Microsoft.Net.Http.Server
RawUrl = Marshal.PtrToStringAnsi((IntPtr)memoryBlob.RequestBlob->pRawUrl, memoryBlob.RequestBlob->RawUrlLength);
}
UnsafeNclNativeMethods.HttpApi.HTTP_COOKED_URL cookedUrl = memoryBlob.RequestBlob->CookedUrl;
HttpApi.HTTP_COOKED_URL cookedUrl = memoryBlob.RequestBlob->CookedUrl;
if (cookedUrl.pHost != null && cookedUrl.HostLength > 0)
{
// TODO: Unused
@ -119,10 +119,10 @@ namespace Microsoft.Net.Http.Server
}
KnownMethod = memoryBlob.RequestBlob->Verb;
Method = UnsafeNclNativeMethods.HttpApi.GetVerb(memoryBlob.RequestBlob);
Method = HttpApi.GetVerb(memoryBlob.RequestBlob);
Headers = new HeaderCollection(new RequestHeaders(_nativeRequestContext));
var requestV2 = (UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_V2*)memoryBlob.RequestBlob;
var requestV2 = (HttpApi.HTTP_REQUEST_V2*)memoryBlob.RequestBlob;
User = AuthenticationManager.GetUser(requestV2->pRequestInfo, requestV2->RequestInfoCount);
GetTlsTokenBindingInfo();
@ -207,9 +207,9 @@ namespace Microsoft.Net.Http.Server
public HeaderCollection Headers { get; }
internal UnsafeNclNativeMethods.HttpApi.HTTP_VERB KnownMethod { get; }
internal HttpApi.HTTP_VERB KnownMethod { get; }
public bool IsHeadMethod => KnownMethod == UnsafeNclNativeMethods.HttpApi.HTTP_VERB.HttpVerbHEAD;
public bool IsHeadMethod => KnownMethod == HttpApi.HTTP_VERB.HttpVerbHEAD;
public string Method { get; }
@ -251,7 +251,7 @@ namespace Microsoft.Net.Http.Server
{
if (_remoteEndPoint == null)
{
_remoteEndPoint = UnsafeNclNativeMethods.HttpApi.GetRemoteEndPoint(RequestBuffer, BufferAlignment, OriginalBlobAddress);
_remoteEndPoint = HttpApi.GetRemoteEndPoint(RequestBuffer, BufferAlignment, OriginalBlobAddress);
}
return _remoteEndPoint;
@ -264,7 +264,7 @@ namespace Microsoft.Net.Http.Server
{
if (_localEndPoint == null)
{
_localEndPoint = UnsafeNclNativeMethods.HttpApi.GetLocalEndPoint(RequestBuffer, BufferAlignment, OriginalBlobAddress);
_localEndPoint = HttpApi.GetLocalEndPoint(RequestBuffer, BufferAlignment, OriginalBlobAddress);
}
return _localEndPoint;
@ -349,13 +349,13 @@ namespace Microsoft.Net.Http.Server
// Value: "iexplore.exe"=dword:00000001
private unsafe void GetTlsTokenBindingInfo()
{
var nativeRequest = (UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_V2*)_nativeRequestContext.RequestBlob;
var nativeRequest = (HttpApi.HTTP_REQUEST_V2*)_nativeRequestContext.RequestBlob;
for (int i = 0; i < nativeRequest->RequestInfoCount; i++)
{
var pThisInfo = &nativeRequest->pRequestInfo[i];
if (pThisInfo->InfoType == UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_INFO_TYPE.HttpRequestInfoTypeSslTokenBinding)
if (pThisInfo->InfoType == HttpApi.HTTP_REQUEST_INFO_TYPE.HttpRequestInfoTypeSslTokenBinding)
{
var pTokenBindingInfo = (UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_TOKEN_BINDING_INFO*)pThisInfo->pInfo;
var pTokenBindingInfo = (HttpApi.HTTP_REQUEST_TOKEN_BINDING_INFO*)pThisInfo->pInfo;
_providedTokenBindingId = TokenBindingUtil.GetProvidedTokenIdFromBindingInfo(pTokenBindingInfo, out _referredTokenBindingId);
}
}

View File

@ -136,7 +136,7 @@ namespace Microsoft.Net.Http.Server
return false;
}
if (Request.KnownMethod != UnsafeNclNativeMethods.HttpApi.HTTP_VERB.HttpVerbGET)
if (Request.KnownMethod != HttpApi.HTTP_VERB.HttpVerbGET)
{
return false;
}
@ -186,7 +186,7 @@ namespace Microsoft.Net.Http.Server
throw new InvalidOperationException("This request is not a valid upgrade request.");
}
if (Request.KnownMethod != UnsafeNclNativeMethods.HttpApi.HTTP_VERB.HttpVerbGET)
if (Request.KnownMethod != HttpApi.HTTP_VERB.HttpVerbGET)
{
throw new InvalidOperationException("This request is not a valid upgrade request; invalid verb: " + Request.Method);
}
@ -352,7 +352,7 @@ namespace Microsoft.Net.Http.Server
{
try
{
var statusCode = UnsafeNclNativeMethods.HttpApi.HttpCancelHttpRequest(Server.RequestQueue.Handle,
var statusCode = HttpApi.HttpCancelHttpRequest(Server.RequestQueue.Handle,
Request.RequestId, IntPtr.Zero);
// Either the connection has already dropped, or the last write is in progress.

View File

@ -85,13 +85,13 @@ namespace Microsoft.Net.Http.Server
private string GetKnownHeader(HttpSysRequestHeader header)
{
return UnsafeNclNativeMethods.HttpApi.GetKnownHeader(_requestMemoryBlob.RequestBuffer,
return HttpApi.GetKnownHeader(_requestMemoryBlob.RequestBuffer,
_requestMemoryBlob.BufferAlignment, _requestMemoryBlob.OriginalBlobAddress, (int)header);
}
private void GetUnknownHeaders(IDictionary<string, StringValues> extra)
{
UnsafeNclNativeMethods.HttpApi.GetUnknownHeaders(extra, _requestMemoryBlob.RequestBuffer,
HttpApi.GetUnknownHeaders(extra, _requestMemoryBlob.RequestBuffer,
_requestMemoryBlob.BufferAlignment, _requestMemoryBlob.OriginalBlobAddress);
}

View File

@ -154,7 +154,7 @@ namespace Microsoft.Net.Http.Server
if (_dataChunkIndex != -1)
{
dataRead = UnsafeNclNativeMethods.HttpApi.GetChunks(_requestContext.Request.RequestBuffer,
dataRead = HttpApi.GetChunks(_requestContext.Request.RequestBuffer,
_requestContext.Request.BufferAlignment, _requestContext.Request.OriginalBlobAddress,
ref _dataChunkIndex, ref _dataChunkOffset, buffer, offset, size);
}
@ -179,7 +179,7 @@ namespace Microsoft.Net.Http.Server
uint flags = 0;
statusCode =
UnsafeNclNativeMethods.HttpApi.HttpReceiveRequestEntityBody(
HttpApi.HttpReceiveRequestEntityBody(
RequestQueueHandle,
RequestId,
flags,
@ -232,7 +232,7 @@ namespace Microsoft.Net.Http.Server
uint dataRead = 0;
if (_dataChunkIndex != -1)
{
dataRead = UnsafeNclNativeMethods.HttpApi.GetChunks(_requestContext.Request.RequestBuffer, _requestContext.Request.BufferAlignment,
dataRead = HttpApi.GetChunks(_requestContext.Request.RequestBuffer, _requestContext.Request.BufferAlignment,
_requestContext.Request.OriginalBlobAddress, ref _dataChunkIndex, ref _dataChunkOffset, buffer, offset, size);
if (_dataChunkIndex != -1 && dataRead == size)
@ -262,7 +262,7 @@ namespace Microsoft.Net.Http.Server
uint flags = 0;
statusCode =
UnsafeNclNativeMethods.HttpApi.HttpReceiveRequestEntityBody(
HttpApi.HttpReceiveRequestEntityBody(
RequestQueueHandle,
RequestId,
flags,
@ -350,7 +350,7 @@ namespace Microsoft.Net.Http.Server
uint dataRead = 0;
if (_dataChunkIndex != -1)
{
dataRead = UnsafeNclNativeMethods.HttpApi.GetChunks(_requestContext.Request.RequestBuffer, _requestContext.Request.BufferAlignment,
dataRead = HttpApi.GetChunks(_requestContext.Request.RequestBuffer, _requestContext.Request.BufferAlignment,
_requestContext.Request.OriginalBlobAddress, ref _dataChunkIndex, ref _dataChunkOffset, buffer, offset, size);
if (_dataChunkIndex != -1 && dataRead == size)
{
@ -386,7 +386,7 @@ namespace Microsoft.Net.Http.Server
uint flags = 0;
statusCode =
UnsafeNclNativeMethods.HttpApi.HttpReceiveRequestEntityBody(
HttpApi.HttpReceiveRequestEntityBody(
RequestQueueHandle,
RequestId,
flags,

View File

@ -406,9 +406,9 @@ namespace Microsoft.Net.Http.Server
_requestContext.Abort();
}
private UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS ComputeLeftToWrite(bool endOfRequest = false)
private HttpApi.HTTP_FLAGS ComputeLeftToWrite(bool endOfRequest = false)
{
UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS flags = UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.NONE;
HttpApi.HTTP_FLAGS flags = HttpApi.HTTP_FLAGS.NONE;
if (!_requestContext.Response.ComputedHeaders)
{
flags = _requestContext.Response.ComputeHeaders(endOfRequest, _buffer.TotalBytes);
@ -565,7 +565,7 @@ namespace Microsoft.Net.Http.Server
internal unsafe Task SendFileAsyncCore(string fileName, long offset, long? count, CancellationToken cancellationToken)
{
_requestContext.Response.Start();
UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS flags = ComputeLeftToWrite();
HttpApi.HTTP_FLAGS flags = ComputeLeftToWrite();
if (count == 0 && _leftToWrite != 0)
{
return Helpers.CompletedTask();

View File

@ -35,7 +35,7 @@ namespace Microsoft.Net.Http.Server
public sealed class TimeoutManager
{
private static readonly int TimeoutLimitSize =
Marshal.SizeOf<UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_LIMIT_INFO>();
Marshal.SizeOf<HttpApi.HTTP_TIMEOUT_LIMIT_INFO>();
private WebListener _server;
private int[] _timeouts;
@ -69,11 +69,11 @@ namespace Microsoft.Net.Http.Server
{
get
{
return GetTimeSpanTimeout(UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_TYPE.EntityBody);
return GetTimeSpanTimeout(HttpApi.HTTP_TIMEOUT_TYPE.EntityBody);
}
set
{
SetTimeSpanTimeout(UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_TYPE.EntityBody, value);
SetTimeSpanTimeout(HttpApi.HTTP_TIMEOUT_TYPE.EntityBody, value);
}
}
@ -92,11 +92,11 @@ namespace Microsoft.Net.Http.Server
{
get
{
return GetTimeSpanTimeout(UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_TYPE.DrainEntityBody);
return GetTimeSpanTimeout(HttpApi.HTTP_TIMEOUT_TYPE.DrainEntityBody);
}
set
{
SetTimeSpanTimeout(UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_TYPE.DrainEntityBody, value);
SetTimeSpanTimeout(HttpApi.HTTP_TIMEOUT_TYPE.DrainEntityBody, value);
}
}
@ -110,11 +110,11 @@ namespace Microsoft.Net.Http.Server
{
get
{
return GetTimeSpanTimeout(UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_TYPE.RequestQueue);
return GetTimeSpanTimeout(HttpApi.HTTP_TIMEOUT_TYPE.RequestQueue);
}
set
{
SetTimeSpanTimeout(UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_TYPE.RequestQueue, value);
SetTimeSpanTimeout(HttpApi.HTTP_TIMEOUT_TYPE.RequestQueue, value);
}
}
@ -129,11 +129,11 @@ namespace Microsoft.Net.Http.Server
{
get
{
return GetTimeSpanTimeout(UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_TYPE.IdleConnection);
return GetTimeSpanTimeout(HttpApi.HTTP_TIMEOUT_TYPE.IdleConnection);
}
set
{
SetTimeSpanTimeout(UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_TYPE.IdleConnection, value);
SetTimeSpanTimeout(HttpApi.HTTP_TIMEOUT_TYPE.IdleConnection, value);
}
}
@ -149,11 +149,11 @@ namespace Microsoft.Net.Http.Server
{
get
{
return GetTimeSpanTimeout(UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_TYPE.HeaderWait);
return GetTimeSpanTimeout(HttpApi.HTTP_TIMEOUT_TYPE.HeaderWait);
}
set
{
SetTimeSpanTimeout(UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_TYPE.HeaderWait, value);
SetTimeSpanTimeout(HttpApi.HTTP_TIMEOUT_TYPE.HeaderWait, value);
}
}
@ -189,13 +189,13 @@ namespace Microsoft.Net.Http.Server
#region Helpers
private TimeSpan GetTimeSpanTimeout(UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_TYPE type)
private TimeSpan GetTimeSpanTimeout(HttpApi.HTTP_TIMEOUT_TYPE type)
{
// Since we maintain local state, GET is local.
return new TimeSpan(0, 0, (int)_timeouts[(int)type]);
}
private void SetTimeSpanTimeout(UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_TYPE type, TimeSpan value)
private void SetTimeSpanTimeout(HttpApi.HTTP_TIMEOUT_TYPE type, TimeSpan value)
{
// All timeouts are defined as USHORT in native layer (except MinSendRate, which is ULONG). Make sure that
// timeout value is within range.
@ -217,25 +217,25 @@ namespace Microsoft.Net.Http.Server
private unsafe void SetServerTimeouts(int[] timeouts, uint minSendBytesPerSecond)
{
var timeoutinfo = new UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_LIMIT_INFO();
var timeoutinfo = new HttpApi.HTTP_TIMEOUT_LIMIT_INFO();
timeoutinfo.Flags = UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.HTTP_PROPERTY_FLAG_PRESENT;
timeoutinfo.Flags = HttpApi.HTTP_FLAGS.HTTP_PROPERTY_FLAG_PRESENT;
timeoutinfo.DrainEntityBody =
(ushort)timeouts[(int)UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_TYPE.DrainEntityBody];
(ushort)timeouts[(int)HttpApi.HTTP_TIMEOUT_TYPE.DrainEntityBody];
timeoutinfo.EntityBody =
(ushort)timeouts[(int)UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_TYPE.EntityBody];
(ushort)timeouts[(int)HttpApi.HTTP_TIMEOUT_TYPE.EntityBody];
timeoutinfo.RequestQueue =
(ushort)timeouts[(int)UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_TYPE.RequestQueue];
(ushort)timeouts[(int)HttpApi.HTTP_TIMEOUT_TYPE.RequestQueue];
timeoutinfo.IdleConnection =
(ushort)timeouts[(int)UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_TYPE.IdleConnection];
(ushort)timeouts[(int)HttpApi.HTTP_TIMEOUT_TYPE.IdleConnection];
timeoutinfo.HeaderWait =
(ushort)timeouts[(int)UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_TYPE.HeaderWait];
(ushort)timeouts[(int)HttpApi.HTTP_TIMEOUT_TYPE.HeaderWait];
timeoutinfo.MinSendRate = minSendBytesPerSecond;
var infoptr = new IntPtr(&timeoutinfo);
_server.UrlGroup.SetProperty(
UnsafeNclNativeMethods.HttpApi.HTTP_SERVER_PROPERTY.HttpServerTimeoutsProperty,
HttpApi.HTTP_SERVER_PROPERTY.HttpServerTimeoutsProperty,
infoptr, (uint)TimeoutLimitSize);
}

View File

@ -81,15 +81,15 @@ namespace Microsoft.Net.Http.Server
public WebListener(ILoggerFactory factory)
{
if (!UnsafeNclNativeMethods.HttpApi.Supported)
if (!HttpApi.Supported)
{
throw new PlatformNotSupportedException();
}
_logger = LogHelper.CreateLogger(factory, typeof(WebListener));
Debug.Assert(UnsafeNclNativeMethods.HttpApi.ApiVersion ==
UnsafeNclNativeMethods.HttpApi.HTTP_API_VERSION.Version20, "Invalid Http api version");
Debug.Assert(HttpApi.ApiVersion ==
HttpApi.HTTP_API_VERSION.Version20, "Invalid Http api version");
_state = State.Stopped;
_internalLock = new object();
@ -399,7 +399,7 @@ namespace Microsoft.Net.Http.Server
internal unsafe bool ValidateAuth(NativeRequestContext requestMemory)
{
var requestV2 = (UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_V2*)requestMemory.RequestBlob;
var requestV2 = (HttpApi.HTTP_REQUEST_V2*)requestMemory.RequestBlob;
if (!AuthenticationManager.AllowAnonymous && !AuthenticationManager.CheckAuthenticated(requestV2->pRequestInfo))
{
SendError(requestMemory.RequestBlob->RequestId, HttpStatusCode.Unauthorized,
@ -411,8 +411,8 @@ namespace Microsoft.Net.Http.Server
private unsafe void SendError(ulong requestId, HttpStatusCode httpStatusCode, IList<string> authChallenges)
{
UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE_V2 httpResponse = new UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE_V2();
httpResponse.Response_V1.Version = new UnsafeNclNativeMethods.HttpApi.HTTP_VERSION();
HttpApi.HTTP_RESPONSE_V2 httpResponse = new HttpApi.HTTP_RESPONSE_V2();
httpResponse.Response_V1.Version = new HttpApi.HTTP_VERSION();
httpResponse.Response_V1.Version.MajorVersion = (ushort)1;
httpResponse.Response_V1.Version.MinorVersion = (ushort)1;
@ -425,25 +425,25 @@ namespace Microsoft.Net.Http.Server
{
pinnedHeaders = new List<GCHandle>();
UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE_INFO[] knownHeaderInfo = null;
knownHeaderInfo = new UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE_INFO[1];
HttpApi.HTTP_RESPONSE_INFO[] knownHeaderInfo = null;
knownHeaderInfo = new HttpApi.HTTP_RESPONSE_INFO[1];
gcHandle = GCHandle.Alloc(knownHeaderInfo, GCHandleType.Pinned);
pinnedHeaders.Add(gcHandle);
httpResponse.pResponseInfo = (UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE_INFO*)gcHandle.AddrOfPinnedObject();
httpResponse.pResponseInfo = (HttpApi.HTTP_RESPONSE_INFO*)gcHandle.AddrOfPinnedObject();
knownHeaderInfo[httpResponse.ResponseInfoCount].Type = UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE_INFO_TYPE.HttpResponseInfoTypeMultipleKnownHeaders;
knownHeaderInfo[httpResponse.ResponseInfoCount].Type = HttpApi.HTTP_RESPONSE_INFO_TYPE.HttpResponseInfoTypeMultipleKnownHeaders;
knownHeaderInfo[httpResponse.ResponseInfoCount].Length =
(uint)Marshal.SizeOf<UnsafeNclNativeMethods.HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS>();
(uint)Marshal.SizeOf<HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS>();
UnsafeNclNativeMethods.HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS header = new UnsafeNclNativeMethods.HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS();
HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS header = new HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS();
header.HeaderId = UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE_HEADER_ID.Enum.HttpHeaderWwwAuthenticate;
header.Flags = UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE_INFO_FLAGS.PreserveOrder; // The docs say this is for www-auth only.
header.HeaderId = HttpApi.HTTP_RESPONSE_HEADER_ID.Enum.HttpHeaderWwwAuthenticate;
header.Flags = HttpApi.HTTP_RESPONSE_INFO_FLAGS.PreserveOrder; // The docs say this is for www-auth only.
UnsafeNclNativeMethods.HttpApi.HTTP_KNOWN_HEADER[] nativeHeaderValues = new UnsafeNclNativeMethods.HttpApi.HTTP_KNOWN_HEADER[authChallenges.Count];
HttpApi.HTTP_KNOWN_HEADER[] nativeHeaderValues = new HttpApi.HTTP_KNOWN_HEADER[authChallenges.Count];
gcHandle = GCHandle.Alloc(nativeHeaderValues, GCHandleType.Pinned);
pinnedHeaders.Add(gcHandle);
header.KnownHeaders = (UnsafeNclNativeMethods.HttpApi.HTTP_KNOWN_HEADER*)gcHandle.AddrOfPinnedObject();
header.KnownHeaders = (HttpApi.HTTP_KNOWN_HEADER*)gcHandle.AddrOfPinnedObject();
for (int headerValueIndex = 0; headerValueIndex < authChallenges.Count; headerValueIndex++)
{
@ -460,7 +460,7 @@ namespace Microsoft.Net.Http.Server
// This type is a struct, not an object, so pinning it causes a boxed copy to be created. We can't do that until after all the fields are set.
gcHandle = GCHandle.Alloc(header, GCHandleType.Pinned);
pinnedHeaders.Add(gcHandle);
knownHeaderInfo[0].pInfo = (UnsafeNclNativeMethods.HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS*)gcHandle.AddrOfPinnedObject();
knownHeaderInfo[0].pInfo = (HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS*)gcHandle.AddrOfPinnedObject();
httpResponse.ResponseInfoCount = 1;
}
@ -483,7 +483,7 @@ namespace Microsoft.Net.Http.Server
httpResponse.Response_V1.Headers.UnknownHeaderCount = 0;
statusCode =
UnsafeNclNativeMethods.HttpApi.HttpSendHttpResponse(
HttpApi.HttpSendHttpResponse(
_requestQueue.Handle,
requestId,
0,
@ -499,7 +499,7 @@ namespace Microsoft.Net.Http.Server
if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS)
{
// if we fail to send a 401 something's seriously wrong, abort the request
UnsafeNclNativeMethods.HttpApi.HttpCancelHttpRequest(_requestQueue.Handle, requestId, IntPtr.Zero);
HttpApi.HttpCancelHttpRequest(_requestQueue.Handle, requestId, IntPtr.Zero);
}
}
finally

View File

@ -1,52 +0,0 @@
// Copyright (c) Microsoft Open Technologies, Inc.
// All Rights Reserved
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF
// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR
// NON-INFRINGEMENT.
// See the Apache 2 License for the specific language governing
// permissions and limitations under the License.
//------------------------------------------------------------------------------
// <copyright file="TraceEventType.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if NETSTANDARD1_3
using System;
using System.ComponentModel;
namespace System.Diagnostics
{
internal enum TraceEventType
{
Critical = 0x01,
Error = 0x02,
Warning = 0x04,
Information = 0x08,
Verbose = 0x10,
[EditorBrowsable(EditorBrowsableState.Advanced)]
Start = 0x0100,
[EditorBrowsable(EditorBrowsableState.Advanced)]
Stop = 0x0200,
[EditorBrowsable(EditorBrowsableState.Advanced)]
Suspend = 0x0400,
[EditorBrowsable(EditorBrowsableState.Advanced)]
Resume = 0x0800,
[EditorBrowsable(EditorBrowsableState.Advanced)]
Transfer = 0x1000,
}
}
#endif

View File

@ -1,33 +0,0 @@
// Copyright (c) Microsoft Open Technologies, Inc.
// All Rights Reserved
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF
// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR
// NON-INFRINGEMENT.
// See the Apache 2 License for the specific language governing
// permissions and limitations under the License.
//------------------------------------------------------------------------------
// <copyright file="ExternDll.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if NETSTANDARD1_3
namespace System
{
internal static class ExternDll
{
public const string api_ms_win_core_localization_LIB = "api-ms-win-core-localization-l2-1-0.dll";
}
}
#endif

View File

@ -1,115 +0,0 @@
// Copyright (c) Microsoft Open Technologies, Inc.
// All Rights Reserved
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF
// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR
// NON-INFRINGEMENT.
// See the Apache 2 License for the specific language governing
// permissions and limitations under the License.
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*=============================================================================
**
** Class: ExternalException
**
**
** Purpose: Exception base class for all errors from Interop or Structured
** Exception Handling code.
**
**
=============================================================================*/
#if NETSTANDARD1_3
namespace System.Runtime.InteropServices
{
using System;
using System.Globalization;
// Base exception for COM Interop errors &; Structured Exception Handler
// exceptions.
//
internal class ExternalException : Exception
{
public ExternalException()
{
SetErrorCode(__HResults.E_FAIL);
}
public ExternalException(String message)
: base(message)
{
SetErrorCode(__HResults.E_FAIL);
}
public ExternalException(String message, Exception inner)
: base(message, inner)
{
SetErrorCode(__HResults.E_FAIL);
}
public ExternalException(String message, int errorCode)
: base(message)
{
SetErrorCode(errorCode);
}
private void SetErrorCode(int errorCode)
{
HResult = ErrorCode;
}
private static class __HResults
{
internal const int E_FAIL = unchecked((int)0x80004005);
}
public virtual int ErrorCode
{
get
{
return HResult;
}
}
public override String ToString()
{
String message = Message;
String s;
String _className = GetType().ToString();
s = _className + " (0x" + HResult.ToString("X8", CultureInfo.InvariantCulture) + ")";
if (!(String.IsNullOrEmpty(message)))
{
s = s + ": " + message;
}
Exception _innerException = InnerException;
if (_innerException != null)
{
s = s + " ---> " + _innerException.ToString();
}
if (StackTrace != null)
s += Environment.NewLine + StackTrace;
return s;
}
}
}
#endif

View File

@ -1,44 +0,0 @@
// Copyright (c) Microsoft Open Technologies, Inc.
// All Rights Reserved
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF
// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR
// NON-INFRINGEMENT.
// See the Apache 2 License for the specific language governing
// permissions and limitations under the License.
//------------------------------------------------------------------------------
// <copyright file="SafeNativeMethods.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if NETSTANDARD1_3
using System.Runtime.InteropServices;
using System.Text;
namespace System
{
internal static class SafeNativeMethods
{
public const int
FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100,
FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200,
FORMAT_MESSAGE_FROM_STRING = 0x00000400,
FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000,
FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000;
[DllImport(ExternDll.api_ms_win_core_localization_LIB, CharSet = System.Runtime.InteropServices.CharSet.Unicode, SetLastError = true, BestFitMapping = true)]
public static unsafe extern int FormatMessage(int dwFlags, IntPtr lpSource_mustBeNull, uint dwMessageId,
int dwLanguageId, StringBuilder lpBuffer, int nSize, IntPtr[] arguments);
}
}
#endif