Interface for server requests and responses I have an MVC framework I've written. I'm trying to abstract out ASP.NET specific bits as well as make it more testable. Previously, I relied on HttpContext.Current in many places, which proves to be very unfriendly to unit testing. So, I started designing my own minimalistic interface for everything I'd need from there. However, it seems to keep on growing.

/// &lt;summary&gt;
/// This is a very simplified context for server requests and responses
/// It should not cover "everything", but should instead have only what BarelyMVC needs to function
/// As a result, it will usually only have the most commonly used things in it
/// All "get" methods should normally return null if a given name/key doesn't exist
/// &lt;/summary&gt;
public interface IServerContext
{
    /// &lt;summary&gt;
    /// Gets a cookie from the current request
    /// &lt;/summary&gt;
    HttpCookie GetCookie(string name);
    /// &lt;summary&gt;
    /// Sets a cookie to send with the current response
    /// &lt;/summary&gt;
    void SetCookie(HttpCookie cookie);
    /// &lt;summary&gt;
    /// Kills the current request. Kills it with fire! This function should never return(for security purposes)
    /// &lt;/summary&gt;
    void KillIt();
    /// &lt;summary&gt;
    /// Gets the user agent sent by the current request
    /// &lt;/summary&gt;
    string UserAgent{get;}
    /// &lt;summary&gt;
    /// Maps a relative URL path to an absolute path on the host (is this needed?)
    /// &lt;/summary&gt;
    string MapPath(string path);
    /// &lt;summary&gt;
    /// Gets the client's IP address
    /// &lt;/summary&gt;
    string UserIP{get;}
    /// &lt;summary&gt;
    /// Gets an HTTP header by name from the current request
    /// &lt;/summary&gt;
    string GetHeader(string name);
    /// &lt;summary&gt;
    /// Sets an HTTP header to be sent back in the response to the current request
    /// &lt;/summary&gt;
    void SetHeader(string name, string value);
    /// &lt;summary&gt;
    /// Performs a server-side transfer to another URL to service the current request (is this needed?)
    /// Should perform a KillIt() afterwards and never return
    /// &lt;/summary&gt;
    void Transfer(string url);
    /// &lt;summary&gt;
    /// Send a 302 redirect back to the client for the given URL and use KillIt() to end the request
    /// &lt;/summary&gt;
    void Redirect(string url);
    /// &lt;summary&gt;
    /// Gets a generic item from a key/value store associated with the current request only
    /// &lt;/summary&gt;
    object GetItem(string name);
    /// &lt;summary&gt;
    /// Sets a generic item to a key/value store associated with the current request only
    /// &lt;/summary&gt;
    object SetItem(string name, object value);
    /// &lt;summary&gt;
    /// Gets or sets the HTTP status code
    /// &lt;/summary&gt;
    string HttpStatus{get;set;}
    /// &lt;summary&gt;
    /// Gets a TextWriter which can be used to send content back as the response
    /// &lt;/summary&gt;
    TextWriter Writer{get;}
    /// &lt;summary&gt;
    /// Gets a parameter dictionary corresponding to the FORM values passed in by a POST request
    /// &lt;/summary&gt;
    ParameterDictionary Form{get;}
    /// &lt;summary&gt;
    /// Gets the URL of the current request
    /// &lt;/summary&gt;
    Uri RequestUrl{get;}
}


Is this interface already too big? I know I could abstract out the Request and Response parts, but I tend to think it make it a bit harder to use, especially because of my limits on "get" and "set" being stuck to request and response respectively.

What do you think? Refactoring into Request/Response interfaces, or is it OK how it is?
You have to keep in mind that the earlier version of the .NET framework suffered in applying the interface segregation principle. In this case, the HTTP context includes methods associated with the request (ex. URL), the response (ex. HTTP status) and server utility functions (ex. map path).

With that in mind, the interface looks OK and familiar in terms of usage in comparison to the original HttpContext (System.Web) and HttpContextBase (System.Web.Mvc) and should be fine.

One aspect in regards to MVC that is hard to manage is the multiple data sources (query parameters, URL parameters, HTTP post Form values, routing parameters, session and the per request key/value store (HttpContext.Current.Items)) - perhaps it would be worthwhile to create an intermediary to manage these.