MCPcopy Index your code
hub / github.com/github/copilot-sdk / HttpRequestStart

Method HttpRequestStart

go/copilot_request_handler.go:582–630  ·  view source on GitHub ↗
(params *rpc.LlmInferenceHTTPRequestStartRequest)

Source from the content-addressed store, hash-verified

580}
581
582func (a *copilotRequestAdapter) HttpRequestStart(params *rpc.LlmInferenceHTTPRequestStartRequest) (*rpc.LlmInferenceHTTPRequestStartResult, error) {
583 // Adopt any exchange a racing chunk already created — with its buffered
584 // body — rather than dropping those frames.
585 exchange := a.getOrCreateExchange(params.RequestID)
586 ctx := exchange.ctx
587 bodyCh := make(chan CopilotWebSocketMessage)
588
589 go func() {
590 defer close(bodyCh)
591 for {
592 m, ok := exchange.queue.pop()
593 if !ok {
594 return
595 }
596 select {
597 case bodyCh <- m:
598 case <-ctx.Done():
599 return
600 }
601 }
602 }()
603
604 transport := "http"
605 if params.Transport != nil {
606 transport = string(*params.Transport)
607 }
608 sessionID := ""
609 if params.SessionID != nil {
610 sessionID = *params.SessionID
611 }
612 headers := http.Header{}
613 for k, v := range params.Headers {
614 headers[k] = append([]string(nil), v...)
615 }
616
617 rctx := &CopilotRequestContext{
618 RequestID: params.RequestID,
619 SessionID: sessionID,
620 Method: params.Method,
621 URL: params.URL,
622 Headers: headers,
623 Transport: transport,
624 body: bodyCh,
625 Context: ctx,
626 }
627 sink := &responseSink{requestID: params.RequestID, adapter: a, exchange: exchange}
628 go a.runHandler(rctx, sink, exchange)
629 return &rpc.LlmInferenceHTTPRequestStartResult{}, nil
630}
631
632func (a *copilotRequestAdapter) HttpRequestChunk(params *rpc.LlmInferenceHTTPRequestChunkRequest) (*rpc.LlmInferenceHTTPRequestChunkResult, error) {
633 // May arrive before the matching start frame (frames are dispatched on

Callers

nothing calls this directly

Calls 5

getOrCreateExchangeMethod · 0.95
runHandlerMethod · 0.95
popMethod · 0.80
DoneMethod · 0.65
closeFunction · 0.50

Tested by

no test coverage detected