mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 06:48:16 +08:00
fixed a bug where getting invalid parameter error if sending a steam content with no stream, now we try convert to byte array which the c# http client is happy to take if empty...or this error is caused because we are trying to use a stream when we shouldnt.
This commit is contained in:
@ -106,6 +106,31 @@ namespace Ocelot.AcceptanceTests
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_return_response_201_with_complex_query_string()
|
||||
{
|
||||
var yamlConfiguration = new YamlConfiguration
|
||||
{
|
||||
ReRoutes = new List<YamlReRoute>
|
||||
{
|
||||
new YamlReRoute
|
||||
{
|
||||
DownstreamTemplate = "http://localhost:51879/newThing",
|
||||
UpstreamTemplate = "/newThing",
|
||||
UpstreamHttpMethod = "Get",
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", 200, "Hello from Laura"))
|
||||
.And(x => _steps.GivenThereIsAConfiguration(yamlConfiguration))
|
||||
.And(x => _steps.GivenOcelotIsRunning())
|
||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/newThing?DeviceType=IphoneApp&Browser=moonpigIphone&BrowserString=-&CountryCode=123&DeviceName=iPhone 5 (GSM+CDMA)&OperatingSystem=iPhone OS 7.1.2&BrowserVersion=3708AdHoc&ipAddress=-"))
|
||||
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
|
||||
.And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Laura"))
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
private void GivenThereIsAServiceRunningOn(string url, int statusCode, string responseBody)
|
||||
{
|
||||
_builder = new WebHostBuilder()
|
||||
|
@ -21,9 +21,6 @@ ReRoutes:
|
||||
LocationId: Claims[LocationId] > value
|
||||
UserType: Claims[sub] > value[0] > |
|
||||
UserId: Claims[sub] > value[1] > |
|
||||
- DownstreamTemplate: http://www.bbc.co.uk
|
||||
UpstreamTemplate: /
|
||||
UpstreamHttpMethod: Get
|
||||
- DownstreamTemplate: http://localhost:51879/api/products/{productId}
|
||||
UpstreamTemplate: /products/{productId}
|
||||
- DownstreamTemplate: http://jsonplaceholder.typicode.com/posts
|
||||
UpstreamTemplate: /posts
|
||||
UpstreamHttpMethod: Get
|
||||
|
@ -69,7 +69,7 @@ namespace Ocelot.UnitTests.RequestBuilder
|
||||
_request = new OkResponse<Request>(request);
|
||||
_requestBuilder
|
||||
.Setup(x => x.Build(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<Stream>(), It.IsAny<IHeaderDictionary>(),
|
||||
It.IsAny<IRequestCookieCollection>(), It.IsAny<string>(), It.IsAny<string>()))
|
||||
It.IsAny<IRequestCookieCollection>(), It.IsAny<QueryString>(), It.IsAny<string>()))
|
||||
.ReturnsAsync(_request);
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ namespace Ocelot.UnitTests.RequestBuilder
|
||||
private HttpContent _content;
|
||||
private IHeaderDictionary _headers;
|
||||
private IRequestCookieCollection _cookies;
|
||||
private string _query;
|
||||
private QueryString _query;
|
||||
private string _contentType;
|
||||
private readonly IRequestBuilder _requestBuilder;
|
||||
private Response<Request> _result;
|
||||
@ -137,7 +137,7 @@ namespace Ocelot.UnitTests.RequestBuilder
|
||||
{
|
||||
this.Given(x => x.GivenIHaveHttpMethod("POST"))
|
||||
.And(x => x.GivenIHaveDownstreamUrl("http://www.bbc.co.uk"))
|
||||
.And(x => x.GivenTheQueryStringIs("?jeff=1&geoff=2"))
|
||||
.And(x => x.GivenTheQueryStringIs(new QueryString("?jeff=1&geoff=2")))
|
||||
.When(x => x.WhenICreateARequest())
|
||||
.And(x => x.ThenTheCorrectQueryStringIsUsed("?jeff=1&geoff=2"))
|
||||
.BDDfy();
|
||||
@ -153,7 +153,7 @@ namespace Ocelot.UnitTests.RequestBuilder
|
||||
_result.Data.HttpRequestMessage.RequestUri.Query.ShouldBe(expected);
|
||||
}
|
||||
|
||||
private void GivenTheQueryStringIs(string query)
|
||||
private void GivenTheQueryStringIs(QueryString query)
|
||||
{
|
||||
_query = query;
|
||||
}
|
||||
|
Reference in New Issue
Block a user