diff options
Diffstat (limited to 'vendor/google.golang.org/grpc/transport/http2_client.go')
-rw-r--r-- | vendor/google.golang.org/grpc/transport/http2_client.go | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/vendor/google.golang.org/grpc/transport/http2_client.go b/vendor/google.golang.org/grpc/transport/http2_client.go index 3c18554..2b0f680 100644 --- a/vendor/google.golang.org/grpc/transport/http2_client.go +++ b/vendor/google.golang.org/grpc/transport/http2_client.go @@ -57,6 +57,7 @@ import ( type http2Client struct { target string // server name/addr userAgent string + md interface{} conn net.Conn // underlying communication channel authInfo credentials.AuthInfo // auth info about the connection nextID uint32 // the next stream ID to be used @@ -107,7 +108,7 @@ type http2Client struct { prevGoAwayID uint32 } -func dial(fn func(context.Context, string) (net.Conn, error), ctx context.Context, addr string) (net.Conn, error) { +func dial(ctx context.Context, fn func(context.Context, string) (net.Conn, error), addr string) (net.Conn, error) { if fn != nil { return fn(ctx, addr) } @@ -145,9 +146,9 @@ func isTemporary(err error) bool { // newHTTP2Client constructs a connected ClientTransport to addr based on HTTP2 // and starts to receive messages on it. Non-nil error returns if construction // fails. -func newHTTP2Client(ctx context.Context, addr string, opts ConnectOptions) (_ ClientTransport, err error) { +func newHTTP2Client(ctx context.Context, addr TargetInfo, opts ConnectOptions) (_ ClientTransport, err error) { scheme := "http" - conn, err := dial(opts.Dialer, ctx, addr) + conn, err := dial(ctx, opts.Dialer, addr.Addr) if err != nil { return nil, connectionErrorf(true, err, "transport: %v", err) } @@ -160,7 +161,7 @@ func newHTTP2Client(ctx context.Context, addr string, opts ConnectOptions) (_ Cl var authInfo credentials.AuthInfo if creds := opts.TransportCredentials; creds != nil { scheme = "https" - conn, authInfo, err = creds.ClientHandshake(ctx, addr, conn) + conn, authInfo, err = creds.ClientHandshake(ctx, addr.Addr, conn) if err != nil { // Credentials handshake errors are typically considered permanent // to avoid retrying on e.g. bad certificates. @@ -174,8 +175,9 @@ func newHTTP2Client(ctx context.Context, addr string, opts ConnectOptions) (_ Cl } var buf bytes.Buffer t := &http2Client{ - target: addr, + target: addr.Addr, userAgent: ua, + md: addr.Metadata, conn: conn, authInfo: authInfo, // The client initiated stream id is odd starting from 1. @@ -400,6 +402,16 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Strea } } } + if md, ok := t.md.(*metadata.MD); ok { + for k, v := range *md { + if isReservedHeader(k) { + continue + } + for _, entry := range v { + t.hEnc.WriteField(hpack.HeaderField{Name: k, Value: entry}) + } + } + } first := true // Sends the headers in a single batch even when they span multiple frames. for !endHeaders { @@ -790,6 +802,9 @@ func (t *http2Client) handleSettings(f *http2.SettingsFrame) { } func (t *http2Client) handlePing(f *http2.PingFrame) { + if f.IsAck() { // Do nothing. + return + } pingAck := &ping{ack: true} copy(pingAck.data[:], f.Data[:]) t.controlBuf.put(pingAck) |