Show / Hide Table of Contents

Class ExtInternet

Extension methods for .NET Internet functions.

public static class ExtInternet

Namespace: Au.Types
Assembly: Au.dll
Inheritance
object
ExtInternet

Methods

Name Description
Add(MultipartFormDataContent, string, string)

Adds a non-file field. Uses System.Net.Http.MultipartFormDataContent.Add.

AddFile(MultipartFormDataContent, string, string, string, string)

Adds a file field. Uses System.Net.Http.MultipartFormDataContent.Add. Please read remarks about disposing.

AddMany(HttpRequestHeaders, IEnumerable<string>)

Adds multiple HTTP request headers. Uses System.Net.Http.Headers.HttpHeaders.Add.

AddMany(HttpRequestHeaders, params string[])

Adds multiple HTTP request headers. Uses System.Net.Http.Headers.HttpHeaders.Add.

Bytes(HttpResponseMessage, bool)

Gets content data as byte[]. Downloads it if need. If content is text, the array contains that text, usually UTF-8.

Download(HttpResponseMessage, Stream, Action<ProgressArgs>, CancellationToken, bool)

Downloads content to stream and provides the progress.

Download(HttpResponseMessage, string, Action<ProgressArgs>, CancellationToken)

Downloads content to file and provides the progress.

DownloadAsync(HttpResponseMessage, Stream, Action<ProgressArgs>, CancellationToken, bool)

The async version of ExtInternet.Download.

DownloadAsync(HttpResponseMessage, string, Action<ProgressArgs>, CancellationToken)

The async version of ExtInternet.Download.

Get(HttpClient, string, bool, IEnumerable<string>, string, Action<HttpRequestMessage>)

Sends a GET request to the specified URL, and gets the response.

Get(HttpClient, string, string, IEnumerable<string>, string, Action<HttpRequestMessage>)

Sends a GET request to the specified URL, and gets the response. Saves the response content (file, web page, etc) in a file.

Json(HttpResponseMessage, bool)

Parses content, which must be JSON, and returns the root node. Then you can access JSON elements like var y = (string)r["x"]["y"];. Downloads content if need. Uses System.Text.Json.Nodes.JsonNode.Parse.

Json<T>(HttpResponseMessage)

Parses content, which must be JSON. From it creates/returns an object of type T. Downloads content if need. Uses System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>.

Post(HttpClient, string, HttpContent, IEnumerable<string>, bool, string, Action<HttpRequestMessage>)

Sends a POST request to the specified URL, and gets the response.

Save(HttpResponseMessage, string)

Saves content in a file. Downloads if need.

Text(HttpResponseMessage, bool)

Gets content text as string. Downloads it if need.

TryGet(HttpClient, out HttpResponseMessage, string, bool, IEnumerable<string>, bool, string, Action<HttpRequestMessage>)

Sends a GET request to the specified URL, and gets the response. Handles HTTP errors and exceptions.

TryPost(HttpClient, out HttpResponseMessage, string, HttpContent, IEnumerable<string>, bool, bool, string, Action<HttpRequestMessage>)

Sends a POST request to the specified URL, and gets the response. Handles HTTP errors and exceptions.