Make Client safe for concurrent use
This commit is contained in:
parent
0c75e5d5ad
commit
4b653032e4
@ -9,10 +9,13 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Client is a Gemini client.
|
// Client is a Gemini client.
|
||||||
|
//
|
||||||
|
// Clients are safe for concurrent use by multiple goroutines.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
// KnownHosts is a list of known hosts.
|
// KnownHosts is a list of known hosts.
|
||||||
KnownHosts KnownHostsFile
|
KnownHosts KnownHostsFile
|
||||||
@ -59,6 +62,8 @@ type Client struct {
|
|||||||
// If TrustCertificate returns TrustAlways, the certificate will also be
|
// If TrustCertificate returns TrustAlways, the certificate will also be
|
||||||
// written to the known hosts file.
|
// written to the known hosts file.
|
||||||
TrustCertificate func(hostname string, cert *x509.Certificate) Trust
|
TrustCertificate func(hostname string, cert *x509.Certificate) Trust
|
||||||
|
|
||||||
|
mu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get performs a Gemini request for the given url.
|
// Get performs a Gemini request for the given url.
|
||||||