Skip to content

Commit

Permalink
blank useragent bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gfody committed Mar 14, 2018
1 parent aa47171 commit b8f3f0f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion App/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<!-- accept relays (required for the webclient) -->
<add key="acceptRelays" value="true"/>

<!-- set to false to shutdown when the last relay is finished or canceled -->
<!-- set to false to shutdown when the last relay is finished or canceled (only applicable to the tray app) -->
<add key="stayOpen" value="true"/>

<!-- max concurrent connections for listener -->
Expand Down
2 changes: 1 addition & 1 deletion Server/RelayServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private async Task ProcessRequestAsync(HttpContextBase context)
{
if (validCode)
{
if (activeRelays.TryGetValue(code, out IRelay relay) && !botAgents.IsMatch(context.Request.UserAgent))
if (activeRelays.TryGetValue(code, out IRelay relay) && !botAgents.IsMatch(context.Request.UserAgent ?? ""))
await relay.HandleDownloadRequest(context);
else
context.Response.StatusCode = 410;
Expand Down
12 changes: 10 additions & 2 deletions Tests/TestTransfers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ private void LocalDownload(int size, bool pipe = false)
var code = server.AddRelay(new LocalRelay(stream));

using (var client = new WebClient())
CollectionAssert.AreEqual(data, client.DownloadData(downloadUrl + code));
{
var downloaded = client.DownloadData(downloadUrl + code);
if (listen.IsFaulted) throw listen.Exception.InnerException;
CollectionAssert.AreEqual(data, downloaded);
}
}

private void SocketDownload(int size, bool pipe = false)
Expand All @@ -66,7 +70,11 @@ private void SocketDownload(int size, bool pipe = false)
var code = socket.AddRelay(websocketUrl, stream).Result;

using (var client = new WebClient())
CollectionAssert.AreEqual(data, client.DownloadData(downloadUrl + code));
{
var downloaded = client.DownloadData(downloadUrl + code);
if (listen.IsFaulted) throw listen.Exception.InnerException;
CollectionAssert.AreEqual(data, downloaded);
}
}

[TestMethod] public void Local_Empty() => LocalDownload(0);
Expand Down

0 comments on commit b8f3f0f

Please sign in to comment.