Skip to content

Commit

Permalink
Removed restrictions on adding headers after connection has started
Browse files Browse the repository at this point in the history
  • Loading branch information
abnanda1 committed Sep 19, 2013
1 parent dfd71d9 commit 058b66a
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 42 deletions.
3 changes: 0 additions & 3 deletions src/Microsoft.AspNet.SignalR.Client.WinRT/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@
<data name="Error_ConnectionHasNotBeenEstablished" xml:space="preserve">
<value>The connection has not been established.</value>
</data>
<data name="Error_HeadersCanOnlyBeSetWhenDisconnected" xml:space="preserve">
<value>Request headers cannot be set after the connection has started.</value>
</data>
<data name="Error_IncompatibleProtocolVersion" xml:space="preserve">
<value>You are using a version of the client that isn't compatible with the server. Client version {0}, server version {1}.</value>
</data>
Expand Down
14 changes: 0 additions & 14 deletions src/Microsoft.AspNet.SignalR.Client/HeaderDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public HeaderDictionary(IConnection connection)

public void Add(string key, string value)
{
EnsureConnnectionDisconnected();
_dictionary.Add(key, value);
}

Expand All @@ -33,7 +32,6 @@ public ICollection<string> Keys

public bool Remove(string key)
{
EnsureConnnectionDisconnected();
return _dictionary.Remove(key);
}

Expand All @@ -55,20 +53,17 @@ public string this[string key]
}
set
{
EnsureConnnectionDisconnected();
_dictionary[key] = value;
}
}

public void Add(KeyValuePair<string, string> item)
{
EnsureConnnectionDisconnected();
_dictionary.Add(item);
}

public void Clear()
{
EnsureConnnectionDisconnected();
_dictionary.Clear();
}

Expand All @@ -94,7 +89,6 @@ public bool IsReadOnly

public bool Remove(KeyValuePair<string, string> item)
{
EnsureConnnectionDisconnected();
return _dictionary.Remove(item);
}

Expand All @@ -107,13 +101,5 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return _dictionary.GetEnumerator();
}

private void EnsureConnnectionDisconnected()
{
if (_connection.State != ConnectionState.Disconnected)
{
throw new InvalidOperationException(Resources.Error_HeadersCanOnlyBeSetWhenDisconnected);
}
}
}
}
9 changes: 0 additions & 9 deletions src/Microsoft.AspNet.SignalR.Client/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions src/Microsoft.AspNet.SignalR.Client/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@
<data name="Error_ConnectionHasNotBeenEstablished" xml:space="preserve">
<value>The connection has not been established.</value>
</data>
<data name="Error_HeadersCanOnlyBeSetWhenDisconnected" xml:space="preserve">
<value>Request headers cannot be set after the connection has started.</value>
</data>
<data name="Error_IncompatibleProtocolVersion" xml:space="preserve">
<value>You are using a version of the client that isn't compatible with the server. Client version {0}, server version {1}.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,18 +258,6 @@ public void AsyncStartShouldFailIfTransportStartFails()
Assert.Equal(aggEx.Unwrap(), ex);
Assert.Equal(ConnectionState.Disconnected, connection.State);
}

[Fact]
public void HeaderDictionaryShouldThrowWhenConnectionStateInvalid()
{
var connection = new Client.Connection("http://test");
((Client.IConnection)connection).ChangeState(ConnectionState.Disconnected, ConnectionState.Connecting);

var dictionary = new HeaderDictionary(connection);
var ex = Assert.Throws<InvalidOperationException>(() => dictionary.Add("test-header", "test-header"));

Assert.Equal("Request headers cannot be set after the connection has started.", ex.Message);
}
}

protected virtual void Dispose(bool disposing)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Microsoft.AspNet.SignalR.Tests.Common.Hubs
[HubName("ExamineHeadersHub")]
public class ExamineHeadersHub : Hub
{
public Task Send(string message)
public Task Send()
{
string testHeader = Context.Headers.Get("test-header");
string refererHeader = Context.Headers.Get(HttpRequestHeader.Referer.ToString());
Expand Down

0 comments on commit 058b66a

Please sign in to comment.