MCPcopy
hub / github.com/kubernetes/client-go / Negotiate

Function Negotiate

transport/spdy/spdy.go:80–94  ·  view source on GitHub ↗

Negotiate opens a connection to a remote server and attempts to negotiate a SPDY connection. Upon success, it returns the connection and the protocol selected by the server. The client transport must use the upgradeRoundTripper - see RoundTripperFor.

(upgrader Upgrader, client *http.Client, req *http.Request, protocols ...string)

Source from the content-addressed store, hash-verified

78// a SPDY connection. Upon success, it returns the connection and the protocol selected by
79// the server. The client transport must use the upgradeRoundTripper - see RoundTripperFor.
80func Negotiate(upgrader Upgrader, client *http.Client, req *http.Request, protocols ...string) (httpstream.Connection, string, error) {
81 for i := range protocols {
82 req.Header.Add(httpstream.HeaderProtocolVersion, protocols[i])
83 }
84 resp, err := client.Do(req)
85 if err != nil {
86 return nil, "", fmt.Errorf("error sending request: %v", err)
87 }
88 defer resp.Body.Close()
89 conn, err := upgrader.NewConnection(resp)
90 if err != nil {
91 return nil, "", err
92 }
93 return conn, resp.Header.Get(httpstream.HeaderProtocolVersion), nil
94}

Callers 2

StreamMethod · 0.92
DialMethod · 0.85

Calls 6

AddMethod · 0.65
DoMethod · 0.65
ErrorfMethod · 0.65
CloseMethod · 0.65
NewConnectionMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected