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

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