Example #1
0
        ResponseHashConfig UpdateNew(Action <ResponseHashConfig, HttpMessageHashHandler> updater,
                                     HttpMessageHashHandler update)
        {
            var config = new ResponseHashConfig(this);

            updater(config, update);
            return(config);
        }
Example #2
0
 ResponseHashConfig(HttpMessageHashHandler version, HttpMessageHashHandler statusCode, HttpMessageHashHandler reasonPhrase,
                    HttpMessageHashHandler headers, HttpMessageHashHandler content, HttpMessageHashHandler trailingHeaders)
 {
     Version         = version;
     StatusCode      = statusCode;
     ReasonPhrase    = reasonPhrase;
     Headers         = headers;
     Content         = content;
     TrailingHeaders = trailingHeaders;
 }
Example #3
0
 RequestHashConfig(HttpMessageHashHandler method, HttpMessageHashHandler url, HttpMessageHashHandler version,
                   HttpMessageHashHandler headers, HttpMessageHashHandler content, HttpMessageHashHandler trailingHeaders)
 {
     Method          = method;
     Url             = url;
     Version         = version;
     Headers         = headers;
     Content         = content;
     TrailingHeaders = trailingHeaders;
 }
Example #4
0
        public static byte[] Hash(this HttpMessage message, HashAlgorithmName hashAlgorithm,
                                  HttpMessageHashHandler handler,
                                  params HttpMessageHashHandler[] handlers)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            using var hash = IncrementalHash.CreateHash(hashAlgorithm);

            handler = Collect(handlers.Prepend(handler));
            var task = handler(message, ArrayPool <byte> .Create(),
                               buffer => hash.AppendData(buffer.Array, buffer.Offset, buffer.Count));

            task.GetAwaiter().GetResult();
            return(hash.GetHashAndReset());
        }
Example #5
0
 public ResponseHashConfig WithTrailingHeaders(HttpMessageHashHandler value) => With(TrailingHeaders, value, (c, v) => c.TrailingHeaders = v);
Example #6
0
 public ResponseHashConfig WithContent(HttpMessageHashHandler value) => With(Content, value, (c, v) => c.Content       = v);
Example #7
0
 public ResponseHashConfig WithHeaders(HttpMessageHashHandler value) => With(Headers, value, (c, v) => c.Headers       = v);
Example #8
0
 public ResponseHashConfig WithUrl(HttpMessageHashHandler value) => With(ReasonPhrase, value, (c, v) => c.ReasonPhrase = v);
Example #9
0
 public ResponseHashConfig WithMethod(HttpMessageHashHandler value) => With(StatusCode, value, (c, v) => c.StatusCode  = v);
Example #10
0
 public ResponseHashConfig WithVersion(HttpMessageHashHandler value) => With(Version, value, (c, v) => c.Version       = v);
Example #11
0
 ResponseHashConfig With(HttpMessageHashHandler current,
                         HttpMessageHashHandler update,
                         Action <ResponseHashConfig, HttpMessageHashHandler> updater) =>
 update == current ? this : UpdateNew(updater, update);
Example #12
0
 public static string HashString(this HttpMessage message, HashAlgorithmName hashAlgorithm,
                                 HttpMessageHashHandler handler,
                                 params HttpMessageHashHandler[] handlers) =>
 Hash(message, hashAlgorithm, handler, handlers).ToHexadecimalString();
Example #13
0
 public RequestHashConfig WithUrl(HttpMessageHashHandler value) => With(Url, value, (c, v) => c.Url             = v);
Example #14
0
 public RequestHashConfig WithMethod(HttpMessageHashHandler value) => With(Method, value, (c, v) => c.Method    = v);