go.net.http
1.26.10.1
dotnet add package go.net.http --version 1.26.10.1
NuGet\Install-Package go.net.http -Version 1.26.10.1
<PackageReference Include="go.net.http" Version="1.26.10.1" />
<PackageVersion Include="go.net.http" Version="1.26.10.1" />
<PackageReference Include="go.net.http" />
paket add go.net.http --version 1.26.10.1
#r "nuget: go.net.http, 1.26.10.1"
#:package go.net.http@1.26.10.1
#addin nuget:?package=go.net.http&version=1.26.10.1
#tool nuget:?package=go.net.http&version=1.26.10.1
go.net.http
C# package converted from the Go standard library by go2cs.
From C#, call this package through the static class go.net.http_package; see Consuming converted Go from C#.
Package http provides HTTP client and server implementations.
[Get], [Head], [Post], and [PostForm] make HTTP (or HTTPS) requests:
resp, err := http.Get("http://example.com/")
...
resp, err := http.Post("http://example.com/upload", "image/jpeg", &buf)
...
resp, err := http.PostForm("http://example.com/form",
url.Values{"key": {"Value"}, "id": {"123"}})
The caller must close the response body when finished with it:
resp, err := http.Get("http://example.com/")
if err != nil {
// handle error
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
// ...
Clients and Transports
For control over HTTP client headers, redirect policy, and other settings, create a [Client]:
client := &http.Client{
CheckRedirect: redirectPolicyFunc,
}
resp, err := client.Get("http://example.com")
// ...
req, err := http.NewRequest("GET", "http://example.com", nil)
// ...
req.Header.Add("If-None-Match", `W/"wyzzy"`)
resp, err := client.Do(req)
// ...
For control over proxies, TLS configuration, keep-alives, compression, and other settings, create a [Transport]:
tr := &http.Transport{
MaxIdleConns: 10,
IdleConnTimeout: 30 * time.Second,
DisableCompression: true,
}
client := &http.Client{Transport: tr}
resp, err := client.Get("https://example.com")
Clients and Transports are safe for concurrent use by multiple goroutines and for efficiency should only be created once and re-used.
Servers
ListenAndServe starts an HTTP server with a given address and handler. The handler is usually nil, which means to use [DefaultServeMux]. [Handle] and [HandleFunc] add handlers to [DefaultServeMux]:
http.Handle("/foo", fooHandler)
http.HandleFunc("/bar", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
})
log.Fatal(http.ListenAndServe(":8080", nil))
More control over the server's behavior is available by creating a custom Server:
s := &http.Server{
Addr: ":8080",
Handler: myHandler,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
log.Fatal(s.ListenAndServe())
HTTP/2
The http package has transparent support for the HTTP/2 protocol.
[Server] and [DefaultTransport] automatically enable HTTP/2 support when using HTTPS. [Transport] does not enable HTTP/2 by default.
To enable or disable support for HTTP/1, HTTP/2, and/or unencrypted HTTP/2, see the [Server.Protocols] and [Transport.Protocols] configuration fields.
To configure advanced HTTP/2 features, see the [Server.HTTP2] and [Transport.HTTP2] configuration fields.
Alternatively, the following GODEBUG settings are currently supported:
GODEBUG=http2client=0 # disable HTTP/2 client support
GODEBUG=http2server=0 # disable HTTP/2 server support
GODEBUG=http2debug=1 # enable verbose HTTP/2 debug logs
GODEBUG=http2debug=2 # ... even more verbose, with frame dumps
The "omithttp2" build tag may be used to disable the HTTP/2 implementation contained in the http package.
Copyright 2009 The Go Authors. All rights reserved. This C# package is converted from Go standard library source; use of that source is governed by a BSD-style license that can be found in the LICENSE file.
Artwork licensed under Creative Commons Attribution 3.0; see artwork attribution.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- go.bufio (>= 1.26.10.1)
- go.bytes (>= 1.26.10.1)
- go.compress.flate (>= 1.26.10.1)
- go.compress.gzip (>= 1.26.10.1)
- go.container.list (>= 1.26.10.1)
- go.context (>= 1.26.10.1)
- go.crypto.rand (>= 1.26.10.1)
- go.crypto.tls (>= 1.26.10.1)
- go.encoding.base64 (>= 1.26.10.1)
- go.encoding.binary (>= 1.26.10.1)
- go.errors (>= 1.26.10.1)
- go.fmt (>= 1.26.10.1)
- go.internal.godebug (>= 1.26.10.1)
- go.io (>= 1.26.10.1)
- go.io.fs (>= 1.26.10.1)
- go.lib (>= 1.26.10.1)
- go.log (>= 1.26.10.1)
- go.maps (>= 1.26.10.1)
- go.math (>= 1.26.10.1)
- go.math.bits (>= 1.26.10.1)
- go.math.rand (>= 1.26.10.1)
- go.mime (>= 1.26.10.1)
- go.mime.multipart (>= 1.26.10.1)
- go.net (>= 1.26.10.1)
- go.net.http.httptrace (>= 1.26.10.1)
- go.net.http.internal (>= 1.26.10.1)
- go.net.http.internal.ascii (>= 1.26.10.1)
- go.net.http.internal.httpcommon (>= 1.26.10.1)
- go.net.textproto (>= 1.26.10.1)
- go.net.url (>= 1.26.10.1)
- go.os (>= 1.26.10.1)
- go.path (>= 1.26.10.1)
- go.path.filepath (>= 1.26.10.1)
- go.reflect (>= 1.26.10.1)
- go.runtime (>= 1.26.10.1)
- go.slices (>= 1.26.10.1)
- go.sort (>= 1.26.10.1)
- go.strconv (>= 1.26.10.1)
- go.strings (>= 1.26.10.1)
- go.sync (>= 1.26.10.1)
- go.sync.atomic (>= 1.26.10.1)
- go.time (>= 1.26.10.1)
- go.unicode (>= 1.26.10.1)
- go.unicode.utf8 (>= 1.26.10.1)
- go.unsafe (>= 1.26.10.1)
- go.vendor.golang.org.x.net.http.httpguts (>= 1.26.10.1)
- go.vendor.golang.org.x.net.http.httpproxy (>= 1.26.10.1)
- go.vendor.golang.org.x.net.http2.hpack (>= 1.26.10.1)
- go.vendor.golang.org.x.net.idna (>= 1.26.10.1)
NuGet packages (10)
Showing the top 5 NuGet packages that depend on go.net.http:
| Package | Downloads |
|---|---|
|
go.net.rpc
net.rpc (net10.0 - Release) -- C# project converted from Go source |
|
|
go.net.http.cgi
net.http.cgi (net10.0 - Release) -- C# project converted from Go source |
|
|
go.net.http.pprof
net.http.pprof (net10.0 - Release) -- C# project converted from Go source |
|
|
go.net.http.fcgi
net.http.fcgi (net10.0 - Release) -- C# project converted from Go source |
|
|
go.net.http.cookiejar
net.http.cookiejar (net10.0 - Release) -- C# project converted from Go source |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.26.10.1 | 32 | 10/26/2026 |
| 1.24.13.7 | 174 | 10/14/2026 |
| 1.24.13.6 | 175 | 10/12/2026 |
| 1.24.13.5 | 186 | 10/9/2026 |
| 1.24.13.4 | 178 | 10/6/2026 |
| 1.24.13.3 | 182 | 10/2/2026 |
| 1.24.13.2 | 185 | 9/24/2026 |
| 1.24.13.1 | 179 | 9/24/2026 |
| 1.23.12.3 | 220 | 9/8/2026 |
| 1.23.12.2 | 209 | 8/29/2026 |
| 1.23.12.1 | 215 | 8/26/2026 |
| 1.23.1.7 | 280 | 8/23/2026 |
| 1.23.1.6 | 242 | 8/11/2026 |
| 1.23.1.5 | 250 | 8/9/2026 |
| 1.23.1.4 | 244 | 8/8/2026 |
| 1.23.1.3 | 281 | 8/4/2026 |
| 1.23.1.2 | 271 | 7/27/2026 |
| 1.23.1.1 | 283 | 7/14/2026 |