Support http verb Patch.
This commit is contained in:
Родитель
b8545644d5
Коммит
b6ebef8f46
|
@ -86,6 +86,14 @@ namespace ARMClient.Authentication.Utilities
|
|||
{
|
||||
response = await client.PutAsync(uri, content);
|
||||
}
|
||||
else if (String.Equals(verb, "patch", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
using (var message = new HttpRequestMessage(new HttpMethod("PATCH"), uri))
|
||||
{
|
||||
message.Content = content;
|
||||
response = await client.SendAsync(message).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException(String.Format("Invalid http verb {0}!", verb));
|
||||
|
|
|
@ -116,7 +116,8 @@ namespace ARMClient
|
|||
else if (String.Equals(verb, "get", StringComparison.OrdinalIgnoreCase)
|
||||
|| String.Equals(verb, "delete", StringComparison.OrdinalIgnoreCase)
|
||||
|| String.Equals(verb, "put", StringComparison.OrdinalIgnoreCase)
|
||||
|| String.Equals(verb, "post", StringComparison.OrdinalIgnoreCase))
|
||||
|| String.Equals(verb, "post", StringComparison.OrdinalIgnoreCase)
|
||||
|| String.Equals(verb, "patch", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var path = _parameters.Get(1, keyName: "url");
|
||||
var verbose = _parameters.Get("-verbose", requires: false) != null || Utils.GetDefaultVerbose();
|
||||
|
|
|
@ -101,6 +101,13 @@ namespace ARMClient.Library
|
|||
return await httpResponse.Content.ReadAsAsync<T>().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<T> PatchAsync<T>(params object[] args)
|
||||
{
|
||||
var httpResponse = await HttpInvoke("Patch", args).ConfigureAwait(false);
|
||||
httpResponse.EnsureSuccessStatusCode();
|
||||
return await httpResponse.Content.ReadAsAsync<T>().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<T> DeleteAsync<T>()
|
||||
{
|
||||
var httpResponse = await HttpInvoke("Delete", Enumerable.Empty<object>().ToArray()).ConfigureAwait(false);
|
||||
|
@ -182,6 +189,14 @@ namespace ARMClient.Library
|
|||
{
|
||||
response = await client.PutAsync(uri, new StringContent(payload ?? String.Empty, Encoding.UTF8, Constants.JsonContentType)).ConfigureAwait(false);
|
||||
}
|
||||
else if (String.Equals(verb, "patch", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
using (var message = new HttpRequestMessage(new HttpMethod("PATCH"), uri))
|
||||
{
|
||||
message.Content = new StringContent(payload ?? String.Empty, Encoding.UTF8, Constants.JsonContentType);
|
||||
response = await client.SendAsync(message).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException(String.Format("Invalid http verb '{0}'!", verb));
|
||||
|
|
Загрузка…
Ссылка в новой задаче