Directly initialize DefaultClient
This commit is contained in:
		
							parent
							
								
									7ccf75ad43
								
							
						
					
					
						commit
						365e94f06e
					
				
							
								
								
									
										14
									
								
								gemini.go
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								gemini.go
									
									
									
									
									
								
							@ -41,20 +41,18 @@ const (
 | 
			
		||||
// DefaultClient is the default client. It is used by Send.
 | 
			
		||||
//
 | 
			
		||||
// On the first request, DefaultClient will load the default list of known hosts.
 | 
			
		||||
var DefaultClient *Client
 | 
			
		||||
var DefaultClient = &Client{}
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	crlf = []byte("\r\n")
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	DefaultClient = &Client{
 | 
			
		||||
		TrustCertificate: func(hostname string, cert *x509.Certificate, knownHosts *KnownHosts) error {
 | 
			
		||||
			// Load the hosts only once. This is so that the hosts don't have to be loaded
 | 
			
		||||
			// for those using their own clients.
 | 
			
		||||
			setupDefaultClientOnce.Do(setupDefaultClient)
 | 
			
		||||
			return knownHosts.Lookup(hostname, cert)
 | 
			
		||||
		},
 | 
			
		||||
	DefaultClient.TrustCertificate = func(hostname string, cert *x509.Certificate, knownHosts *KnownHosts) error {
 | 
			
		||||
		// Load the hosts only once. This is so that the hosts don't have to be loaded
 | 
			
		||||
		// for those using their own clients.
 | 
			
		||||
		setupDefaultClientOnce.Do(setupDefaultClient)
 | 
			
		||||
		return knownHosts.Lookup(hostname, cert)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user