mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-07-31 08:35:58 +08:00
failing pesky test
This commit is contained in:
@ -1,17 +1,39 @@
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Flurl;
|
||||
using Flurl.Http;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Ocelot.Library.Infrastructure.Requester
|
||||
{
|
||||
public class HttpClientHttpRequester : IHttpRequester
|
||||
{
|
||||
public async Task<HttpResponseMessage> GetResponse(string httpMethod, string downstreamUrl, Stream content = null)
|
||||
public async Task<HttpResponseMessage> GetResponse(
|
||||
string httpMethod,
|
||||
string downstreamUrl,
|
||||
Stream content,
|
||||
IHeaderDictionary headers,
|
||||
IRequestCookieCollection cookies,
|
||||
IQueryCollection queryString)
|
||||
{
|
||||
var method = new HttpMethod(httpMethod);
|
||||
var streamContent = new StreamContent(content);
|
||||
|
||||
return await downstreamUrl.SendAsync(method, new StreamContent(content));
|
||||
if (content.Length > 0)
|
||||
{
|
||||
return await downstreamUrl
|
||||
.SetQueryParams(queryString)
|
||||
.WithCookies(cookies)
|
||||
.WithHeaders(streamContent.Headers)
|
||||
.SendAsync(method, streamContent);
|
||||
}
|
||||
|
||||
return await downstreamUrl
|
||||
.SetQueryParams(queryString)
|
||||
.WithHeaders(headers)
|
||||
.WithCookies(cookies)
|
||||
.SendAsync(method, streamContent);
|
||||
}
|
||||
}
|
||||
}
|
@ -2,11 +2,18 @@
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Flurl.Http;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Ocelot.Library.Infrastructure.Requester
|
||||
{
|
||||
public interface IHttpRequester
|
||||
{
|
||||
Task<HttpResponseMessage> GetResponse(string httpMethod, string downstreamUrl, Stream content = null);
|
||||
Task<HttpResponseMessage> GetResponse(
|
||||
string httpMethod,
|
||||
string downstreamUrl,
|
||||
Stream content,
|
||||
IHeaderDictionary headers,
|
||||
IRequestCookieCollection cookies,
|
||||
IQueryCollection queryString);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user