Skip to content

Commit 2e25324

Browse files
committed
Merge branch 'master' of https://github.com/restsharp/RestSharp
2 parents 98aedaa + 3f2e43c commit 2e25324

File tree

84 files changed

+4987
-44682
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+4987
-44682
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
packages
12

23
#ignore thumbnails created by windows
34
Thumbs.db

.nuget/NuGet.Config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<solution>
4+
<add key="disableSourceControlIntegration" value="true" />
5+
</solution>
6+
</configuration>

.nuget/NuGet.exe

554 KB
Binary file not shown.

.nuget/NuGet.targets

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
5+
6+
<!-- Windows specific commands -->
7+
<NuGetToolsPath Condition=" '$(OS)' == 'Windows_NT'">$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
8+
<PackagesConfig Condition=" '$(OS)' == 'Windows_NT'">$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
9+
<PackagesDir Condition=" '$(OS)' == 'Windows_NT'">$([System.IO.Path]::Combine($(SolutionDir), "packages"))</PackagesDir>
10+
11+
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
12+
<NuGetToolsPath Condition=" '$(OS)' != 'Windows_NT'">$(SolutionDir).nuget</NuGetToolsPath>
13+
<PackagesConfig Condition=" '$(OS)' != 'Windows_NT' ">packages.config</PackagesConfig>
14+
<PackagesDir Condition=" '$(OS)' != 'Windows_NT'">$(SolutionDir)packages</PackagesDir>
15+
16+
<!-- NuGet command -->
17+
<NuGetExePath>$(NuGetToolsPath)\nuget.exe</NuGetExePath>
18+
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
19+
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>
20+
21+
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
22+
23+
<!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config -->
24+
<PackageSources>""</PackageSources>
25+
26+
<!-- Enable the restore command to run before builds -->
27+
<RestorePackages Condition="$(RestorePackages) == ''">false</RestorePackages>
28+
29+
<!-- Property that enables building a package from a project -->
30+
<BuildPackage Condition="$(BuildPackage) == ''">false</BuildPackage>
31+
32+
<!-- Commands -->
33+
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source $(PackageSources) -o "$(PackagesDir)"</RestoreCommand>
34+
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand>
35+
36+
<!-- Make the build depend on restore packages -->
37+
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
38+
RestorePackages;
39+
$(BuildDependsOn);
40+
</BuildDependsOn>
41+
42+
<!-- Make the build depend on restore packages -->
43+
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
44+
$(BuildDependsOn);
45+
BuildPackage;
46+
</BuildDependsOn>
47+
</PropertyGroup>
48+
49+
<Target Name="CheckPrerequisites">
50+
<!-- Raise an error if we're unable to locate nuget.exe -->
51+
<Error Condition="!Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
52+
</Target>
53+
54+
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
55+
<Exec Command="$(RestoreCommand)"
56+
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
57+
58+
<Exec Command="$(RestoreCommand)"
59+
LogStandardErrorAsError="true"
60+
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
61+
</Target>
62+
63+
<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
64+
<Exec Command="$(BuildCommand)"
65+
Condition=" '$(OS)' != 'Windows_NT' " />
66+
67+
<Exec Command="$(BuildCommand)"
68+
LogStandardErrorAsError="true"
69+
Condition=" '$(OS)' == 'Windows_NT' " />
70+
</Target>
71+
</Project>

RestSharp.IntegrationTests/RestSharp.IntegrationTests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
<OldToolsVersion>3.5</OldToolsVersion>
1818
<UpgradeBackupLocation />
1919
<TargetFrameworkProfile />
20+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
21+
<RestorePackages>true</RestorePackages>
2022
</PropertyGroup>
2123
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2224
<DebugSymbols>true</DebugSymbols>
@@ -85,6 +87,7 @@
8587
</ProjectReference>
8688
</ItemGroup>
8789
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
90+
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
8891
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
8992
Other similar extension points exist, see Microsoft.Common.targets.
9093
<Target Name="BeforeBuild">

RestSharp.IntegrationTests/StatusCodeTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ void UrlToStatusCodeHandler(HttpListenerContext obj)
2626
obj.Response.StatusCode = int.Parse(obj.Request.Url.Segments.Last());
2727
}
2828

