(status int, statusTxt string, headers http.Header)
| 729 | } |
| 730 | |
| 731 | func (s *responseSink) start(status int, statusTxt string, headers http.Header) error { |
| 732 | s.exchange.mu.Lock() |
| 733 | if s.exchange.started { |
| 734 | s.exchange.mu.Unlock() |
| 735 | return fmt.Errorf("CopilotRequestHandler response sink Start() called twice") |
| 736 | } |
| 737 | if s.exchange.finished { |
| 738 | s.exchange.mu.Unlock() |
| 739 | return fmt.Errorf("CopilotRequestHandler response sink already finished") |
| 740 | } |
| 741 | s.exchange.started = true |
| 742 | s.exchange.mu.Unlock() |
| 743 | |
| 744 | api, err := s.rpcAPI() |
| 745 | if err != nil { |
| 746 | return err |
| 747 | } |
| 748 | var st *string |
| 749 | if statusTxt != "" { |
| 750 | st = &statusTxt |
| 751 | } |
| 752 | h := map[string][]string(headers) |
| 753 | if h == nil { |
| 754 | h = map[string][]string{} |
| 755 | } |
| 756 | _, err = api.HttpResponseStart(context.Background(), &rpc.LlmInferenceHTTPResponseStartRequest{ |
| 757 | RequestID: s.requestID, |
| 758 | Status: int64(status), |
| 759 | StatusText: st, |
| 760 | Headers: h, |
| 761 | }) |
| 762 | return err |
| 763 | } |
| 764 | |
| 765 | func (s *responseSink) writeText(data []byte) error { |
| 766 | return s.writeRaw(string(data), false) |
no test coverage detected