예제 #1
0
 protected internal HttpRequest(Mono.Net.HttpListenerRequest request)
 {
     Request  = request;
     PathInfo = RawUrl.Split(new[] { '?' }, 2)[0];
     Name     = $"{HttpMethod} {PathInfo}";
     Id       = Guid.NewGuid().Truncate();
     Advanced = new AdvancedHttpRequest(request);
 }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OwinHttpListenerRequest"/> class.
        /// Uses the given request object to populate the OWIN standard keys in the environment IDictionary.
        /// Most values are copied so that they can be mutable, but the headers collection is only wrapped.
        /// </summary>
        internal OwinHttpListenerRequest(HttpListenerRequest request, string basePath, string path, string query, CallEnvironment environment)
        {
            Contract.Requires(request != null);

            _request = request;
            _environment = environment;

            _environment.RequestProtocol = GetProtocol(request.ProtocolVersion);
            _environment.RequestScheme = request.Url.Scheme;
            _environment.RequestMethod = request.HttpMethod;
            _environment.RequestPathBase = basePath;
            _environment.RequestPath = path;
            _environment.RequestQueryString = query;

            _environment.RequestHeaders = new RequestHeadersDictionary(request);

            if (_request.IsSecureConnection)
            {
                // TODO: Add delay sync load for folks that directly access the client cert key
                _environment.LoadClientCert = (Func<Task>)LoadClientCertAsync;
            }
        }
예제 #3
0
 internal RequestHeadersDictionary(Mono.Net.HttpListenerRequest request)
     : base()
 {
     _request = request;
 }
예제 #4
0
 internal AdvancedHttpRequest(Mono.Net.HttpListenerRequest request)
 {
     _request = request;
 }
예제 #5
0
        public static List<string> DumpHTTPRequest(HttpListenerRequest req)
        {
            List<string> rv = new List<string>();

            rv.Add(req.ProtocolVersion.ToString());
            rv.Add(req.HttpMethod);
            rv.Add(req.Url.ToString());
            rv.Add(req.RemoteEndPoint.ToString());
            rv.Add("Headers");
            foreach (var key in req.Headers.AllKeys)
                rv.Add(req.Headers[key]);
            rv.Add("Cookies");
            foreach (var cookie in req.Cookies)
            {
                rv.Add(cookie.ToString());
            }
            rv.Add("Body");
            var post = GetRequestPostData(req);
            if (post != null)
                rv.Add(post);
            return rv;
        }
예제 #6
0
 public static string GetRequestPostData(HttpListenerRequest request)
 {
     if (!request.HasEntityBody)
     {
         return null;
     }
     using (System.IO.Stream body = request.InputStream) // here we have data
     {
         using (System.IO.StreamReader reader = new System.IO.StreamReader(body, request.ContentEncoding))
         {
             return reader.ReadToEnd();
         }
     }
 }
 internal HttpListenerContext(HttpConnection cnc)
 {
     this.cnc = cnc;
     request  = new HttpListenerRequest(this);
     response = new HttpListenerResponse(this);
 }