/// <summary>
    /// Registers an HTTP request interception for a stream, replacing any existing registration.
    /// </summary>
    /// <param name="method">The HTTP method to register an interception for.</param>
    /// <param name="uri">The request URI to register an interception for.</param>
    /// <param name="contentStream">A delegate to a method that returns the response stream.</param>
    /// <param name="statusCode">The optional HTTP status code to return.</param>
    /// <param name="mediaType">The optional media type for the content-type.</param>
    /// <param name="responseHeaders">The optional HTTP response headers for the response.</param>
    /// <param name="contentHeaders">The optional HTTP response headers for the content.</param>
    /// <param name="onIntercepted">An optional delegate to invoke when the HTTP message is intercepted.</param>
    /// <returns>
    /// The current <see cref="HttpClientInterceptorOptions"/>.
    /// </returns>
    /// <exception cref="ArgumentNullException">
    /// <paramref name="method"/>, <paramref name="uri"/> or <paramref name="contentStream"/> is <see langword="null"/>.
    /// </exception>
    public HttpClientInterceptorOptions RegisterStream(
        HttpMethod method,
        Uri uri,
        Func <Task <Stream> > contentStream,
        HttpStatusCode statusCode = HttpStatusCode.OK,
        string mediaType          = JsonMediaType,
        IEnumerable <KeyValuePair <string, IEnumerable <string> > >?responseHeaders = null,
        IEnumerable <KeyValuePair <string, IEnumerable <string> > >?contentHeaders  = null,
        Func <HttpRequestMessage, Task>?onIntercepted = null)
    {
        if (method == null)
        {
            throw new ArgumentNullException(nameof(method));
        }

        if (uri == null)
        {
            throw new ArgumentNullException(nameof(uri));
        }

        if (contentStream == null)
        {
            throw new ArgumentNullException(nameof(contentStream));
        }

        var interceptor = new HttpInterceptionResponse()
        {
            ContentStream    = contentStream,
            ContentHeaders   = contentHeaders,
            ContentMediaType = mediaType,
            Method           = method,
            OnIntercepted    = DelegateHelpers.ConvertToBooleanTask(onIntercepted),
            RequestUri       = uri,
            ResponseHeaders  = responseHeaders,
            StatusCode       = statusCode,
        };

        ConfigureMatcherAndRegister(interceptor);

        return(this);
    }