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)
| 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. |
| 1588 | func 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. |
no test coverage detected