using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; namespace Nuclex.Networking.Gallery3.Requests { /// Request that can be sent to a server /// /// /// The destination of the request and any authentication options are /// set at construction time by the factory for the request. This /// interface merely services to customize the request for its purpose. /// /// /// By using an interface to construct requests, it is easy to mock /// any request being constructed by the Gallery 3 connector in order /// to verify the code in unit tests without relying on a server. /// /// public interface IRequest { /// HTTP request method /// /// Can be "GET", "POST", "PUT" or "DELETE". Not all server support /// the "PUT" and "DELETE" methods, so these methods are passed to /// Gallery 3 as a "POST" request with a custom header: /// "X-Gallery-Request-Method". /// string Method { get; set; } /// The type/format of the content in a "POST" request /// /// Should be "application/x-www-form-urlencoded" for any request. /// string ContentType { get; set; } /// Adds a custom header field to the request /// Name of the header that will be added /// Value that will be assigned to the header field void AddHeader(string name, string value); /// Attaches content to a POST request /// Data that will be attached to the request as content void AttachContent(byte[] data); /// Sends the request to the server and returns the response /// A JSON reader through which the response can be read ResponseType GetJsonResponse(); } } // namespace Nuclex.Networking.Gallery3.Requests