Skip to content

Commit efaf864

Browse files
author
stlc-bot
committed
feat(scrape): support custom screenshot headers (#1169)
Stainless-Generated-From: 6c64f9cd8d5247e7f42ee55c9127fd80e8b8bfe6
1 parent 0d84fa4 commit efaf864

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

‎pkg/cmd/web.go‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,11 @@ var webScreenshot = requestflag.WithInnerFlags(cli.Command{
405405
Default: false,
406406
QueryPath: "handleCookiePopup",
407407
},
408+
&requestflag.Flag[map[string]any]{
409+
Name: "headers",
410+
Usage: "Optional outbound HTTP headers, using the same JSON object or deep-object query format as other scrape endpoints (for example headers[Authorization]=Bearer token). Headers are scoped to the target origin during capture. For domain/page requests, discovery receives no custom headers and only pages on the resolved origin are eligible. Non-empty headers bypass screenshot caching and return an in-memory data URL; no screenshot is uploaded. Empty objects behave like omitted headers.",
411+
QueryPath: "headers",
412+
},
408413
&requestflag.Flag[*int64]{
409414
Name: "max-age-ms",
410415
Usage: "Return a cached screenshot if a prior screenshot for the same parameters exists and is younger than this many milliseconds. Defaults to 1 day (86400000 ms) when omitted. Max is 30 days (2592000000 ms). Set to 0 to always capture fresh.",
@@ -1255,6 +1260,11 @@ var webWebScrapeScreenshot = requestflag.WithInnerFlags(cli.Command{
12551260
Default: false,
12561261
QueryPath: "handleCookiePopup",
12571262
},
1263+
&requestflag.Flag[map[string]any]{
1264+
Name: "headers",
1265+
Usage: "Optional outbound HTTP headers, using the same JSON object or deep-object query format as other scrape endpoints (for example headers[Authorization]=Bearer token). Headers are scoped to the target origin during capture. For domain/page requests, discovery receives no custom headers and only pages on the resolved origin are eligible. Non-empty headers bypass screenshot caching and return an in-memory data URL; no screenshot is uploaded. Empty objects behave like omitted headers.",
1266+
QueryPath: "headers",
1267+
},
12581268
&requestflag.Flag[*int64]{
12591269
Name: "max-age-ms",
12601270
Usage: "Return a cached screenshot if a prior screenshot for the same parameters exists and is younger than this many milliseconds. Defaults to 1 day (86400000 ms) when omitted. Max is 30 days (2592000000 ms). Set to 0 to always capture fresh.",

‎pkg/cmd/web_test.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ func TestWebScreenshot(t *testing.T) {
297297
"--domain", "xxx",
298298
"--full-screenshot", "true",
299299
"--handle-cookie-popup=true",
300+
"--headers", "{foo: J!}",
300301
"--max-age-ms", "0",
301302
"--page", "login",
302303
"--scroll-offset", "0",
@@ -325,6 +326,7 @@ func TestWebScreenshot(t *testing.T) {
325326
"--domain", "xxx",
326327
"--full-screenshot", "true",
327328
"--handle-cookie-popup=true",
329+
"--headers", "{foo: J!}",
328330
"--max-age-ms", "0",
329331
"--page", "login",
330332
"--scroll-offset", "0",
@@ -781,6 +783,7 @@ func TestWebWebScrapeScreenshot(t *testing.T) {
781783
"--country", "de",
782784
"--full-screenshot", "true",
783785
"--handle-cookie-popup=true",
786+
"--headers", "{foo: J!}",
784787
"--max-age-ms", "0",
785788
"--scroll-offset", "0",
786789
"--tag", "production",
@@ -807,6 +810,7 @@ func TestWebWebScrapeScreenshot(t *testing.T) {
807810
"--country", "de",
808811
"--full-screenshot", "true",
809812
"--handle-cookie-popup=true",
813+
"--headers", "{foo: J!}",
810814
"--max-age-ms", "0",
811815
"--scroll-offset", "0",
812816
"--tag", "production",

0 commit comments

Comments
 (0)