Skip to content

Commit c963c78

Browse files
author
Michael Hallett
committed
Added the additional test cases for PR #505 and excluded Silverlight from the change in RestRequest.
1 parent aeb665a commit c963c78

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

RestSharp.Tests/RestRequestTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public void Cannot_Set_Empty_Host_Header()
4141
[InlineData(".")]
4242
[InlineData(".:2345")]
4343
[InlineData(":5678")]
44+
[InlineData("")]
45+
[InlineData("foo:bar:baz")]
4446
public void Cannot_Set_Invalid_Host_Header(string value)
4547
{
4648
var request = new RestRequest();

RestSharp/RestRequest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,15 @@ public IRestRequest AddParameter (string name, object value, ParameterType type)
357357
/// <returns></returns>
358358
public IRestRequest AddHeader (string name, string value)
359359
{
360+
#if !SILVERLIGHT
360361
const string portSplit = @":\d+";
361362
Func<string, bool> invalidHost = host => Uri.CheckHostName(Regex.Split(host, portSplit)[0]) == UriHostNameType.Unknown;
363+
362364
if (name == "Host" && invalidHost(value))
363365
{
364366
throw new ArgumentException("The specified value is not a valid Host header string.", "value");
365367
}
368+
#endif
366369
return AddParameter(name, value, ParameterType.HttpHeader);
367370
}
368371

0 commit comments

Comments
 (0)