(c net.Conn, fr *fasthttp2.FrameHeader, symbol byte)
| 117 | } |
| 118 | |
| 119 | func debugFrame(c net.Conn, fr *fasthttp2.FrameHeader, symbol byte) { |
| 120 | bf := bytes.NewBuffer(nil) |
| 121 | |
| 122 | fmt.Fprintf(bf, "%c %d - %s\n", symbol, fr.Stream(), c.RemoteAddr()) |
| 123 | fmt.Fprintf(bf, "%c %d\n", symbol, fr.Len()) |
| 124 | fmt.Fprintf(bf, "%c EndStream: %v\n", symbol, fr.HasFlag(fasthttp2.FlagEndStream)) |
| 125 | |
| 126 | switch fr.Type() { |
| 127 | case fasthttp2.FrameHeaders: |
| 128 | fmt.Fprintf(bf, "%c [HEADERS]\n", symbol) |
| 129 | h := fasthttp2.AcquireHeaders() |
| 130 | h.ReadFrame(fr) |
| 131 | debugHeaders(bf, h, symbol) |
| 132 | fasthttp2.ReleaseHeaders(h) |
| 133 | case fasthttp2.FrameContinuation: |
| 134 | println("continuation") |
| 135 | case fasthttp2.FrameData: |
| 136 | fmt.Fprintf(bf, "%c [DATA]\n", symbol) |
| 137 | data := fasthttp2.AcquireData() |
| 138 | data.ReadFrame(fr) |
| 139 | debugData(bf, data, symbol) |
| 140 | fasthttp2.ReleaseData(data) |
| 141 | case fasthttp2.FramePriority: |
| 142 | println("priority") |
| 143 | // TODO: If a PRIORITY frame is received with a stream identifier of 0x0, the recipient MUST respond with a connection error |
| 144 | case fasthttp2.FrameResetStream: |
| 145 | println("reset") |
| 146 | case fasthttp2.FrameSettings: |
| 147 | fmt.Fprintf(bf, "%c [SETTINGS]\n", symbol) |
| 148 | st := fasthttp2.AcquireSettings() |
| 149 | st.ReadFrame(fr) |
| 150 | debugSettings(bf, st, symbol) |
| 151 | fasthttp2.ReleaseSettings(st) |
| 152 | case fasthttp2.FramePushPromise: |
| 153 | println("pp") |
| 154 | case fasthttp2.FramePing: |
| 155 | println("ping") |
| 156 | case fasthttp2.FrameGoAway: |
| 157 | println("away") |
| 158 | case fasthttp2.FrameWindowUpdate: |
| 159 | fmt.Fprintf(bf, "%c [WINDOW_UPDATE]\n", symbol) |
| 160 | wu := fasthttp2.AcquireWindowUpdate() |
| 161 | wu.ReadFrame(fr) |
| 162 | fmt.Fprintf(bf, "%c Increment: %d\n", symbol, wu.Increment()) |
| 163 | fasthttp2.ReleaseWindowUpdate(wu) |
| 164 | } |
| 165 | |
| 166 | fmt.Println(bf.String()) |
| 167 | } |
| 168 | |
| 169 | func debugSettings(bf *bytes.Buffer, st *fasthttp2.Settings, symbol byte) { |
| 170 | fmt.Fprintf(bf, "%c ACK: %v\n", symbol, st.IsAck()) |
no test coverage detected