Skip to content

Commit

Permalink
Merge pull request #35 from rcknight/support-query-params
Browse files Browse the repository at this point in the history
Add support for query parameters in RunProxy()
  • Loading branch information
twitchax authored Feb 18, 2020
2 parents ee46332 + 70d690a commit c1b7274
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Core/Extensions/Basic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ internal static EndpointComputerToValueTask GetRunProxyComputer(EndpointComputer
return async (context, args) =>
{
var endpoint = await GetEndpointFromComputerAsync(context, endpointComputer).ConfigureAwait(false);
return $"{endpoint}{context.Request.Path}";
return $"{endpoint}{context.Request.Path}{context.Request.QueryString}";
};
}

Expand Down
4 changes: 3 additions & 1 deletion src/Test/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;

namespace AspNetCore.Proxy.Tests
{
Expand Down Expand Up @@ -63,7 +64,8 @@ internal static async Task SocketBoomerang(this HttpContext context)
internal static async Task HttpBoomerang(this HttpContext context)
{
var message = await new StreamReader(context.Request.Body).ReadToEndAsync();
await context.Response.WriteAsync($"[{message}]");
var uri = context.Request.GetDisplayUrl();
await context.Response.WriteAsync($"({uri})[{message}]");
}
}
}
12 changes: 11 additions & 1 deletion src/Test/RunProxy/RunProxyIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public async Task CanDoWebSockets()

// HTTP test.
var response = await _httpClient.PostAsync("http://localhost:5003/at/some/path", new StringContent(send1));
Assert.Equal(expected1, await response.Content.ReadAsStringAsync());
Assert.EndsWith(expected1, await response.Content.ReadAsStringAsync());
}

[Fact]
Expand All @@ -80,6 +80,16 @@ public async Task CanDoSimpleServer()
var expected1 = $"[{send1}]";

var response = await _httpClient.PostAsync("http://localhost:5007/at/some/other/path", new StringContent(send1));
Assert.EndsWith(expected1, await response.Content.ReadAsStringAsync());
}

[Fact]
public async Task CanAppendQueryParameters()
{
var send1 = "TESTWITHQUERY";
var expected1 = $"(http://localhost:5004/at/some/other/path?with=query&parameters=true)[{send1}]";

var response = await _httpClient.PostAsync("http://localhost:5007/at/some/other/path?with=query&parameters=true", new StringContent(send1));
Assert.Equal(expected1, await response.Content.ReadAsStringAsync());
}

Expand Down

0 comments on commit c1b7274

Please sign in to comment.