Skip to content

Commit

Permalink
Fixed bug when testing against ip-adresses
Browse files Browse the repository at this point in the history
  • Loading branch information
hallatore committed Jul 10, 2016
1 parent 3d10cb7 commit a97d754
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Netling.Core/Performance/HttpWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,18 @@ public HttpWorker(string url)
_read = 0;
_responseType = ResponseType.Unknown;
_uri = new Uri(url, UriKind.Absolute);
var host = Dns.GetHostEntry(_uri.Host);
var ip = host.AddressList.First(i => i.AddressFamily == AddressFamily.InterNetwork);
IPAddress ip;

if (_uri.HostNameType == UriHostNameType.Dns)
{
var host = Dns.GetHostEntry(_uri.Host);
ip = host.AddressList.First(i => i.AddressFamily == AddressFamily.InterNetwork);
}
else
{
ip = IPAddress.Parse(_uri.Host);
}

_endPoint = new IPEndPoint(ip, _uri.Port);
_request = Encoding.UTF8.GetBytes($"GET {_uri.PathAndQuery} HTTP/1.1\r\nAccept-Encoding: gzip, deflate, sdch\r\nHost: {_uri.Host}\r\nContent-Length: 0\r\n\r\n");
}
Expand Down

0 comments on commit a97d754

Please sign in to comment.