本文整理汇总了C#中System.Net.Http.StringContent.ReadAsHttpRequestMessageAsync方法的典型用法代码示例。如果您正苦于以下问题:C# StringContent.ReadAsHttpRequestMessageAsync方法的具体用法?C# StringContent.ReadAsHttpRequestMessageAsync怎么用?C# StringContent.ReadAsHttpRequestMessageAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Http.StringContent
的用法示例。
在下文中一共展示了StringContent.ReadAsHttpRequestMessageAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadAsHttpRequestMessageAsync_VerifyArguments
public void ReadAsHttpRequestMessageAsync_VerifyArguments()
{
Assert.ThrowsArgumentNull(() => HttpContentMessageExtensions.ReadAsHttpRequestMessageAsync(null), "content");
Assert.ThrowsArgument(() => new ByteArrayContent(new byte[] { }).ReadAsHttpRequestMessageAsync(), "content");
Assert.ThrowsArgument(() => new StringContent(String.Empty).ReadAsHttpRequestMessageAsync(), "content");
Assert.ThrowsArgument(() => new StringContent(String.Empty, Encoding.UTF8, "application/http").ReadAsHttpRequestMessageAsync(), "content");
Assert.ThrowsArgument(() =>
{
HttpContent content = new StringContent(String.Empty);
content.Headers.ContentType = ParserData.HttpResponseMediaType;
content.ReadAsHttpRequestMessageAsync();
}, "content");
Assert.ThrowsArgumentNull(() =>
{
HttpContent content = new StringContent(String.Empty);
content.Headers.ContentType = ParserData.HttpRequestMediaType;
content.ReadAsHttpRequestMessageAsync(null);
}, "uriScheme");
Assert.ThrowsArgument(() =>
{
HttpContent content = new StringContent(String.Empty);
content.Headers.ContentType = ParserData.HttpRequestMediaType;
content.ReadAsHttpRequestMessageAsync("i n v a l i d");
}, "uriScheme");
Assert.ThrowsArgumentGreaterThanOrEqualTo(() =>
{
HttpContent content = new StringContent(String.Empty);
content.Headers.ContentType = ParserData.HttpRequestMediaType;
content.ReadAsHttpRequestMessageAsync(Uri.UriSchemeHttp, ParserData.MinBufferSize - 1);
}, "bufferSize", ParserData.MinBufferSize.ToString(), ParserData.MinBufferSize - 1);
}
示例2: ReadAsHttpRequestMessageAsync_IncompleteRequest
public void ReadAsHttpRequestMessageAsync_IncompleteRequest(string incompleteRequest)
{
StringContent content = new StringContent(incompleteRequest);
content.Headers.ContentType = ParserData.HttpRequestMediaType;
Assert.Throws<IOException>(() => content.ReadAsHttpRequestMessageAsync().Result);
}