using System; using System.Collections.Specialized; using System.IO; using OSHttpServer.Exceptions; namespace OSHttpServer { /// /// Contains server side HTTP request information. /// public interface IHttpRequest : ICloneable { /// /// Gets kind of types accepted by the client. /// string[] AcceptTypes { get; } uint ID {get; } /// /// Gets or sets body stream. /// Stream Body { get; set; } /// /// Gets whether the body is complete. /// bool BodyIsComplete { get; } /// /// Gets or sets kind of connection used for the session. /// ConnectionType Connection { get; set; } IHttpClientContext Context { get; } /// /// Gets or sets number of bytes in the body. /// int ContentLength { get; set; } /// /// Gets cookies that was sent with the request. /// RequestCookies Cookies { get; } /// /// Gets form parameters. /// //HttpForm Form { get; } /// /// Gets headers sent by the client. /// NameValueCollection Headers { get; } /// /// Gets or sets version of HTTP protocol that's used. /// /// /// Probably or . /// /// string HttpVersion { get; set; } /// /// Gets whether the request was made by Ajax (Asynchronous JavaScript) /// bool IsAjax { get; } /// /// Gets or sets requested method. /// /// /// Will always be in upper case. /// /// string Method { get; set; } /// /// Gets parameter from or . /// HttpParam Param { get; } /// /// Gets variables sent in the query string /// HttpInput QueryString { get; } /// /// Gets or sets requested URI. /// Uri Uri { get; set; } /// /// Gets URI absolute path divided into parts. /// /// /// // URI is: http://gauffin.com/code/tiny/ /// Console.WriteLine(request.UriParts[0]); // result: code /// Console.WriteLine(request.UriParts[1]); // result: tiny /// /// /// If you're using controllers than the first part is controller name, /// the second part is method name and the third part is Id property. /// /// string[] UriParts { get; } /// /// Gets or sets path and query. /// /// /// /// Are only used during request parsing. Cannot be set after "Host" header have been /// added. /// string UriPath { get; set; } /// /// Called during parsing of a . /// /// Name of the header, should not be URL encoded /// Value of the header, should not be URL encoded /// If a header is incorrect. void AddHeader(string name, string value); /// /// Add bytes to the body /// /// buffer to read bytes from /// where to start read /// number of bytes to read /// Number of bytes actually read (same as length unless we got all body bytes). /// If body is not writable /// bytes is null. /// offset is out of range. int AddToBody(byte[] bytes, int offset, int length); /// /// Clear everything in the request /// void Clear(); /// /// Decode body into a form. /// /// A list with form decoders. /// If body contents is not valid for the chosen decoder. /// If body is still being transferred. //void DecodeBody(FormDecoderProvider providers); /// /// Sets the cookies. /// /// The cookies. void SetCookies(RequestCookies cookies); /// /// Create a response object. /// /// Context for the connected client. /// A new . //IHttpResponse CreateResponse(IHttpClientContext context); } }