greetWithSettings initiates the client's HTTP/2 connection with custom settings.
(settings ...http2.Setting)
| 96 | |
| 97 | // greetWithSettings initiates the client's HTTP/2 connection with custom settings. |
| 98 | func (st *serverTester) greetWithSettings(settings ...http2.Setting) { |
| 99 | st.writePreface() |
| 100 | if len(settings) > 0 { |
| 101 | if err := st.fr.WriteSettings(settings...); err != nil { |
| 102 | st.t.Fatalf("Error writing initial SETTINGS frame from client to server: %v", err) |
| 103 | } |
| 104 | } else { |
| 105 | st.writeInitialSettings() |
| 106 | } |
| 107 | st.wantSettings() |
| 108 | st.writeSettingsAck() |
| 109 | for { |
| 110 | f, err := st.readFrame() |
| 111 | if err != nil { |
| 112 | st.t.Fatal(err) |
| 113 | } |
| 114 | switch f := f.(type) { |
| 115 | case *http2.WindowUpdateFrame: |
| 116 | // grpc's transport/http2_server sends this |
| 117 | // before the settings ack. The Go http2 |
| 118 | // server uses a setting instead. |
| 119 | case *http2.SettingsFrame: |
| 120 | if f.IsAck() { |
| 121 | return |
| 122 | } |
| 123 | st.t.Fatalf("during greet, got non-ACK settings frame") |
| 124 | default: |
| 125 | st.t.Fatalf("during greet, unexpected frame type %T", f) |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | func (st *serverTester) writePreface() { |
| 131 | n, err := st.cc.Write([]byte(http2.ClientPreface)) |