Skip to content

Commit d112191

Browse files
rgarciaclaude
andcommitted
fix: address bugbot review comments for browser curl
- Pass encoding param to /curl/raw endpoint (was silently ignored) - Print response headers to stdout when -i and -o are combined - Remove unused client field from BrowsersCmd Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7f8cece commit d112191

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

cmd/browsers.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ type BrowsersCmd struct {
228228
logs BrowserLogService
229229
computer BrowserComputerService
230230
playwright BrowserPlaywrightService
231-
client *kernel.Client
232231
}
233232

234233
type BrowsersListInput struct {
@@ -3384,6 +3383,9 @@ func (b BrowsersCmd) curlRaw(ctx context.Context, in BrowsersCurlInput) error {
33843383
params.Set("url", in.URL)
33853384
params.Set("method", method)
33863385
params.Set("timeout_ms", fmt.Sprintf("%d", in.TimeoutMs))
3386+
if in.Encoding != "" {
3387+
params.Set("response_encoding", in.Encoding)
3388+
}
33873389

33883390
// Add custom headers as query params
33893391
for _, h := range in.Headers {
@@ -3442,6 +3444,16 @@ func (b BrowsersCmd) curlRaw(ctx context.Context, in BrowsersCurlInput) error {
34423444
return fmt.Errorf("not found (%d): %s", resp.StatusCode, strings.TrimSpace(string(respBody)))
34433445
}
34443446

3447+
if in.Include {
3448+
fmt.Fprintf(os.Stdout, "HTTP %d\n", resp.StatusCode)
3449+
for k, vals := range resp.Header {
3450+
for _, v := range vals {
3451+
fmt.Fprintf(os.Stdout, "%s: %s\n", k, v)
3452+
}
3453+
}
3454+
fmt.Fprintln(os.Stdout)
3455+
}
3456+
34453457
if in.OutputFile != "" {
34463458
f, err := os.Create(in.OutputFile)
34473459
if err != nil {
@@ -3458,16 +3470,6 @@ func (b BrowsersCmd) curlRaw(ctx context.Context, in BrowsersCurlInput) error {
34583470
return nil
34593471
}
34603472

3461-
if in.Include {
3462-
fmt.Fprintf(os.Stdout, "HTTP %d\n", resp.StatusCode)
3463-
for k, vals := range resp.Header {
3464-
for _, v := range vals {
3465-
fmt.Fprintf(os.Stdout, "%s: %s\n", k, v)
3466-
}
3467-
}
3468-
fmt.Fprintln(os.Stdout)
3469-
}
3470-
34713473
_, err = io.Copy(os.Stdout, resp.Body)
34723474
return err
34733475
}
@@ -3500,7 +3502,7 @@ func runBrowsersCurl(cmd *cobra.Command, args []string) error {
35003502
silent, _ := cmd.Flags().GetBool("silent")
35013503
jsonOutput, _ := cmd.Flags().GetBool("json")
35023504

3503-
b := BrowsersCmd{browsers: &svc, client: &client}
3505+
b := BrowsersCmd{browsers: &svc}
35043506
return b.Curl(cmd.Context(), BrowsersCurlInput{
35053507
Identifier: args[0],
35063508
URL: args[1],

0 commit comments

Comments
 (0)