本文整理汇总了C#中WebSocketSharp.Net.HttpListenerContext类的典型用法代码示例。如果您正苦于以下问题:C# HttpListenerContext类的具体用法?C# HttpListenerContext怎么用?C# HttpListenerContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpListenerContext类属于WebSocketSharp.Net命名空间,在下文中一共展示了HttpListenerContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HttpListenerRequest
internal HttpListenerRequest(HttpListenerContext context)
{
_context = context;
_contentLength = -1;
_headers = new WebHeaderCollection ();
_identifier = Guid.NewGuid ();
}
示例2: ChunkedRequestStream
public ChunkedRequestStream (
HttpListenerContext context, Stream stream, byte [] buffer, int offset, int length)
: base (stream, buffer, offset, length)
{
_context = context;
_decoder = new ChunkStream ((WebHeaderCollection) context.Request.Headers);
}
示例3: ChunkedRequestStream
internal ChunkedRequestStream (
Stream stream, byte[] buffer, int offset, int count, HttpListenerContext context)
: base (stream, buffer, offset, count)
{
_context = context;
_decoder = new ChunkStream ((WebHeaderCollection) context.Request.Headers);
}
示例4: ProcessRequest
//This gets called when the listener receives a request
private void ProcessRequest (HttpListenerContext context)
{
var getContext = Task.Factory.FromAsync<HttpListenerContext>(_listener.BeginGetContext, _listener.EndGetContext, null);
getContext.ContinueWith(t => ProcessRequest(t.Result));
_router.HandleRequest(ContextGenerator(context));
}
示例5: ChunkedInputStream
public ChunkedInputStream(
HttpListenerContext context, Stream stream, byte [] buffer, int offset, int length)
: base(stream, buffer, offset, length)
{
this.context = context;
WebHeaderCollection coll = (WebHeaderCollection) context.Request.Headers;
decoder = new ChunkStream (coll);
}
示例6: HttpListenerResponse
internal HttpListenerResponse (HttpListenerContext context)
{
_context = context;
_keepAlive = true;
_statusCode = 200;
_statusDescription = "OK";
_version = HttpVersion.Version11;
}
示例7: InitTask
private void InitTask(HttpListenerContext context)
{
try
{
var task = this.ProcessRequestAsync(context);
task.ContinueWith(x => HandleError(x.Exception, context), TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.AttachedToParent);
if (task.Status == TaskStatus.Created)
{
task.RunSynchronously();
}
}
catch (Exception ex)
{
HandleError(ex, context);
}
}
示例8: ProcessRequestAsync
private Task ProcessRequestAsync(HttpListenerContext context)
{
var request = context.Request;
LogHttpRequest(request);
if (request.IsWebSocketRequest)
{
ProcessWebSocketRequest(context);
return Task.FromResult(true);
}
if (string.IsNullOrEmpty(context.Request.RawUrl))
return ((object)null).AsTaskResult();
var httpReq = GetRequest(context);
return RequestHandler(httpReq, request.Url);
}
示例9: Complete
internal void Complete (HttpListenerContext context)
{
Complete (context, false);
}
示例10: CreateServerStream
internal static WsStream CreateServerStream(HttpListenerContext context)
{
var conn = context.Connection;
return new WsStream (conn.Stream, conn.IsSecure);
}
示例11: Complete
internal void Complete(HttpListenerContext context, bool syncCompleted)
{
var listener = context.Listener;
var schm = listener.SelectAuthenticationScheme (context);
if (schm != AuthenticationSchemes.Anonymous &&
!authenticate (context, schm, listener.Realm, listener.UserCredentialsFinder)) {
listener.BeginGetContext (this);
return;
}
_context = context;
_syncCompleted = syncCompleted;
lock (_sync)
complete (this);
}
示例12: CleanupContextRegistry
void CleanupContextRegistry()
{
lock (((ICollection)registry).SyncRoot) {
if (registry.Count == 0)
return;
// Need to copy this since closing will call UnregisterContext
ICollection keys = registry.Keys;
var all = new HttpListenerContext [keys.Count];
keys.CopyTo (all, 0);
registry.Clear ();
for (int i = all.Length - 1; i >= 0; i--)
all [i].Connection.Close (true);
}
}
示例13: SelectAuthenticationScheme
internal AuthenticationSchemes SelectAuthenticationScheme(HttpListenerContext context)
{
if (AuthenticationSchemeSelectorDelegate != null)
return AuthenticationSchemeSelectorDelegate (context.Request);
else
return auth_schemes;
}
示例14: UnregisterContext
internal void UnregisterContext (HttpListenerContext context)
{
lock (_ctxRegistrySync)
_ctxRegistry.Remove (context);
lock (_ctxQueueSync) {
var idx = _ctxQueue.IndexOf (context);
if (idx >= 0)
_ctxQueue.RemoveAt (idx);
}
}
示例15: RegisterContext
internal void RegisterContext(HttpListenerContext context)
{
lock (((ICollection)registry).SyncRoot)
registry [context] = context;
ListenerAsyncResult ares = null;
lock (((ICollection)wait_queue).SyncRoot) {
if (wait_queue.Count == 0) {
lock (((ICollection)ctx_queue).SyncRoot)
ctx_queue.Add (context);
} else {
ares = wait_queue [0];
wait_queue.RemoveAt (0);
}
}
if (ares != null)
ares.Complete (context);
}