
The .NET library provides a powerful API for creating and sending HTTP web requests.
There is a simple WebClient
type (see MSDN) and a more flexible HttpWebRequest
type (see MSDN). However, these two types are quite difficult to use if you
want to quickly run a simple HTTP request and specify parameters such as method,
HTTP POST data, or additional headers.
The FSharp.Data package provides a simple Http type with four methods:
Http.RequestString and Http.AsyncRequestString, that can be used to create a simple request and
perform it synchronously or asynchronously, and Http.Request and it's async companion Http.AsyncRequest if
you want to request binary files or you want to know more about the response like the status code,
the response URL, or the returned headers and cookies.
The type is located in FSharp.Data
namespace:
open FSharp.Data
To send a simple HTTP (GET) request that downloads a specified web page, you
can use Http.RequestString and Http.AsyncRequestString with just a single parameter:
// Download the content of a web site
Http.RequestString("http://tomasp.net")
// Download web site asynchronously
async {
let! html = Http.AsyncRequestString("http://tomasp.net")
printfn "%d" html.Length
}
|> Async.Start
In the rest of the documentation, we focus on the RequestString
method, because
the use of AsyncRequestString
is exactly the same.
You can specify query parameters either by constructing
an URL that includes the parameters (e.g. http://...?test=foo&more=bar
) or you
can pass them using the optional parameter query
. The following example also explicitly
specifies the GET method, but it will be set automatically for you if you omit it:
Http.RequestString("http://httpbin.org/get", query = [ "test", "foo" ], httpMethod = "GET")
36745
val it: string =
"{
"args": {
"test": "foo"
},
"headers": {
"Accept-Encoding": "gzip, deflate",
"Host": "httpbin.org",
"X-Amzn-Trace-Id": "Root=1-6473c444-04cf95a23c3783194df0d3bb"
},
"origin": "40.122.245.224",
"url": "http://httpbin.org/get?test=foo"
}
"
|
Additional headers are specified similarly - using an optional parameter headers
.
The collection can contain custom headers, but also standard headers such as the
Accept header (which has to be set using a specific property when using HttpWebRequest
).
The following example uses The Movie Database API
to search for the word "batman". To run the sample, you'll need to register and
provide your API key:
// API key for http://www.themoviedb.org
let apiKey = "<please register to get a key>"
// Run the HTTP web request
Http.RequestString(
"http://api.themoviedb.org/3/search/movie",
httpMethod = "GET",
query = [ "api_key", apiKey; "query", "batman" ],
headers = [ "Accept", "application/json" ]
)
The library supports a simple and unchecked string based API (used in the previous example),
but you can also use pre-defined header names to avoid spelling mistakes. The named headers
are available in HttpRequestHeaders (and HttpResponseHeaders) modules, so you can either
use the full name HttpRequestHeaders.Accept
, or open the module and use just the short name
Accept
as in the following example. Similarly, the HttpContentTypes
enumeration provides
well known content types:
open FSharp.Data.HttpRequestHeaders
// Run the HTTP web request
Http.RequestString(
"http://api.themoviedb.org/3/search/movie",
query = [ "api_key", apiKey; "query", "batman" ],
headers = [ Accept HttpContentTypes.Json ]
)
Note that in the previous snippet, if you don't specify a valid API key, you'll get a (401) Unathorized error,
and that will throw an exception. Unlike when using WebRequest
directly, the exception message will still include
the response content, so it's easier to debug in F# interactive when the server returns extra info.
You can also opt out of the exception by specifying the silentHttpErrors
parameter:
Http.RequestString("http://api.themoviedb.org/3/search/movie", silentHttpErrors = true)
val it: string =
"{"status_code":7,"status_message":"Invalid API key: You must be granted a valid key.","success":false}
"
|
In this case, you might want to look at the HTTP status code so you don't confuse an error message for an actual response.
If you want to see more information about the response, including the status code, the response
headers, the returned cookies, and the response url (which might be different to
the url you passed when there are redirects), you can use the Http.Request method
instead of the Http.RequestString method:
let response =
Http.Request("http://api.themoviedb.org/3/search/movie", silentHttpErrors = true)
// Examine information about the response
response.Headers
response.Cookies
response.ResponseUrl
response.StatusCode
If you want to create a POST request with HTTP POST data, you can specify the
additional data in the body
optional parameter. This parameter is of type HttpRequestBody, which
is a discriminated union with three cases:
TextRequest
for sending a string in the request body.
BinaryUpload
for sending binary content in the request.
FormValues
for sending a set of name-value pairs correspondent to form values.
If you specify a body, you do not need to set the httpMethod
parameter, it will be set to Post
automatically.
The following example uses the httpbin.org service which
returns the request details:
Http.RequestString("http://httpbin.org/post", body = FormValues [ "test", "foo" ])
val it: string =
"{
"args": {},
"data": "",
"files": {},
"form": {
"test": "foo"
},
"headers": {
"Accept-Encoding": "gzip, deflate",
"Content-Length": "8",
"Content-Type": "application/x-www-form-urlencoded",
"Host": "httpbin.org",
"X-Amzn-Trace-Id": "Root=1-6473c444-35bb3ab7174c57d05d8278ec"
},
"json": null,
"origin": "40.122.245.224",
"url": "http://httpbin.org/post"
}
"
|
By default, the Content-Type
header is set to text/plain
, application/x-www-form-urlencoded
,
or application/octet-stream
, depending on which kind of HttpRequestBody
you specify, but you can change
this behaviour by adding content-type
to the list of headers using the optional argument headers
:
Http.RequestString(
"http://httpbin.org/post",
headers = [ ContentType HttpContentTypes.Json ],
body = TextRequest """ {"test": 42} """
)
val it: string =
"{
"args": {},
"data": " {\"test\": 42} ",
"files": {},
"form": {},
"headers": {
"Accept-Encoding": "gzip, deflate",
"Content-Length": "14",
"Content-Type": "application/json",
"Host": "httpbin.org",
"X-Amzn-Trace-Id": "Root=1-6473c444-1cc7f02a4f04edda74e3c82e"
},
"json": {
"test": 42
},
"origin": "40.122.245.224",
"url": "http://httpbin.org/post"
}
"
|
If you want to maintain cookies between requests, you can specify the cookieContainer
parameter.
The following is an old sample showing how this is set.
// Build URL with documentation for a given class
let msdnUrl className =
let root = "http://msdn.microsoft.com"
sprintf "%s/en-gb/library/%s.aspx" root className
// Get the page and search for F# code
let docInCSharp = Http.RequestString(msdnUrl "system.web.httprequest")
docInCSharp.Contains "<a>F#</a>"
open System.Net
let cc = CookieContainer()
// Send a request to switch the language
Http.RequestString(
msdnUrl "system.datetime",
query =
[ "cs-save-lang", "1"
"cs-lang", "fsharp" ],
cookieContainer = cc
)
|> ignore
// Request the documentation again & search for F#
let docInFSharp =
Http.RequestString(msdnUrl "system.web.httprequest", cookieContainer = cc)
docInFSharp.Contains "<a>F#</a>"
The Http.RequestString method will always return the response as a string
, but if you use the
Http.Request method, it will return a HttpResponseBody.Text
or a
HttpResponseBody.Binary
depending on the response content-type
header:
let logoUrl = "https://raw.github.com/fsharp/FSharp.Data/master/misc/logo.png"
match Http.Request(logoUrl).Body with
| Text text -> printfn "Got text content: %s" text
| Binary bytes -> printfn "Got %d bytes of binary content" bytes.Length
For the cases where you need something not natively provided by the library, you can use the
customizeHttpRequest
parameter, which expects a function that transforms an HttpWebRequest
.
As an example, let's say you want to add a client certificate to your request. To do that,
you need to open the X509Certificates
namespace from System.Security.Cryptography
,
create a X509ClientCertificate2
value, and add it to the ClientCertificates
list of the request.
Assuming the certificate is stored in myCertificate.pfx
:
open System.Security.Cryptography.X509Certificates
// Load the certificate from local file
let clientCert = new X509Certificate2(".\myCertificate.pfx", "password")
// Send the request with certificate
Http.Request(
"http://yourprotectedresouce.com/data",
customizeHttpRequest =
fun req ->
req.ClientCertificates.Add(clientCert) |> ignore
req
)
You can also send http multipart form data via the Multipart
HttpRequestBody case.
Data sent in this way is streamed instead of being read into memory in its entirety, allowing for
uploads of arbitrary size.
let largeFilePath = "//path/to/large/file.mp4"
let data = System.IO.File.OpenRead(largeFilePath) :> System.IO.Stream
Http.Request(
"http://endpoint/for/multipart/data",
body =
Multipart(
boundary = "define a custom boundary here", // this is used to separate the items you're streaming
parts = [ MultipartItem("formFieldName", System.IO.Path.GetFileName(largeFilePath), data) ]
)
)
Multiple items
namespace FSharp
--------------------
namespace Microsoft.FSharp
Multiple items
namespace FSharp.Data
--------------------
namespace Microsoft.FSharp.Data
type Http =
static member AsyncRequest: url: string * ?query: (string * string) list * ?headers: seq<string * string> * ?httpMethod: string * ?body: HttpRequestBody * ?cookies: seq<string * string> * ?cookieContainer: CookieContainer * ?silentHttpErrors: bool * ?silentCookieErrors: bool * ?responseEncodingOverride: string * ?customizeHttpRequest: (HttpWebRequest -> HttpWebRequest) * ?timeout: int -> Async<HttpResponse>
static member AsyncRequestStream: url: string * ?query: (string * string) list * ?headers: seq<string * string> * ?httpMethod: string * ?body: HttpRequestBody * ?cookies: seq<string * string> * ?cookieContainer: CookieContainer * ?silentHttpErrors: bool * ?silentCookieErrors: bool * ?customizeHttpRequest: (HttpWebRequest -> HttpWebRequest) * ?timeout: int -> Async<HttpResponseWithStream>
static member AsyncRequestString: url: string * ?query: (string * string) list * ?headers: seq<string * string> * ?httpMethod: string * ?body: HttpRequestBody * ?cookies: seq<string * string> * ?cookieContainer: CookieContainer * ?silentHttpErrors: bool * ?silentCookieErrors: bool * ?responseEncodingOverride: string * ?customizeHttpRequest: (HttpWebRequest -> HttpWebRequest) * ?timeout: int -> Async<string>
static member Request: url: string * ?query: (string * string) list * ?headers: seq<string * string> * ?httpMethod: string * ?body: HttpRequestBody * ?cookies: seq<string * string> * ?cookieContainer: CookieContainer * ?silentHttpErrors: bool * ?silentCookieErrors: bool * ?responseEncodingOverride: string * ?customizeHttpRequest: (HttpWebRequest -> HttpWebRequest) * ?timeout: int -> HttpResponse
static member RequestStream: url: string * ?query: (string * string) list * ?headers: seq<string * string> * ?httpMethod: string * ?body: HttpRequestBody * ?cookies: seq<string * string> * ?cookieContainer: CookieContainer * ?silentHttpErrors: bool * ?silentCookieErrors: bool * ?customizeHttpRequest: (HttpWebRequest -> HttpWebRequest) * ?timeout: int -> HttpResponseWithStream
static member RequestString: url: string * ?query: (string * string) list * ?headers: seq<string * string> * ?httpMethod: string * ?body: HttpRequestBody * ?cookies: seq<string * string> * ?cookieContainer: CookieContainer * ?silentHttpErrors: bool * ?silentCookieErrors: bool * ?responseEncodingOverride: string * ?customizeHttpRequest: (HttpWebRequest -> HttpWebRequest) * ?timeout: int -> string
<summary>
Utilities for working with network via HTTP. Includes methods for downloading
resources with specified headers, query parameters and HTTP body
</summary>
static member Http.RequestString: url: string * ?query: (string * string) list * ?headers: seq<string * string> * ?httpMethod: string * ?body: HttpRequestBody * ?cookies: seq<string * string> * ?cookieContainer: System.Net.CookieContainer * ?silentHttpErrors: bool * ?silentCookieErrors: bool * ?responseEncodingOverride: string * ?customizeHttpRequest: (System.Net.HttpWebRequest -> System.Net.HttpWebRequest) * ?timeout: int -> string
val async: AsyncBuilder
<summary>Builds an asynchronous workflow using computation expression syntax.</summary>
<example id="async-1"><code lang="fsharp">
let sleepExample() =
async {
printfn "sleeping"
do! Async.Sleep 10
printfn "waking up"
return 6
}
sleepExample() |> Async.RunSynchronously
</code></example>
val html: string
static member Http.AsyncRequestString: url: string * ?query: (string * string) list * ?headers: seq<string * string> * ?httpMethod: string * ?body: HttpRequestBody * ?cookies: seq<string * string> * ?cookieContainer: System.Net.CookieContainer * ?silentHttpErrors: bool * ?silentCookieErrors: bool * ?responseEncodingOverride: string * ?customizeHttpRequest: (System.Net.HttpWebRequest -> System.Net.HttpWebRequest) * ?timeout: int -> Async<string>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
<summary>Print to <c>stdout</c> using the given format, and add a newline.</summary>
<param name="format">The formatter.</param>
<returns>The formatted result.</returns>
<example>See <c>Printf.printfn</c> (link: <see cref="M:Microsoft.FSharp.Core.PrintfModule.PrintFormatLine``1" />) for examples.</example>
property System.String.Length: int with get
Multiple items
type Async =
static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit)
static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate)
static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool>
static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload
static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool>
static member CancelDefaultToken: unit -> unit
static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>>
static member Choice: computations: seq<Async<'T option>> -> Async<'T option>
static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads
static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T>
...
<summary>Holds static members for creating and manipulating asynchronous computations.</summary>
<remarks>
See also <a href="https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/asynchronous-workflows">F# Language Guide - Async Workflows</a>.
</remarks>
<category index="1">Async Programming</category>
--------------------
type Async<'T>
<summary>
An asynchronous computation, which, when run, will eventually produce a value of type T, or else raises an exception.
</summary>
<remarks>
This type has no members. Asynchronous computations are normally specified either by using an async expression
or the static methods in the <see cref="T:Microsoft.FSharp.Control.Async" /> type.
See also <a href="https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/asynchronous-workflows">F# Language Guide - Async Workflows</a>.
</remarks>
<namespacedoc><summary>
Library functionality for asynchronous programming, events and agents. See also
<a href="https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/asynchronous-workflows">Asynchronous Programming</a>,
<a href="https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/members/events">Events</a> and
<a href="https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/lazy-expressions">Lazy Expressions</a> in the
F# Language Guide.
</summary></namespacedoc>
<category index="1">Async Programming</category>
static member Async.Start: computation: Async<unit> * ?cancellationToken: System.Threading.CancellationToken -> unit
val query: Linq.QueryBuilder
<summary>Builds a query using query syntax and operators.</summary>
<example id="query-1"><code lang="fsharp">
let findEvensAndSortAndDouble(xs: System.Linq.IQueryable<int>) =
query {
for x in xs do
where (x % 2 = 0)
sortBy x
select (x+x)
}
let data = [1; 2; 6; 7; 3; 6; 2; 1]
findEvensAndSortAndDouble (data.AsQueryable()) |> Seq.toList
</code>
Evaluates to <c>[4; 4; 12; 12]</c>.
</example>
val apiKey: string
module HttpRequestHeaders
from FSharp.Data
<summary>
Headers that can be sent in an HTTP request
</summary>
val Accept: contentType: string -> string * string
<summary>
Content-Types that are acceptable for the response
</summary>
module HttpContentTypes
from FSharp.Data
<summary>
Constants for common HTTP content types
</summary>
[<Literal>]
val Json: string = "application/json"
<summary>
application/json
</summary>
val response: HttpResponse
static member Http.Request: url: string * ?query: (string * string) list * ?headers: seq<string * string> * ?httpMethod: string * ?body: HttpRequestBody * ?cookies: seq<string * string> * ?cookieContainer: System.Net.CookieContainer * ?silentHttpErrors: bool * ?silentCookieErrors: bool * ?responseEncodingOverride: string * ?customizeHttpRequest: (System.Net.HttpWebRequest -> System.Net.HttpWebRequest) * ?timeout: int -> HttpResponse
HttpResponse.Headers: Map<string,string>
<summary>
If the same header is present multiple times, the values will be concatenated with comma as the separator
</summary>
HttpResponse.Cookies: Map<string,string>
HttpResponse.ResponseUrl: string
HttpResponse.StatusCode: int
union case HttpRequestBody.FormValues: seq<string * string> -> HttpRequestBody
val ContentType: contentType: string -> string * string
<summary>
The MIME type of the body of the request (used with POST and PUT requests)
</summary>
union case HttpRequestBody.TextRequest: string -> HttpRequestBody
val msdnUrl: className: string -> string
val className: string
val root: string
val sprintf: format: Printf.StringFormat<'T> -> 'T
<summary>Print to a string using the given format.</summary>
<param name="format">The formatter.</param>
<returns>The formatted result.</returns>
<example>See <c>Printf.sprintf</c> (link: <see cref="M:Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThen``1" />) for examples.</example>
val docInCSharp: string
System.String.Contains(value: string) : bool
System.String.Contains(value: char) : bool
System.String.Contains(value: string, comparisonType: System.StringComparison) : bool
System.String.Contains(value: char, comparisonType: System.StringComparison) : bool
namespace System
namespace System.Net
val cc: CookieContainer
Multiple items
type CookieContainer =
new: unit -> unit + 2 overloads
member Add: cookie: Cookie -> unit + 3 overloads
member GetAllCookies: unit -> CookieCollection
member GetCookieHeader: uri: Uri -> string
member GetCookies: uri: Uri -> CookieCollection
member SetCookies: uri: Uri * cookieHeader: string -> unit
static val DefaultCookieLengthLimit: int
static val DefaultCookieLimit: int
static val DefaultPerDomainCookieLimit: int
member Capacity: int
...
<summary>Provides a container for a collection of <see cref="T:System.Net.CookieCollection" /> objects.</summary>
--------------------
CookieContainer() : CookieContainer
CookieContainer(capacity: int) : CookieContainer
CookieContainer(capacity: int, perDomainCapacity: int, maxCookieSize: int) : CookieContainer
Multiple items
namespace System.Net.Http
--------------------
type Http =
static member AsyncRequest: url: string * ?query: (string * string) list * ?headers: seq<string * string> * ?httpMethod: string * ?body: HttpRequestBody * ?cookies: seq<string * string> * ?cookieContainer: CookieContainer * ?silentHttpErrors: bool * ?silentCookieErrors: bool * ?responseEncodingOverride: string * ?customizeHttpRequest: (HttpWebRequest -> HttpWebRequest) * ?timeout: int -> Async<HttpResponse>
static member AsyncRequestStream: url: string * ?query: (string * string) list * ?headers: seq<string * string> * ?httpMethod: string * ?body: HttpRequestBody * ?cookies: seq<string * string> * ?cookieContainer: CookieContainer * ?silentHttpErrors: bool * ?silentCookieErrors: bool * ?customizeHttpRequest: (HttpWebRequest -> HttpWebRequest) * ?timeout: int -> Async<HttpResponseWithStream>
static member AsyncRequestString: url: string * ?query: (string * string) list * ?headers: seq<string * string> * ?httpMethod: string * ?body: HttpRequestBody * ?cookies: seq<string * string> * ?cookieContainer: CookieContainer * ?silentHttpErrors: bool * ?silentCookieErrors: bool * ?responseEncodingOverride: string * ?customizeHttpRequest: (HttpWebRequest -> HttpWebRequest) * ?timeout: int -> Async<string>
static member Request: url: string * ?query: (string * string) list * ?headers: seq<string * string> * ?httpMethod: string * ?body: HttpRequestBody * ?cookies: seq<string * string> * ?cookieContainer: CookieContainer * ?silentHttpErrors: bool * ?silentCookieErrors: bool * ?responseEncodingOverride: string * ?customizeHttpRequest: (HttpWebRequest -> HttpWebRequest) * ?timeout: int -> HttpResponse
static member RequestStream: url: string * ?query: (string * string) list * ?headers: seq<string * string> * ?httpMethod: string * ?body: HttpRequestBody * ?cookies: seq<string * string> * ?cookieContainer: CookieContainer * ?silentHttpErrors: bool * ?silentCookieErrors: bool * ?customizeHttpRequest: (HttpWebRequest -> HttpWebRequest) * ?timeout: int -> HttpResponseWithStream
static member RequestString: url: string * ?query: (string * string) list * ?headers: seq<string * string> * ?httpMethod: string * ?body: HttpRequestBody * ?cookies: seq<string * string> * ?cookieContainer: CookieContainer * ?silentHttpErrors: bool * ?silentCookieErrors: bool * ?responseEncodingOverride: string * ?customizeHttpRequest: (HttpWebRequest -> HttpWebRequest) * ?timeout: int -> string
<summary>
Utilities for working with network via HTTP. Includes methods for downloading
resources with specified headers, query parameters and HTTP body
</summary>
static member Http.RequestString: url: string * ?query: (string * string) list * ?headers: seq<string * string> * ?httpMethod: string * ?body: HttpRequestBody * ?cookies: seq<string * string> * ?cookieContainer: CookieContainer * ?silentHttpErrors: bool * ?silentCookieErrors: bool * ?responseEncodingOverride: string * ?customizeHttpRequest: (HttpWebRequest -> HttpWebRequest) * ?timeout: int -> string
val ignore: value: 'T -> unit
<summary>Ignore the passed value. This is often used to throw away results of a computation.</summary>
<param name="value">The value to ignore.</param>
<example id="min-example"><code lang="fsharp">
ignore 55555 // Evaluates to ()
</code></example>
val docInFSharp: string
val logoUrl: string
static member Http.Request: url: string * ?query: (string * string) list * ?headers: seq<string * string> * ?httpMethod: string * ?body: HttpRequestBody * ?cookies: seq<string * string> * ?cookieContainer: CookieContainer * ?silentHttpErrors: bool * ?silentCookieErrors: bool * ?responseEncodingOverride: string * ?customizeHttpRequest: (HttpWebRequest -> HttpWebRequest) * ?timeout: int -> HttpResponse
union case HttpResponseBody.Text: string -> HttpResponseBody
val text: string
union case HttpResponseBody.Binary: byte[] -> HttpResponseBody
val bytes: byte[]
property System.Array.Length: int with get
<summary>Gets the total number of elements in all the dimensions of the <see cref="T:System.Array" />.</summary>
<exception cref="T:System.OverflowException">The array is multidimensional and contains more than <see cref="F:System.Int32.MaxValue" /> elements.</exception>
<returns>The total number of elements in all the dimensions of the <see cref="T:System.Array" />; zero if there are no elements in the array.</returns>
namespace System.Security
namespace System.Security.Cryptography
namespace System.Security.Cryptography.X509Certificates
val clientCert: X509Certificate2
Multiple items
type X509Certificate2 =
inherit X509Certificate
new: unit -> unit + 15 overloads
member CopyWithPrivateKey: privateKey: ECDiffieHellman -> X509Certificate2
member GetECDiffieHellmanPrivateKey: unit -> ECDiffieHellman
member GetECDiffieHellmanPublicKey: unit -> ECDiffieHellman
member GetNameInfo: nameType: X509NameType * forIssuer: bool -> string
member Import: rawData: byte[] -> unit + 5 overloads
member Reset: unit -> unit
member ToString: unit -> string + 1 overload
member Verify: unit -> bool
...
<summary>Represents an X.509 certificate.</summary>
--------------------
X509Certificate2(rawData: byte[]) : X509Certificate2
(+0 other overloads)
X509Certificate2(handle: nativeint) : X509Certificate2
(+0 other overloads)
X509Certificate2(rawData: System.ReadOnlySpan<byte>) : X509Certificate2
(+0 other overloads)
X509Certificate2(certificate: X509Certificate) : X509Certificate2
(+0 other overloads)
X509Certificate2(fileName: string) : X509Certificate2
(+0 other overloads)
X509Certificate2(rawData: byte[], password: System.Security.SecureString) : X509Certificate2
(+0 other overloads)
X509Certificate2(rawData: byte[], password: string) : X509Certificate2
(+0 other overloads)
X509Certificate2(fileName: string, password: System.Security.SecureString) : X509Certificate2
(+0 other overloads)
X509Certificate2(fileName: string, password: string) : X509Certificate2
(+0 other overloads)
X509Certificate2(rawData: byte[], password: System.Security.SecureString, keyStorageFlags: X509KeyStorageFlags) : X509Certificate2
(+0 other overloads)
val req: HttpWebRequest
property HttpWebRequest.ClientCertificates: X509CertificateCollection with get, set
X509CertificateCollection.Add(value: X509Certificate) : int
val largeFilePath: string
val data: System.IO.Stream
namespace System.IO
type File =
static member AppendAllLines: path: string * contents: IEnumerable<string> -> unit + 1 overload
static member AppendAllLinesAsync: path: string * contents: IEnumerable<string> * encoding: Encoding * ?cancellationToken: CancellationToken -> Task + 1 overload
static member AppendAllText: path: string * contents: string -> unit + 1 overload
static member AppendAllTextAsync: path: string * contents: string * encoding: Encoding * ?cancellationToken: CancellationToken -> Task + 1 overload
static member AppendText: path: string -> StreamWriter
static member Copy: sourceFileName: string * destFileName: string -> unit + 1 overload
static member Create: path: string -> FileStream + 2 overloads
static member CreateSymbolicLink: path: string * pathToTarget: string -> FileSystemInfo
static member CreateText: path: string -> StreamWriter
static member Decrypt: path: string -> unit
...
<summary>Provides static methods for the creation, copying, deletion, moving, and opening of a single file, and aids in the creation of <see cref="T:System.IO.FileStream" /> objects.</summary>
System.IO.File.OpenRead(path: string) : System.IO.FileStream
type Stream =
inherit MarshalByRefObject
interface IAsyncDisposable
interface IDisposable
member BeginRead: buffer: byte[] * offset: int * count: int * callback: AsyncCallback * state: obj -> IAsyncResult
member BeginWrite: buffer: byte[] * offset: int * count: int * callback: AsyncCallback * state: obj -> IAsyncResult
member Close: unit -> unit
member CopyTo: destination: Stream -> unit + 1 overload
member CopyToAsync: destination: Stream -> Task + 3 overloads
member Dispose: unit -> unit
member DisposeAsync: unit -> ValueTask
...
<summary>Provides a generic view of a sequence of bytes. This is an abstract class.</summary>
union case HttpRequestBody.Multipart: boundary: string * parts: seq<MultipartItem> -> HttpRequestBody
<summary>
A sequence of formParamName * fileName * fileContent groups
</summary>
Multiple items
union case MultipartItem.MultipartItem: formField: string * filename: string * content: System.IO.Stream -> MultipartItem
--------------------
type MultipartItem = | MultipartItem of formField: string * filename: string * content: Stream
type Path =
static member ChangeExtension: path: string * extension: string -> string
static member Combine: path1: string * path2: string -> string + 3 overloads
static member EndsInDirectorySeparator: path: ReadOnlySpan<char> -> bool + 1 overload
static member GetDirectoryName: path: ReadOnlySpan<char> -> ReadOnlySpan<char> + 1 overload
static member GetExtension: path: ReadOnlySpan<char> -> ReadOnlySpan<char> + 1 overload
static member GetFileName: path: ReadOnlySpan<char> -> ReadOnlySpan<char> + 1 overload
static member GetFileNameWithoutExtension: path: ReadOnlySpan<char> -> ReadOnlySpan<char> + 1 overload
static member GetFullPath: path: string -> string + 1 overload
static member GetInvalidFileNameChars: unit -> char[]
static member GetInvalidPathChars: unit -> char[]
...
<summary>Performs operations on <see cref="T:System.String" /> instances that contain file or directory path information. These operations are performed in a cross-platform manner.</summary>
System.IO.Path.GetFileName(path: string) : string
System.IO.Path.GetFileName(path: System.ReadOnlySpan<char>) : System.ReadOnlySpan<char>