29+
/// <summary>
30+
/// Success of this test is based largely on the behavior of your current DNS.
31+
/// For example, if you're using OpenDNS this will test will fail; ResponseStatus will be Completed.
32+
/// </summary>
2933
[Fact]
3034
public void Handles_Non_Existent_Domain()
3135
{

RestSharp.IntegrationTests/oAuth1Tests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,5 +171,20 @@ public void Properly_Encodes_Parameter_Names()
171171

172172
Assert.Equal("name%5Bfirst%5D", sortedParams[0].Name);
173173
}
174+
175+
[Fact]
176+
public void Use_RFC_3986_Encoding_For_Auth_Signature_Base()
177+
{
178+
// reserved characters for 2396 and 3986
179+
var reserved2396Characters = new[] { ";", "/", "?", ":", "@", "&", "=", "+", "$", "," }; // http://www.ietf.org/rfc/rfc2396.txt
180+
var additionalReserved3986Characters = new[] { "!", "*", "'", "(", ")" }; // http://www.ietf.org/rfc/rfc3986.txt
181+
var reservedCharacterString = string.Join( string.Empty, reserved2396Characters.Union( additionalReserved3986Characters ) );
182+
183+
// act
184+
var escapedString = OAuthTools.UrlEncodeRelaxed( reservedCharacterString );
185+
186+
// assert
187+
Assert.Equal( "%3B%2F%3F%3A%40%26%3D%2B%24%2C%21%2A%27%28%29", escapedString );
188+
}
174189
}
175190
}

RestSharp.MonoDroid/RestSharp.MonoDroid.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@
9696
<Compile Include="..\RestSharp\RestResponse.cs">
9797
<Link>RestResponse.cs</Link>
9898
</Compile>
99+
<Compile Include="..\RestSharp\SimpleJson.cs">
100+
<Link>SimpleJson.cs</Link>
101+
</Compile>
99102
<Compile Include="..\RestSharp\Validation\Require.cs">
100103
<Link>Validation\Require.cs</Link>
101104
</Compile>
@@ -126,6 +129,9 @@
126129
<Compile Include="..\RestSharp\Extensions\XmlExtensions.cs">
127130
<Link>Extensions\XmlExtensions.cs</Link>
128131
</Compile>
132+
<Compile Include="..\RestSharp\Extensions\ResponseExtensions.cs">
133+
<Link>Extensions\ResponseExtensions.cs</Link>
134+
</Compile>
129135
<Compile Include="..\RestSharp\Deserializers\DeserializeAsAttribute.cs">
130136
<Link>Deserializers\DeserializeAsAttribute.cs</Link>
131137
</Compile>

RestSharp.MonoTouch/RestSharp.MonoTouch.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@
143143
<Compile Include="..\RestSharp\RestResponse.cs">
144144
<Link>RestResponse.cs</Link>
145145
</Compile>
146+
<Compile Include="..\RestSharp\SimpleJson.cs">
147+
<Link>SimpleJson.cs</Link>
148+
</Compile>
146149
<Compile Include="..\RestSharp\Validation\Require.cs">
147150
<Link>Validation\Require.cs</Link>
148151
</Compile>
@@ -158,6 +161,9 @@
158161
<Compile Include="..\RestSharp\Serializers\SerializeAsAttribute.cs">
159162
<Link>Serializers\SerializeAsAttribute.cs</Link>
160163
</Compile>
164+
<Compile Include="..\RestSharp\Extensions\ResponseExtensions.cs">
165+
<Link>Extensions\ResponseExtensions.cs</Link>
166+
</Compile>
161167
<Compile Include="..\RestSharp\Serializers\XmlSerializer.cs">
162168
<Link>Serializers\XmlSerializer.cs</Link>
163169
</Compile>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace RestSharp
7+
{
8+
public static partial class RestClientExtensions
9+
{
10+
public static RestResponse<dynamic> ExecuteDynamic(this IRestClient client, IRestRequest request)
11+
{
12+
var response = client.Execute(request);
13+
14+
var generic = (RestResponse<dynamic>)response;
15+
dynamic content = SimpleJson.DeserializeObject(response.Content);
16+
generic.Data = content;
17+
18+
return generic;
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)