SignalR/SignalR — Issue #205: Allow setting of Cookies on HttpWebRequest in SignalR.Client.Connection
Author: edchapel
Created: 2012-02-22 17:41:16+00:00
State: open

We are using Cookies to store some client information that must be sent in each request to the hub. At the moment, we've copied a number of files to change `SignalR.Client.Connection.PrepareRequest` from `internal` to `public`. We looked at issue #27 but `ICredentials` doesn't work for us. Our implementation overrides the virtual:

private CookieCollection _cookies;

public override void PrepareRequest(HttpWebRequest request)
{
if (_cookies != null)
{
var cookieContainer = request.CookieContainer
?? (request.CookieContainer = new CookieContainer());
cookieContainer.Add(_cookies);
}

base.PrepareRequest(request);
}

Of course, there are a number of ways this could be done. We'd like to send a pull request but need your design opinion. Would you prefer:

1) Change `PrepareRequest` to be `public`
2) Add `CookieContainer { get; }` to `Connection` and change `PrepareRequest` to add it to the request as it does the `ICredentials`