Support requests with HttpContent body

If a 3rd party client needs to provide a specific HttpContent, we should
allow that in the adapter. Our clients probably shouldn't do this as it
would break encapsulation.
This commit is contained in:
Haacked
2013-10-11 14:34:09 -07:00
parent db0dc1c00b
commit db2f805bc8
3 changed files with 26 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
@@ -68,13 +69,19 @@ namespace Octokit.Internal
{
requestMessage.Headers.Add(header.Key, header.Value);
}
var httpContent = request.Body as HttpContent;
if (httpContent != null)
{
requestMessage.Content = httpContent;
}
var body = request.Body as string;
if (body != null)
{
requestMessage.Content = new StringContent(body, Encoding.UTF8, request.ContentType);
}
var bodyStream = request.Body as System.IO.Stream;
var bodyStream = request.Body as Stream;
if (bodyStream != null)
{
requestMessage.Content = new StreamContent(bodyStream);