(ctx context.Context, req ExecuteCodeRequest)
| 155 | } |
| 156 | |
| 157 | func (c *Client) ExecuteCodeStream(ctx context.Context, req ExecuteCodeRequest) (*http.Response, error) { |
| 158 | jsonData, err := json.Marshal(req) |
| 159 | if err != nil { |
| 160 | return nil, fmt.Errorf("failed to marshal request: %v", err) |
| 161 | } |
| 162 | |
| 163 | httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, c.baseURL+"/execute/stream", bytes.NewBuffer(jsonData)) |
| 164 | if err != nil { |
| 165 | return nil, err |
| 166 | } |
| 167 | httpReq.Header.Set("Content-Type", "application/json") |
| 168 | httpReq.Header.Set("Accept", "text/event-stream") |
| 169 | |
| 170 | resp, err := c.httpClient.Do(httpReq) |
| 171 | if err != nil { |
| 172 | return nil, err |
| 173 | } |
| 174 | if resp.StatusCode != http.StatusOK { |
| 175 | defer resp.Body.Close() |
| 176 | body, _ := io.ReadAll(resp.Body) |
| 177 | return nil, fmt.Errorf("sandbox streaming failed (status %d): %s", resp.StatusCode, string(body)) |
| 178 | } |
| 179 | return resp, nil |
| 180 | } |
| 181 | |
| 182 | func (c *Client) ExecuteShell(ctx context.Context, req ShellRequest) (*ShellResponse, error) { |
| 183 | var resp ShellResponse |
no test coverage detected