Skip to content

Commit

Permalink
Added a BuildCustomQueryString function to the TransportHelper
Browse files Browse the repository at this point in the history
- Verified its functionality against the test project that was provided in #1556
- Need to add some tests to verify the functionality
#1556
  • Loading branch information
NTaylorMullen committed Feb 22, 2013
1 parent 70027b6 commit 9ed4ae0
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions src/Microsoft.AspNet.SignalR.Client/Transports/TransportHelper.cs
Expand Up @@ -33,8 +33,8 @@ public static Task<NegotiationResponse> GetNegotiationResponse(this IHttpClient
#else
string negotiateUrl = connection.Url + "negotiate";
#endif


negotiateUrl += BuildCustomQueryString(connection, negotiateUrl);
return httpClient.Get(negotiateUrl, connection.PrepareRequest).Then(response =>
{
string raw = response.ReadAsString();
Expand Down Expand Up @@ -76,20 +76,40 @@ public static string GetReceiveQueryString(IConnection connection, string data,
qsBuilder.Append("&connectionData=" + data);
}

string customQuery = connection.QueryString;
qsBuilder.Append(BuildCustomQueryString(connection, qsBuilder.ToString()));

if (!String.IsNullOrEmpty(customQuery))
{
qsBuilder.Append("&")
.Append(customQuery);
}
string customQuery = connection.QueryString;

#if SILVERLIGHT || WINDOWS_PHONE
qsBuilder.Append("&").Append(GetNoCacheUrlParam());
#endif
return qsBuilder.ToString();
}

public static string BuildCustomQueryString(IConnection connection, string baseUrl)
{
if (connection == null)
{
throw new ArgumentNullException("connection");
}

string appender = "?",
customQuery = connection.QueryString,
qs = "";

if (!String.IsNullOrEmpty(customQuery))
{
if (baseUrl.Contains("?"))
{
appender = "&";
}

qs += appender + customQuery;
}

return qs;
}

[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "This is called internally.")]
[SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", Justification = "This is called internally.")]
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "The client receives the exception in the OnError callback.")]
Expand Down

0 comments on commit 9ed4ae0

Please sign in to comment.