/// <summary> /// Retrieves a standard HTTP response header from a REST response, if available. /// </summary> /// <param name="response">The REST response.</param> /// <param name="header">The header to retrieve.</param> /// <param name="value">Returns the value for <paramref name="header"/>.</param> /// <returns><c>true</c> if the specified header is contained in <paramref name="response"/>, otherwise <c>false</c>.</returns> /// <exception cref="ArgumentNullException"><paramref name="response"/> is <c>null</c>.</exception> public static bool TryGetHeader(this Response response, HttpResponseHeader header, out string value) { if (response == null) throw new ArgumentNullException("response"); if (response.Headers == null) { value = null; return false; } WebHeaderCollection collection = new RestWebHeaderCollection(response.Headers); value = collection[header]; return value != null; }
/// <summary> /// Retrieves a standard HTTP response header from a REST response, if available. /// </summary> /// <param name="response">The REST response.</param> /// <param name="header">The header to retrieve.</param> /// <param name="value">Returns the value for <paramref name="header"/>.</param> /// <returns><see langword="true"/> if the specified header is contained in <paramref name="response"/>, otherwise <see langword="false"/>.</returns> /// <exception cref="ArgumentNullException"><paramref name="response"/> is <see langword="null"/>.</exception> public static bool TryGetHeader(this Response response, HttpResponseHeader header, out string value) { if (response == null) { throw new ArgumentNullException("response"); } if (response.Headers == null) { value = null; return(false); } WebHeaderCollection collection = new RestWebHeaderCollection(response.Headers); value = collection[header]; return(value != null); }