aboutsummaryrefslogtreecommitdiff
path: root/Timeline.Tests/Helpers/HttpClientExtensions.cs
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-10-31 00:56:46 +0800
committer杨宇千 <crupest@outlook.com>2019-10-31 00:56:46 +0800
commit2198ad257a2c049f3601a6f95b8906c5be8b27d5 (patch)
tree7d034bb824b50d892136c6f1225a15e8baa30741 /Timeline.Tests/Helpers/HttpClientExtensions.cs
parentfbaa8cab95a91b887bbd2d108d27c5abb38e4e29 (diff)
downloadtimeline-2198ad257a2c049f3601a6f95b8906c5be8b27d5.tar.gz
timeline-2198ad257a2c049f3601a6f95b8906c5be8b27d5.tar.bz2
timeline-2198ad257a2c049f3601a6f95b8906c5be8b27d5.zip
Continue to construct feature and tests.
Diffstat (limited to 'Timeline.Tests/Helpers/HttpClientExtensions.cs')
-rw-r--r--Timeline.Tests/Helpers/HttpClientExtensions.cs12
1 files changed, 12 insertions, 0 deletions
diff --git a/Timeline.Tests/Helpers/HttpClientExtensions.cs b/Timeline.Tests/Helpers/HttpClientExtensions.cs
index 38641f90..6513bbe7 100644
--- a/Timeline.Tests/Helpers/HttpClientExtensions.cs
+++ b/Timeline.Tests/Helpers/HttpClientExtensions.cs
@@ -35,5 +35,17 @@ namespace Timeline.Tests.Helpers
content.Headers.ContentType = new MediaTypeHeaderValue(mimeType);
return client.PutAsync(url, content);
}
+
+ public static Task<HttpResponseMessage> PutStringAsync(this HttpClient client, string url, string body, string mimeType = null)
+ {
+ return client.PutStringAsync(new Uri(url, UriKind.RelativeOrAbsolute), body, mimeType);
+ }
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")]
+ public static Task<HttpResponseMessage> PutStringAsync(this HttpClient client, Uri url, string body, string mimeType = null)
+ {
+ var content = new StringContent(body, Encoding.UTF8, mimeType ?? MediaTypeNames.Text.Plain);
+ return client.PutAsync(url, content);
+ }
}
}