Example #1
0
 /// <summary>
 /// Handle HTTP request.
 /// </summary>
 /// <param name="result"></param>
 private void HttpRequest(IAsyncResult result)
 {
     try
     {
         HttpListener        listener = (HttpListener)result.AsyncState;
         HttpListenerContext context  = listener.EndGetContext(result);
         OnHttpRequest?.Invoke(context);
     }
     catch
     {
         // TODO: Can't handle request.
     }
 }
Example #2
0
        private static void mk_http_request(IntPtr mk_parser, IntPtr mk_http_response_invoker, ref int consumed, IntPtr mk_sock_info)
        {
            if (OnHttpRequest == null)
            {
                return;
            }
            consumed = 1;
            var httpBody = OnHttpRequest.Invoke(new HttpRequest(mk_parser, mk_sock_info));

            if (httpBody == null)
            {
                consumed = 0;
                return;
            }
            httpBody.GetHttpHeader();
            PInvoke.ZLMediaKitMethod.mk_http_response_invoker_do(mk_http_response_invoker, $"{(int)httpBody.HttpStatusCode} {httpBody.HttpStatusCode}", ref httpBody.headerIntptr, httpBody.GetHttpBody());
        }