MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / GetHttpClientForWebSocket

Function GetHttpClientForWebSocket

base/util.go:1588–1606  ·  view source on GitHub ↗

Like GetHttpClient, and also turns off the NODELAY option on the underlying TCP socket. This is better for WebSockets and BLIP, as it allows multiple small messages to be combined in one IP packet instead of generating lots of tiny packets.

(insecureSkipVerify bool)

Source from the content-addressed store, hash-verified

1586// This is better for WebSockets and BLIP, as it allows multiple small messages to be combined in
1587// one IP packet instead of generating lots of tiny packets.
1588func GetHttpClientForWebSocket(insecureSkipVerify bool) *http.Client {
1589 transport := DefaultHTTPTransport()
1590 dial := transport.DialContext
1591 transport.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
1592 conn, err := dial(ctx, network, addr)
1593 if err == nil {
1594 turnOffNoDelay(ctx, conn)
1595 }
1596 return conn, err
1597 }
1598
1599 if insecureSkipVerify {
1600 if transport.TLSClientConfig == nil {
1601 transport.TLSClientConfig = new(tls.Config)
1602 }
1603 transport.TLSClientConfig.InsecureSkipVerify = true
1604 }
1605 return &http.Client{Transport: transport}
1606}
1607
1608// Turns off TCP NODELAY on a TCP connection.
1609// On success returns true; on failure logs a warning and returns false.

Callers 1

blipSyncFunction · 0.92

Calls 2

DefaultHTTPTransportFunction · 0.85
turnOffNoDelayFunction · 0.85

Tested by

no test coverage detected