(f *MetaHeadersFrame)
| 2413 | } |
| 2414 | |
| 2415 | func (rl *clientConnReadLoop) processHeaders(f *MetaHeadersFrame) error { |
| 2416 | cs := rl.streamByID(f.StreamID) |
| 2417 | if cs == nil { |
| 2418 | // We'd get here if we canceled a request while the |
| 2419 | // server had its response still in flight. So if this |
| 2420 | // was just something we canceled, ignore it. |
| 2421 | return nil |
| 2422 | } |
| 2423 | if cs.readClosed { |
| 2424 | rl.endStreamError(cs, StreamError{ |
| 2425 | StreamID: f.StreamID, |
| 2426 | Code: ErrCodeProtocol, |
| 2427 | Cause: errors.New("protocol error: headers after END_STREAM"), |
| 2428 | }) |
| 2429 | return nil |
| 2430 | } |
| 2431 | if !cs.firstByte { |
| 2432 | if cs.trace != nil { |
| 2433 | // TODO(bradfitz): move first response byte earlier, |
| 2434 | // when we first read the 9 byte header, not waiting |
| 2435 | // until all the HEADERS+CONTINUATION frames have been |
| 2436 | // merged. This works for now. |
| 2437 | traceFirstResponseByte(cs.trace) |
| 2438 | } |
| 2439 | cs.firstByte = true |
| 2440 | } |
| 2441 | if !cs.pastHeaders { |
| 2442 | cs.pastHeaders = true |
| 2443 | } else { |
| 2444 | return rl.processTrailers(cs, f) |
| 2445 | } |
| 2446 | |
| 2447 | res, err := rl.handleResponse(cs, f) |
| 2448 | if err != nil { |
| 2449 | if _, ok := err.(ConnectionError); ok { |
| 2450 | return err |
| 2451 | } |
| 2452 | // Any other error type is a stream error. |
| 2453 | rl.endStreamError(cs, StreamError{ |
| 2454 | StreamID: f.StreamID, |
| 2455 | Code: ErrCodeProtocol, |
| 2456 | Cause: err, |
| 2457 | }) |
| 2458 | return nil // return nil from process* funcs to keep conn alive |
| 2459 | } |
| 2460 | if res == nil { |
| 2461 | // (nil, nil) special case. See handleResponse docs. |
| 2462 | return nil |
| 2463 | } |
| 2464 | cs.resTrailer = &res.Trailer |
| 2465 | cs.res = res |
| 2466 | close(cs.respHeaderRecv) |
| 2467 | if f.StreamEnded() { |
| 2468 | rl.endStream(cs) |
| 2469 | } |
| 2470 | return nil |
| 2471 | } |
| 2472 |
no test coverage detected