public void HttpRequestMessageAsFormattedStringHandlesEmptyRequests() { using (var httpRequest = new HttpRequestMessage()) { var formattedString = httpRequest.AsFormattedString(); Assert.Contains("Method: GET", formattedString); } }
public void LogsRequest() { Log4NetTracingInterceptor logger = new Log4NetTracingInterceptor("app.config"); string invocationId = "12345"; HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://azuresdk.com"); string expected = string.Format("DEBUG - invocationId: {0}\r\nrequest: {1}\r\n", invocationId, request.AsFormattedString()); logger.SendRequest(invocationId, request); string actual = File.ReadAllText(logFileName); Assert.Equal(expected, actual); }
public void HttpRequestMessageAsFormattedStringHandlesRequestsWithContent() { using (var httpRequest = new HttpRequestMessage(HttpMethod.Get, "http://www.windowsazure.com/test")) { httpRequest.Content = new StringContent("<body/>"); var formattedString = httpRequest.AsFormattedString(); Assert.Contains("Method: GET", formattedString); Assert.Contains("RequestUri: 'http://www.windowsazure.com/test'", formattedString); Assert.Contains("<body/>", formattedString); } }
public void HttpRequestMessageAsFormattedStringHandlesRequestsWithHeaders() { using (var httpRequest = new HttpRequestMessage(HttpMethod.Get, "http://www.windowsazure.com/test")) { httpRequest.Headers.Add("x-ms-version", "2013-11-01"); var formattedString = httpRequest.AsFormattedString(); Assert.Contains("Method: GET", formattedString); Assert.Contains("RequestUri: 'http://www.windowsazure.com/test'", formattedString); Assert.Contains("x-ms-version: 2013-11-01", formattedString); } }
public void SendRequest(string invocationId, HttpRequestMessage request) { _logger.LogInformation(" request: {0}", request.AsFormattedString()); }
/// <summary> /// Send an HTTP request. /// </summary> /// <param name="invocationId">Method invocation identifier.</param> /// <param name="request">The request about to be sent.</param> public virtual void SendRequest(string invocationId, HttpRequestMessage request) { string requestAsString = request == null ? string.Empty : request.AsFormattedString(); HttpOperationEventSource.Log.SendRequest(invocationId, requestAsString); }
/// <summary> /// Send an HTTP request. /// </summary> /// <param name="invocationId">Method invocation identifier.</param> /// <param name="request">The request about to be sent.</param> public void SendRequest(string invocationId, HttpRequestMessage request) { string requestAsString = (request == null ? string.Empty : request.AsFormattedString()); _logger.DebugFormat(CultureInfo.InvariantCulture, "invocationId: {0}\r\nrequest: {1}", invocationId, requestAsString); }
/// <summary> /// Send an HTTP request. /// </summary> /// <param name="invocationId">Method invocation identifier.</param> /// <param name="request">The request about to be sent.</param> public void SendRequest(string invocationId, HttpRequestMessage request) { string requestAsString = request == null ? string.Empty : request.AsFormattedString(); _logger.DebugFormat("invocationId: {0}\r\nrequest: {1}", invocationId, requestAsString); }