private async Task <string> SendFile(HttpMethod method, string path, string filePath, bool hasResponse) { Stopwatch stopwatch = null; if (_config.LogLevel >= LogMessageSeverity.Verbose) { stopwatch = Stopwatch.StartNew(); } string responseJson = await _engine.SendFile(method, path, filePath, _cancelToken).ConfigureAwait(false); #if TEST_RESPONSES if (!hasResponse && !string.IsNullOrEmpty(responseJson)) { throw new Exception("API check failed: Response is not empty."); } #endif if (_config.LogLevel >= LogMessageSeverity.Verbose) { stopwatch.Stop(); if (_config.LogLevel >= LogMessageSeverity.Debug) { RaiseOnRequest(method, path, filePath, stopwatch.ElapsedTicks / (double)TimeSpan.TicksPerMillisecond); } else { RaiseOnRequest(method, path, null, stopwatch.ElapsedTicks / (double)TimeSpan.TicksPerMillisecond); } } return(responseJson); }
private async Task <string> SendFile(IRestFileRequest request, bool hasResponse) { var method = request.Method; var path = request.Endpoint; var filename = request.Filename; var stream = request.Stream; var isPrivate = request.IsPrivate; Stopwatch stopwatch = null; if (Logger.Level >= LogSeverity.Verbose) { stopwatch = Stopwatch.StartNew(); } string responseJson = await _engine.SendFile(method, path, filename, stream, CancelToken).ConfigureAwait(false); if (Logger.Level >= LogSeverity.Verbose) { stopwatch.Stop(); double milliseconds = Math.Round(stopwatch.ElapsedTicks / (double)TimeSpan.TicksPerMillisecond, 2); string log = $"{method} {path}: {milliseconds} ms"; if (_config.LogLevel >= LogSeverity.Debug && !isPrivate) { log += $" {filename}"; } Logger.Verbose(log); } return(responseJson); }
private async Task<RestResults> SendFile(IRestFileRequest request, bool hasResponse) { Stopwatch stopwatch = Stopwatch.StartNew(); string responseJson = await _engine.SendFile(request.Method, request.Endpoint, request.Filename, request.Stream, CancelToken).ConfigureAwait(false); stopwatch.Stop(); double milliseconds = Math.Round((double)stopwatch.ElapsedTicks / (double)Stopwatch.Frequency * 1000.0, 2); return new RestResults(responseJson, milliseconds); }