Exemplo n.º 1
0
        public static void AddIdempotencyHeader(this HttpRequestHeaders @this, string idempotencyToken)
        {
            @this.ThrowIfNull(typeof(HttpRequestHeaders).Name.ToLower());
            idempotencyToken.ThrowIfNullOrWhiteSpace(nameof(idempotencyToken));

            @this.Add(IdempotencyHeader, idempotencyToken);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Adds this cached result information to the HTTP request headers.
 /// </summary>
 /// <param name="headers">The headers where the data should be added.</param>
 public void AddRequestHeaders(HttpRequestHeaders headers)
 {
     headers.ThrowIfNull(nameof(headers));
     headers.IfModifiedSince = Expires;
     if (!string.IsNullOrEmpty(ETag))
     {
         headers.IfNoneMatch.TryParseAdd(ETag);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        ///  Adds the headers in this object to the given header collection.
        /// </summary>
        /// <param name="requestHeaders">The header collection to add the headers to.</param>
        public void AddHeaders(HttpRequestHeaders requestHeaders)
        {
            requestHeaders.ThrowIfNull(nameof(requestHeaders));

            foreach (var header in Headers)
            {
                requestHeaders.Add(header.Key, header.Value);
            }
        }
Exemplo n.º 4
0
        public static string GetIdempotencyToken(this HttpRequestHeaders @this)
        {
            @this.ThrowIfNull(typeof(HttpRequestHeaders).Name.ToLower());

            var result = @this.GetValues(IdempotencyHeader)
                         .FirstOrDefault()
                         .ValueIfNull(() => string.Empty);

            return(result);
        }
Exemplo n.º 5
0
        public static bool RemoveIdempotencyHeader(this HttpRequestHeaders @this)
        {
            @this.ThrowIfNull(typeof(HttpRequestHeaders).Name.ToLower());

            return(@this.Remove(IdempotencyHeader));
        }
Exemplo n.º 6
0
        public static bool HasIdempotencyHeader(this HttpRequestHeaders @this)
        {
            @this.ThrowIfNull(typeof(HttpRequestHeaders).Name.ToLower());

            return(@this.Contains(IdempotencyHeader));
        }