public async Task <IRwsResponse> SendRequestAsync(IRwsRequest request, int?timeout = null) { var client = new FlurlRequest(Url.Combine(BaseUrl, request.UrlPath())); if (timeout != null) { client.WithTimeout((int)timeout); } if (request.RequiresAuthentication) { client.WithBasicAuth(_username, _password); } client.WithHeaders(request.Headers); var stopwatch = Stopwatch.StartNew(); HttpResponseMessage response = null; try { response = await client.AllowAnyHttpStatus().SendAsync(request.Method, request.RequestBody); } catch (FlurlHttpTimeoutException ex) { throw new RwsException($"Connection timeout for {client.Url.ToString()}", ex); } stopwatch.Stop(); LastResult = response; RequestTime = stopwatch.Elapsed; RwsExceptionHandler.Parse(response); return(request.Result(response)); }