Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 8f527bf

Browse files
committed
Added native support for the HTTP PATCH verb.
1 parent ec22edc commit 8f527bf

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/System.Net.Http/src/System/Net/Http/HttpClient.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,30 @@ public Task<HttpResponseMessage> PutAsync(Uri requestUri, HttpContent content,
351351
return SendAsync(request, cancellationToken);
352352
}
353353

354+
public Task<HttpResponseMessage> PatchAsync(string requestUri, HttpContent content)
355+
{
356+
return PatchAsync(CreateUri(requestUri), content);
357+
}
358+
359+
public Task<HttpResponseMessage> PatchAsync(Uri requestUri, HttpContent content)
360+
{
361+
return PatchAsync(requestUri, content, CancellationToken.None);
362+
}
363+
364+
public Task<HttpResponseMessage> PatchAsync(string requestUri, HttpContent content,
365+
CancellationToken cancellationToken)
366+
{
367+
return PatchAsync(CreateUri(requestUri), content, cancellationToken);
368+
}
369+
370+
public Task<HttpResponseMessage> PatchAsync(Uri requestUri, HttpContent content,
371+
CancellationToken cancellationToken)
372+
{
373+
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Patch, requestUri);
374+
request.Content = content;
375+
return SendAsync(request, cancellationToken);
376+
}
377+
354378
public Task<HttpResponseMessage> DeleteAsync(string requestUri)
355379
{
356380
return DeleteAsync(CreateUri(requestUri));

src/System.Net.Http/src/System/Net/Http/HttpMethod.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class HttpMethod : IEquatable<HttpMethod>
1818
private static readonly HttpMethod s_headMethod = new HttpMethod("HEAD");
1919
private static readonly HttpMethod s_optionsMethod = new HttpMethod("OPTIONS");
2020
private static readonly HttpMethod s_traceMethod = new HttpMethod("TRACE");
21+
private static readonly HttpMethod s_patchMethod = new HttpMethod("PATCH");
2122

2223
// Don't expose CONNECT as static property, since it's used by the transport to connect to a proxy.
2324
// CONNECT is not used by users directly.
@@ -57,6 +58,11 @@ public static HttpMethod Trace
5758
get { return s_traceMethod; }
5859
}
5960

61+
public static HttpMethod Patch
62+
{
63+
get { return s_patchMethod; }
64+
}
65+
6066
public string Method
6167
{
6268
get { return _method; }

0 commit comments

Comments
 (0)