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); }
/// <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; } }
internal RequestHeadersDictionary(Mono.Net.HttpListenerRequest request) : base() { _request = request; }
internal AdvancedHttpRequest(Mono.Net.HttpListenerRequest request) { _request = request; }
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; }
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); }