示例#1
0
        public static async Task <byte[]> GetBytesAsync(this IHttpRequestFactory httpRequestFactory, string url, TimeoutSpecification timeout = default)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }

            var response = await httpRequestFactory.Get(url.ToUrl()).SendAsync(timeout).ConfigureAwait(false);

            return(await response.GetBytesAsync().ConfigureAwait(false));
        }
示例#2
0
        public static async Task <byte[]?> TryGetBytesAsync(this IHttpRequestFactory httpRequestFactory, string url, TimeoutSpecification timeout = default)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }

            var response = await httpRequestFactory.Get(url.ToUrl()).SendAsync(timeout, IgnoreNotFoundApiErrors).ConfigureAwait(false);

            return(response.Status.IsNotFound
                ? default
                : await response.GetBytesAsync().ConfigureAwait(false));
        }