Skip to content

Commit 1c72fa9

Browse files
Merge pull request restsharp#1049 from smietanka/smietanka-branch
Added new request method: COPY
2 parents fbd9b05 + b2493c6 commit 1c72fa9

File tree

6 files changed

+45
-1
lines changed

6 files changed

+45
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The `RestSharp` package is now signed so there is no need to install `RestSharp.
2020
* Supports custom serialization and deserialization via ISerializer and IDeserializer
2121
* Fuzzy element name matching ('product_id' in XML/JSON will match C# property named 'ProductId')
2222
* Automatic detection of type of content returned
23-
* GET, POST, PUT, PATCH, HEAD, OPTIONS, DELETE supported
23+
* GET, POST, PUT, PATCH, HEAD, OPTIONS, DELETE, COPY supported
2424
* Other non-standard HTTP methods also supported
2525
* OAuth 1, OAuth 2, Basic, NTLM and Parameter-based Authenticators included
2626
* Supports custom authentication schemes via IAuthenticator

RestSharp.IntegrationTests/AsyncRequestBodyTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,26 @@ public void Can_Be_Added_To_PATCH_Request()
177177
AssertHasRequestBody(contentType, bodyData);
178178
}
179179

180+
[Test]
181+
public void Can_Be_Added_To_COPY_Request()
182+
{
183+
const Method httpMethod = Method.COPY;
184+
185+
RestRequest request = new RestRequest(RequestBodyCapturer.Resource, httpMethod);
186+
187+
const string contentType = "text/plain";
188+
const string bodyData = "abc123 foo bar baz BING!";
189+
190+
request.AddParameter(contentType, bodyData, ParameterType.RequestBody);
191+
192+
ManualResetEvent resetEvent = new ManualResetEvent(false);
193+
194+
_client.ExecuteAsync(request, response => resetEvent.Set());
195+
resetEvent.WaitOne();
196+
197+
AssertHasRequestBody(contentType, bodyData);
198+
}
199+
180200
private static void AssertHasNoRequestBody()
181201
{
182202
Assert.Null(RequestBodyCapturer.CapturedContentType);

RestSharp.IntegrationTests/RequestBodyTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,27 @@ public void Can_Be_Added_To_PATCH_Request()
173173
}
174174
}
175175

176+
[Test]
177+
public void Can_Be_Added_To_COPY_Request()
178+
{
179+
const Method httpMethod = Method.COPY;
180+
181+
using (SimpleServer.Create(BASE_URL, Handlers.Generic<RequestBodyCapturer>()))
182+
{
183+
RestClient client = new RestClient(BASE_URL);
184+
RestRequest request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
185+
186+
const string contentType = "text/plain";
187+
const string bodyData = "abc123 foo bar baz BING!";
188+
189+
request.AddParameter(contentType, bodyData, ParameterType.RequestBody);
190+
191+
client.Execute(request);
192+
193+
AssertHasRequestBody(contentType, bodyData);
194+
}
195+
}
196+
176197
private static void AssertHasNoRequestBody()
177198
{
178199
Assert.Null(RequestBodyCapturer.CapturedContentType);

RestSharp/Enum.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public enum Method
5151
OPTIONS,
5252
PATCH,
5353
MERGE,
54+
COPY
5455
}
5556

5657
/// <summary>

RestSharp/RestClient.Async.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public virtual RestRequestAsyncHandle ExecuteAsync(IRestRequest request,
3737

3838
switch (request.Method)
3939
{
40+
case Method.COPY:
4041
case Method.MERGE:
4142
case Method.PATCH:
4243
case Method.POST:

RestSharp/RestClient.Sync.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public virtual IRestResponse Execute(IRestRequest request)
4141

4242
switch (request.Method)
4343
{
44+
case Method.COPY:
4445
case Method.POST:
4546
case Method.PUT:
4647
case Method.PATCH:

0 commit comments

Comments
 (0)