@browserless.io/browserless 2.20.2 → 2.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -1
- package/bin/browserless.js +2 -1
- package/build/browserless.js +3 -2
- package/build/browsers/index.d.ts +3 -2
- package/build/browsers/index.js +3 -1
- package/build/routes/chrome/http/content.post.body.json +8 -8
- package/build/routes/chrome/http/pdf.post.body.json +8 -8
- package/build/routes/chrome/http/scrape.post.body.json +8 -8
- package/build/routes/chrome/http/screenshot.post.body.json +8 -8
- package/build/routes/chrome/tests/pdf.spec.js +24 -12
- package/build/routes/chromium/http/content.post.body.json +8 -8
- package/build/routes/chromium/http/pdf.post.body.json +8 -8
- package/build/routes/chromium/http/scrape.post.body.json +8 -8
- package/build/routes/chromium/http/screenshot.post.body.json +8 -8
- package/build/routes/chromium/tests/pdf.spec.js +24 -12
- package/build/shared/pdf.http.js +10 -5
- package/docker/sdk/Dockerfile +11 -0
- package/extensions/ublock/_locales/ar/messages.json +5 -1
- package/extensions/ublock/_locales/az/messages.json +4 -0
- package/extensions/ublock/_locales/be/messages.json +4 -0
- package/extensions/ublock/_locales/bg/messages.json +4 -0
- package/extensions/ublock/_locales/bn/messages.json +4 -0
- package/extensions/ublock/_locales/br_FR/messages.json +9 -5
- package/extensions/ublock/_locales/bs/messages.json +4 -0
- package/extensions/ublock/_locales/ca/messages.json +5 -1
- package/extensions/ublock/_locales/cs/messages.json +4 -0
- package/extensions/ublock/_locales/cv/messages.json +4 -0
- package/extensions/ublock/_locales/cy/messages.json +4 -0
- package/extensions/ublock/_locales/da/messages.json +4 -0
- package/extensions/ublock/_locales/de/messages.json +4 -0
- package/extensions/ublock/_locales/el/messages.json +8 -4
- package/extensions/ublock/_locales/en/messages.json +4 -0
- package/extensions/ublock/_locales/en_GB/messages.json +4 -0
- package/extensions/ublock/_locales/eo/messages.json +9 -5
- package/extensions/ublock/_locales/es/messages.json +4 -0
- package/extensions/ublock/_locales/et/messages.json +4 -0
- package/extensions/ublock/_locales/eu/messages.json +4 -0
- package/extensions/ublock/_locales/fa/messages.json +4 -0
- package/extensions/ublock/_locales/fi/messages.json +6 -2
- package/extensions/ublock/_locales/fil/messages.json +4 -0
- package/extensions/ublock/_locales/fr/messages.json +4 -0
- package/extensions/ublock/_locales/fy/messages.json +4 -0
- package/extensions/ublock/_locales/gl/messages.json +12 -8
- package/extensions/ublock/_locales/gu/messages.json +4 -0
- package/extensions/ublock/_locales/he/messages.json +4 -0
- package/extensions/ublock/_locales/hi/messages.json +4 -0
- package/extensions/ublock/_locales/hr/messages.json +4 -0
- package/extensions/ublock/_locales/hu/messages.json +68 -64
- package/extensions/ublock/_locales/hy/messages.json +4 -0
- package/extensions/ublock/_locales/id/messages.json +6 -2
- package/extensions/ublock/_locales/it/messages.json +4 -0
- package/extensions/ublock/_locales/ja/messages.json +4 -0
- package/extensions/ublock/_locales/ka/messages.json +4 -0
- package/extensions/ublock/_locales/kk/messages.json +4 -0
- package/extensions/ublock/_locales/kn/messages.json +4 -0
- package/extensions/ublock/_locales/ko/messages.json +4 -0
- package/extensions/ublock/_locales/lt/messages.json +4 -0
- package/extensions/ublock/_locales/lv/messages.json +4 -0
- package/extensions/ublock/_locales/mk/messages.json +4 -0
- package/extensions/ublock/_locales/ml/messages.json +4 -0
- package/extensions/ublock/_locales/mr/messages.json +4 -0
- package/extensions/ublock/_locales/ms/messages.json +4 -0
- package/extensions/ublock/_locales/nb/messages.json +4 -0
- package/extensions/ublock/_locales/nl/messages.json +4 -0
- package/extensions/ublock/_locales/no/messages.json +4 -0
- package/extensions/ublock/_locales/oc/messages.json +4 -0
- package/extensions/ublock/_locales/pa/messages.json +8 -4
- package/extensions/ublock/_locales/pl/messages.json +4 -0
- package/extensions/ublock/_locales/pt_BR/messages.json +4 -0
- package/extensions/ublock/_locales/pt_PT/messages.json +4 -0
- package/extensions/ublock/_locales/ro/messages.json +4 -0
- package/extensions/ublock/_locales/ru/messages.json +4 -0
- package/extensions/ublock/_locales/si/messages.json +4 -0
- package/extensions/ublock/_locales/sk/messages.json +4 -0
- package/extensions/ublock/_locales/sl/messages.json +4 -0
- package/extensions/ublock/_locales/so/messages.json +4 -0
- package/extensions/ublock/_locales/sq/messages.json +4 -0
- package/extensions/ublock/_locales/sr/messages.json +6 -2
- package/extensions/ublock/_locales/sv/messages.json +4 -0
- package/extensions/ublock/_locales/sw/messages.json +4 -0
- package/extensions/ublock/_locales/ta/messages.json +4 -0
- package/extensions/ublock/_locales/te/messages.json +4 -0
- package/extensions/ublock/_locales/th/messages.json +4 -0
- package/extensions/ublock/_locales/tr/messages.json +4 -0
- package/extensions/ublock/_locales/uk/messages.json +4 -0
- package/extensions/ublock/_locales/ur/messages.json +4 -0
- package/extensions/ublock/_locales/vi/messages.json +4 -0
- package/extensions/ublock/_locales/zh_CN/messages.json +4 -0
- package/extensions/ublock/_locales/zh_TW/messages.json +5 -1
- package/extensions/ublock/assets/assets.json +8 -6
- package/extensions/ublock/assets/resources/scriptlets.js +455 -301
- package/extensions/ublock/assets/thirdparties/easylist/easylist.txt +4441 -6643
- package/extensions/ublock/assets/thirdparties/easylist/easyprivacy.txt +401 -307
- package/extensions/ublock/assets/thirdparties/pgl.yoyo.org/as/serverlist +34 -29
- package/extensions/ublock/assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat +682 -709
- package/extensions/ublock/assets/thirdparties/urlhaus-filter/urlhaus-filter-online.txt +2439 -1999
- package/extensions/ublock/assets/ublock/badlists.txt +7 -0
- package/extensions/ublock/assets/ublock/badware.min.txt +992 -552
- package/extensions/ublock/assets/ublock/filters.min.txt +1253 -864
- package/extensions/ublock/assets/ublock/privacy.min.txt +58 -31
- package/extensions/ublock/assets/ublock/quick-fixes.min.txt +118 -126
- package/extensions/ublock/assets/ublock/unbreak.min.txt +129 -109
- package/extensions/ublock/js/background.js +4 -3
- package/extensions/ublock/js/benchmarks.js +29 -29
- package/extensions/ublock/js/codemirror/ubo-static-filtering.js +1 -0
- package/extensions/ublock/js/contextmenu.js +20 -21
- package/extensions/ublock/js/devtools.js +137 -3
- package/extensions/ublock/js/filtering-context.js +98 -43
- package/extensions/ublock/js/logger-ui.js +1 -1
- package/extensions/ublock/js/messaging.js +57 -135
- package/extensions/ublock/js/pagestore.js +44 -31
- package/extensions/ublock/js/redirect-resources.js +14 -4
- package/extensions/ublock/js/scriptlet-filtering.js +4 -1
- package/extensions/ublock/js/static-filtering-parser.js +107 -37
- package/extensions/ublock/js/static-net-filtering.js +514 -250
- package/extensions/ublock/js/storage.js +2 -1
- package/extensions/ublock/js/traffic.js +8 -4
- package/extensions/ublock/js/vapi-background.js +1 -0
- package/extensions/ublock/js/vapi-common.js +1 -0
- package/extensions/ublock/logger-ui.html +2 -3
- package/extensions/ublock/manifest.json +2 -2
- package/extensions/ublock/support.html +1 -0
- package/extensions/ublock/web_accessible_resources/noop-vast2.xml +1 -0
- package/extensions/ublock/web_accessible_resources/noop-vast3.xml +1 -0
- package/extensions/ublock/web_accessible_resources/noop-vast4.xml +1 -0
- package/package.json +17 -17
- package/src/browserless.ts +3 -2
- package/src/browsers/index.ts +2 -0
- package/src/routes/chrome/tests/pdf.spec.ts +24 -12
- package/src/routes/chromium/tests/pdf.spec.ts +24 -12
- package/src/shared/pdf.http.ts +10 -6
- package/static/docs/swagger.json +10 -10
- package/static/docs/swagger.min.json +9 -9
- package/static/function/client.js +9 -9
- package/static/function/index.html +9 -9
- /package/extensions/ublock/web_accessible_resources/{noop-vmap1.0.xml → noop-vmap1.xml} +0 -0
|
@@ -319,7 +319,8 @@ onBroadcast(msg => {
|
|
|
319
319
|
cnameIgnoreRootDocument: µbhs.cnameIgnoreRootDocument,
|
|
320
320
|
cnameMaxTTL: µbhs.cnameMaxTTL,
|
|
321
321
|
cnameReplayFullURL: µbhs.cnameReplayFullURL,
|
|
322
|
-
|
|
322
|
+
dnsCacheTTL: µbhs.dnsCacheTTL,
|
|
323
|
+
dnsResolveEnabled: µbhs.dnsResolveEnabled,
|
|
323
324
|
});
|
|
324
325
|
});
|
|
325
326
|
|
|
@@ -188,17 +188,20 @@ const onBeforeRootFrameRequest = function(fctxt) {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
if ( logger.enabled ) {
|
|
191
|
-
fctxt.setFilter(logData);
|
|
191
|
+
fctxt.setRealm('network').setFilter(logData);
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/760
|
|
195
195
|
// Redirect non-blocked request?
|
|
196
|
-
if (
|
|
197
|
-
|
|
196
|
+
if ( trusted === false && pageStore !== null ) {
|
|
197
|
+
if ( result !== 1 ) {
|
|
198
|
+
pageStore.redirectNonBlockedRequest(fctxt);
|
|
199
|
+
}
|
|
200
|
+
pageStore.skipMainDocument(fctxt);
|
|
198
201
|
}
|
|
199
202
|
|
|
200
203
|
if ( logger.enabled ) {
|
|
201
|
-
fctxt.
|
|
204
|
+
fctxt.toLogger();
|
|
202
205
|
}
|
|
203
206
|
|
|
204
207
|
// Redirected
|
|
@@ -680,6 +683,7 @@ const bodyFilterer = (( ) => {
|
|
|
680
683
|
const sessions = new Map();
|
|
681
684
|
const reContentTypeCharset = /charset=['"]?([^'" ]+)/i;
|
|
682
685
|
const otherValidMimes = new Set([
|
|
686
|
+
'application/dash+xml',
|
|
683
687
|
'application/javascript',
|
|
684
688
|
'application/json',
|
|
685
689
|
'application/mpegurl',
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
<input type="search" placeholder="logFilterPrompt" spellcheck="false">
|
|
62
62
|
<span id="filterExprButton" class="button fa-icon expanded" data-i18n-title="loggerRowFiltererBuiltinTip">angle-up</span>
|
|
63
63
|
<div id="filterExprPicker">
|
|
64
|
-
<div><span data-filtex="!" data-i18n="loggerRowFiltererBuiltinNot"></span><span data-filtex="\x1F--\x1F|\x1F<<\x1F|\x1F##" data-i18n="loggerRowFiltererBuiltinBlocked"></span><span data-filtex="\x1F\+\+\x1F|\x1F\*\*\x1F|\x1F#@#" data-i18n="loggerRowFiltererBuiltinAllowed"></span><span data-filtex="[$,](?:csp|permissions|removeparam|redirect-rule|replace|
|
|
64
|
+
<div><span data-filtex="!" data-i18n="loggerRowFiltererBuiltinNot"></span><span data-filtex="\x1F--\x1F|\x1F<<\x1F|\x1F##" data-i18n="loggerRowFiltererBuiltinBlocked"></span><span data-filtex="\x1F\+\+\x1F|\x1F\*\*\x1F|\x1F#@#" data-i18n="loggerRowFiltererBuiltinAllowed"></span><span data-filtex="[$,](?:csp|permissions|removeparam|redirect-rule|replace|urlskip|ur[il]transform)=|\x1F\<\<\x1F" data-i18n="loggerRowFiltererBuiltinModified"></span></div>
|
|
65
65
|
<div><span data-filtex="!" data-i18n="loggerRowFiltererBuiltinNot"></span>
|
|
66
66
|
<span style="flex-direction: column;">
|
|
67
67
|
<div><span data-filtex="\x1F(?:css|(?:inline-)?font)\x1F">css/font</span><span data-filtex="\x1Fimage\x1F">image</span><span data-filtex="\x1Fmedia\x1F">media</span><span data-filtex="\x1F(?:inline-)?script(?:ing)?\x1F">script</span></div>
|
|
@@ -72,8 +72,7 @@
|
|
|
72
72
|
<div><span data-filtex="!" data-i18n="loggerRowFiltererBuiltinNot"></span><span data-filtex="\x1Fget\x1F">get</span><span data-filtex="\x1Fhead\x1F">head</span><span data-filtex="\x1Fpost\x1F">post</span></div>
|
|
73
73
|
<div><span data-filtex="!" data-i18n="loggerRowFiltererBuiltinNot" class="on"></span>
|
|
74
74
|
<span style="flex-direction: column;">
|
|
75
|
-
<
|
|
76
|
-
<div><span data-filtex="\bremoveparam=[^\x1F]+\x1F(?:--|\+\+)\x1F">removeparam</span><span data-filtex="\buritransform=[^\x1F]+\x1F(?:--|\+\+)\x1F">uritransform</span></div>
|
|
75
|
+
<span data-filtex="\bcsp=[^\x1F]+\x1F(?:--|\+\+)\x1F">csp</span><span data-filtex="\bpermissions=[^\x1F]+\x1F(?:--|\+\+)\x1F" class="on">permissions</span><span data-filtex="\bredirect-rule=[^\x1F]+\x1F(?:--|\+\+)\x1F">redirect</span><span data-filtex="\bremoveparam=[^\x1F]+\x1F(?:--|\+\+)\x1F">removeparam</span><span data-filtex="\breplace=[^\x1F]+\x1F(?:--|\+\+)\x1F">replace</span><span data-filtex="\burlskip=[^\x1F]+\x1F(?:--|\+\+)\x1F">urlskip</span>
|
|
77
76
|
</span>
|
|
78
77
|
</div>
|
|
79
78
|
<div id="filterExprCnameOf" style="display:none"><span data-filtex="!" data-i18n="loggerRowFiltererBuiltinNot"></span><span data-filtex="\x1FaliasURL=.">CNAME</span></div>
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
},
|
|
90
90
|
"incognito": "split",
|
|
91
91
|
"manifest_version": 2,
|
|
92
|
-
"minimum_chrome_version": "
|
|
92
|
+
"minimum_chrome_version": "80.0",
|
|
93
93
|
"name": "uBlock Origin",
|
|
94
94
|
"options_ui": {
|
|
95
95
|
"open_in_tab": true,
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"storage": {
|
|
112
112
|
"managed_schema": "managed_storage.json"
|
|
113
113
|
},
|
|
114
|
-
"version": "1.
|
|
114
|
+
"version": "1.60.0",
|
|
115
115
|
"web_accessible_resources": [
|
|
116
116
|
"/web_accessible_resources/*"
|
|
117
117
|
]
|
|
@@ -93,6 +93,7 @@
|
|
|
93
93
|
<option value="nuisance" data-i18n="supportS6Select1Option2"></option>
|
|
94
94
|
<option value="breakage" data-i18n="supportS6Select1Option5"></option>
|
|
95
95
|
<option value="privacy" data-i18n="supportS6Select1Option4"></option>
|
|
96
|
+
<option value="badware" data-i18n="supportS6Select1Option7"></option>
|
|
96
97
|
</select>
|
|
97
98
|
</p>
|
|
98
99
|
<p>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<VAST version="2.0"></VAST>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<VAST version="3.0"></VAST>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<VAST version="4.0"></VAST>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@browserless.io/browserless",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.21.1",
|
|
4
4
|
"license": "SSPL",
|
|
5
5
|
"description": "The browserless platform",
|
|
6
6
|
"author": "browserless.io",
|
|
@@ -53,16 +53,16 @@
|
|
|
53
53
|
"enjoi": "^9.0.1",
|
|
54
54
|
"file-type": "^19.5.0",
|
|
55
55
|
"get-port": "^7.1.0",
|
|
56
|
-
"gradient-string": "^
|
|
56
|
+
"gradient-string": "^3.0.0",
|
|
57
57
|
"http-proxy": "^1.18.1",
|
|
58
58
|
"lighthouse": "^12.2.1",
|
|
59
59
|
"micromatch": "^4.0.8",
|
|
60
|
-
"playwright-1.41": "npm:playwright-core@1.41.2",
|
|
61
|
-
"playwright-1.42": "npm:playwright-core@1.42.1",
|
|
62
60
|
"playwright-1.43": "npm:playwright-core@1.43.1",
|
|
63
61
|
"playwright-1.44": "npm:playwright-core@1.44.1",
|
|
64
|
-
"playwright-
|
|
65
|
-
"
|
|
62
|
+
"playwright-1.45": "npm:playwright-core@1.45.3",
|
|
63
|
+
"playwright-1.46": "npm:playwright-core@1.46.1",
|
|
64
|
+
"playwright-core": "^1.47.2",
|
|
65
|
+
"puppeteer-core": "^23.4.1",
|
|
66
66
|
"puppeteer-extra": "^3.3.6",
|
|
67
67
|
"puppeteer-extra-plugin-stealth": "^2.11.2",
|
|
68
68
|
"queue": "^7.0.0",
|
|
@@ -70,41 +70,41 @@
|
|
|
70
70
|
"tar-fs": "^3.0.6"
|
|
71
71
|
},
|
|
72
72
|
"optionalDependencies": {
|
|
73
|
-
"@types/chai": "^
|
|
73
|
+
"@types/chai": "^5.0.0",
|
|
74
74
|
"@types/debug": "^4.1.12",
|
|
75
75
|
"@types/gradient-string": "^1.1.6",
|
|
76
76
|
"@types/http-proxy": "^1.17.15",
|
|
77
77
|
"@types/micromatch": "^4.0.9",
|
|
78
78
|
"@types/mocha": "^10.0.8",
|
|
79
|
-
"@types/node": "^22.
|
|
79
|
+
"@types/node": "^22.7.4",
|
|
80
80
|
"@types/sinon": "^17.0.3",
|
|
81
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
82
|
-
"@typescript-eslint/parser": "^8.
|
|
81
|
+
"@typescript-eslint/eslint-plugin": "^8.8.0",
|
|
82
|
+
"@typescript-eslint/parser": "^8.8.0",
|
|
83
83
|
"assert": "^2.0.0",
|
|
84
84
|
"chai": "^5.1.1",
|
|
85
85
|
"cross-env": "^7.0.3",
|
|
86
86
|
"env-cmd": "^10.1.0",
|
|
87
|
-
"esbuild": "^0.
|
|
87
|
+
"esbuild": "^0.24.0",
|
|
88
88
|
"esbuild-plugin-polyfill-node": "^0.3.0",
|
|
89
|
-
"eslint": "^9.
|
|
89
|
+
"eslint": "^9.11.1",
|
|
90
90
|
"extract-zip": "^2.0.1",
|
|
91
91
|
"gunzip-maybe": "^1.4.2",
|
|
92
92
|
"marked": "^14.1.2",
|
|
93
93
|
"mocha": "^10.7.3",
|
|
94
94
|
"move-file": "^3.1.0",
|
|
95
95
|
"prettier": "^3.3.3",
|
|
96
|
-
"sinon": "^19.0.
|
|
96
|
+
"sinon": "^19.0.2",
|
|
97
97
|
"ts-node": "^10.9.2",
|
|
98
98
|
"typescript": "^5.6.2",
|
|
99
99
|
"typescript-json-schema": "^0.65.1"
|
|
100
100
|
},
|
|
101
101
|
"playwrightVersions": {
|
|
102
102
|
"default": "playwright-core",
|
|
103
|
-
"1.
|
|
103
|
+
"1.47": "playwright-core",
|
|
104
|
+
"1.46": "playwright-1.46",
|
|
105
|
+
"1.45": "playwright-1.45",
|
|
104
106
|
"1.44": "playwright-1.44",
|
|
105
|
-
"1.43": "playwright-1.43"
|
|
106
|
-
"1.42": "playwright-1.42",
|
|
107
|
-
"1.41": "playwright-1.41"
|
|
107
|
+
"1.43": "playwright-1.43"
|
|
108
108
|
},
|
|
109
109
|
"eslintConfig": {
|
|
110
110
|
"root": true,
|
package/src/browserless.ts
CHANGED
|
@@ -103,10 +103,11 @@ export class Browserless extends EventEmitter {
|
|
|
103
103
|
this.token = token || new Token(this.config);
|
|
104
104
|
this.hooks = hooks || new Hooks();
|
|
105
105
|
this.webhooks = webhooks || new WebHooks(this.config);
|
|
106
|
-
this.browserManager =
|
|
107
|
-
browserManager || new BrowserManager(this.config, this.hooks);
|
|
108
106
|
this.monitoring = monitoring || new Monitoring(this.config);
|
|
109
107
|
this.fileSystem = fileSystem || new FileSystem(this.config);
|
|
108
|
+
this.browserManager =
|
|
109
|
+
browserManager ||
|
|
110
|
+
new BrowserManager(this.config, this.hooks, this.fileSystem);
|
|
110
111
|
this.limiter =
|
|
111
112
|
limiter ||
|
|
112
113
|
new Limiter(
|
package/src/browsers/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
ChromiumCDP,
|
|
15
15
|
ChromiumPlaywright,
|
|
16
16
|
Config,
|
|
17
|
+
FileSystem,
|
|
17
18
|
FirefoxPlaywright,
|
|
18
19
|
HTTPManagementRoutes,
|
|
19
20
|
Hooks,
|
|
@@ -51,6 +52,7 @@ export class BrowserManager {
|
|
|
51
52
|
constructor(
|
|
52
53
|
protected config: Config,
|
|
53
54
|
protected hooks: Hooks,
|
|
55
|
+
protected fileSystem: FileSystem,
|
|
54
56
|
) {}
|
|
55
57
|
|
|
56
58
|
protected browserIsChrome(b: BrowserInstance) {
|
|
@@ -31,7 +31,8 @@ describe('/chrome/pdf API', function () {
|
|
|
31
31
|
'content-type': 'application/json',
|
|
32
32
|
},
|
|
33
33
|
method: 'POST',
|
|
34
|
-
}).then((res) => {
|
|
34
|
+
}).then(async (res) => {
|
|
35
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
35
36
|
expect(res.headers.get('x-response-code')).to.not.be.undefined;
|
|
36
37
|
expect(res.headers.get('x-response-url')).to.not.be.undefined;
|
|
37
38
|
expect(res.headers.get('x-response-ip')).to.not.be.undefined;
|
|
@@ -75,7 +76,8 @@ describe('/chrome/pdf API', function () {
|
|
|
75
76
|
'content-type': 'application/json',
|
|
76
77
|
},
|
|
77
78
|
method: 'POST',
|
|
78
|
-
}).then((res) => {
|
|
79
|
+
}).then(async (res) => {
|
|
80
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
79
81
|
expect(res.headers.get('content-type')).to.equal('application/pdf');
|
|
80
82
|
expect(res.status).to.equal(200);
|
|
81
83
|
});
|
|
@@ -99,7 +101,8 @@ describe('/chrome/pdf API', function () {
|
|
|
99
101
|
'content-type': 'application/json',
|
|
100
102
|
},
|
|
101
103
|
method: 'POST',
|
|
102
|
-
}).then((res) => {
|
|
104
|
+
}).then(async (res) => {
|
|
105
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
103
106
|
expect(res.headers.get('content-type')).to.equal('application/pdf');
|
|
104
107
|
expect(res.status).to.equal(200);
|
|
105
108
|
});
|
|
@@ -123,7 +126,8 @@ describe('/chrome/pdf API', function () {
|
|
|
123
126
|
'content-type': 'application/json',
|
|
124
127
|
},
|
|
125
128
|
method: 'POST',
|
|
126
|
-
}).then((res) => {
|
|
129
|
+
}).then(async (res) => {
|
|
130
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
127
131
|
expect(res.headers.get('content-type')).to.equal('application/pdf');
|
|
128
132
|
expect(res.status).to.equal(200);
|
|
129
133
|
});
|
|
@@ -150,7 +154,8 @@ describe('/chrome/pdf API', function () {
|
|
|
150
154
|
'content-type': 'application/json',
|
|
151
155
|
},
|
|
152
156
|
method: 'POST',
|
|
153
|
-
}).then((res) => {
|
|
157
|
+
}).then(async (res) => {
|
|
158
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
154
159
|
expect(res.headers.get('content-type')).to.equal('application/pdf');
|
|
155
160
|
expect(res.status).to.equal(200);
|
|
156
161
|
});
|
|
@@ -172,7 +177,8 @@ describe('/chrome/pdf API', function () {
|
|
|
172
177
|
'content-type': 'application/json',
|
|
173
178
|
},
|
|
174
179
|
method: 'POST',
|
|
175
|
-
}).then((res) => {
|
|
180
|
+
}).then(async (res) => {
|
|
181
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
176
182
|
expect(res.headers.get('content-type')).to.equal('application/pdf');
|
|
177
183
|
expect(res.status).to.equal(200);
|
|
178
184
|
});
|
|
@@ -255,7 +261,8 @@ describe('/chrome/pdf API', function () {
|
|
|
255
261
|
'content-type': 'application/json',
|
|
256
262
|
},
|
|
257
263
|
method: 'POST',
|
|
258
|
-
}).then((res) => {
|
|
264
|
+
}).then(async (res) => {
|
|
265
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
259
266
|
expect(res.headers.get('content-type')).to.equal('application/pdf');
|
|
260
267
|
expect(res.status).to.equal(200);
|
|
261
268
|
});
|
|
@@ -279,7 +286,8 @@ describe('/chrome/pdf API', function () {
|
|
|
279
286
|
'content-type': 'application/json',
|
|
280
287
|
},
|
|
281
288
|
method: 'POST',
|
|
282
|
-
}).then((res) => {
|
|
289
|
+
}).then(async (res) => {
|
|
290
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
283
291
|
expect(res.headers.get('content-type')).to.equal('application/pdf');
|
|
284
292
|
expect(res.status).to.equal(200);
|
|
285
293
|
});
|
|
@@ -300,7 +308,8 @@ describe('/chrome/pdf API', function () {
|
|
|
300
308
|
'content-type': 'application/json',
|
|
301
309
|
},
|
|
302
310
|
method: 'POST',
|
|
303
|
-
}).then((res) => {
|
|
311
|
+
}).then(async (res) => {
|
|
312
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
304
313
|
expect(res.headers.get('content-type')).to.equal('application/pdf');
|
|
305
314
|
expect(res.status).to.equal(200);
|
|
306
315
|
});
|
|
@@ -324,7 +333,8 @@ describe('/chrome/pdf API', function () {
|
|
|
324
333
|
'content-type': 'application/json',
|
|
325
334
|
},
|
|
326
335
|
method: 'POST',
|
|
327
|
-
}).then((res) => {
|
|
336
|
+
}).then(async (res) => {
|
|
337
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
328
338
|
expect(res.headers.get('content-type')).to.equal('application/pdf');
|
|
329
339
|
expect(res.status).to.equal(200);
|
|
330
340
|
});
|
|
@@ -350,7 +360,8 @@ describe('/chrome/pdf API', function () {
|
|
|
350
360
|
'content-type': 'application/json',
|
|
351
361
|
},
|
|
352
362
|
method: 'POST',
|
|
353
|
-
}).then((res) => {
|
|
363
|
+
}).then(async (res) => {
|
|
364
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
354
365
|
expect(res.headers.get('content-type')).to.equal('application/pdf');
|
|
355
366
|
expect(res.status).to.equal(200);
|
|
356
367
|
});
|
|
@@ -368,7 +379,8 @@ describe('/chrome/pdf API', function () {
|
|
|
368
379
|
'content-type': 'application/json',
|
|
369
380
|
},
|
|
370
381
|
method: 'POST',
|
|
371
|
-
}).then((res) => {
|
|
382
|
+
}).then(async (res) => {
|
|
383
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
372
384
|
expect(res.headers.get('x-response-code')).to.not.be.undefined;
|
|
373
385
|
expect(res.headers.get('x-response-url')).to.not.be.undefined;
|
|
374
386
|
expect(res.headers.get('x-response-ip')).to.not.be.undefined;
|
|
@@ -31,7 +31,8 @@ describe('/chromium/pdf API', function () {
|
|
|
31
31
|
'content-type': 'application/json; charset=utf-8',
|
|
32
32
|
},
|
|
33
33
|
method: 'POST',
|
|
34
|
-
}).then((res) => {
|
|
34
|
+
}).then(async (res) => {
|
|
35
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
35
36
|
expect(res.headers.get('x-response-code')).to.not.be.undefined;
|
|
36
37
|
expect(res.headers.get('x-response-url')).to.not.be.undefined;
|
|
37
38
|
expect(res.headers.get('x-response-ip')).to.not.be.undefined;
|
|
@@ -75,7 +76,8 @@ describe('/chromium/pdf API', function () {
|
|
|
75
76
|
'content-type': 'application/json',
|
|
76
77
|
},
|
|
77
78
|
method: 'POST',
|
|
78
|
-
}).then((res) => {
|
|
79
|
+
}).then(async (res) => {
|
|
80
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
79
81
|
expect(res.headers.get('content-type')).to.equal('application/pdf');
|
|
80
82
|
expect(res.status).to.equal(200);
|
|
81
83
|
});
|
|
@@ -99,7 +101,8 @@ describe('/chromium/pdf API', function () {
|
|
|
99
101
|
'content-type': 'application/json',
|
|
100
102
|
},
|
|
101
103
|
method: 'POST',
|
|
102
|
-
}).then((res) => {
|
|
104
|
+
}).then(async (res) => {
|
|
105
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
103
106
|
expect(res.headers.get('content-type')).to.equal('application/pdf');
|
|
104
107
|
expect(res.status).to.equal(200);
|
|
105
108
|
});
|
|
@@ -123,7 +126,8 @@ describe('/chromium/pdf API', function () {
|
|
|
123
126
|
'content-type': 'application/json',
|
|
124
127
|
},
|
|
125
128
|
method: 'POST',
|
|
126
|
-
}).then((res) => {
|
|
129
|
+
}).then(async (res) => {
|
|
130
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
127
131
|
expect(res.headers.get('content-type')).to.equal('application/pdf');
|
|
128
132
|
expect(res.status).to.equal(200);
|
|
129
133
|
});
|
|
@@ -150,7 +154,8 @@ describe('/chromium/pdf API', function () {
|
|
|
150
154
|
'content-type': 'application/json',
|
|
151
155
|
},
|
|
152
156
|
method: 'POST',
|
|
153
|
-
}).then((res) => {
|
|
157
|
+
}).then(async (res) => {
|
|
158
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
154
159
|
expect(res.headers.get('content-type')).to.equal('application/pdf');
|
|
155
160
|
expect(res.status).to.equal(200);
|
|
156
161
|
});
|
|
@@ -172,7 +177,8 @@ describe('/chromium/pdf API', function () {
|
|
|
172
177
|
'content-type': 'application/json',
|
|
173
178
|
},
|
|
174
179
|
method: 'POST',
|
|
175
|
-
}).then((res) => {
|
|
180
|
+
}).then(async (res) => {
|
|
181
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
176
182
|
expect(res.headers.get('content-type')).to.equal('application/pdf');
|
|
177
183
|
expect(res.status).to.equal(200);
|
|
178
184
|
});
|
|
@@ -255,7 +261,8 @@ describe('/chromium/pdf API', function () {
|
|
|
255
261
|
'content-type': 'application/json',
|
|
256
262
|
},
|
|
257
263
|
method: 'POST',
|
|
258
|
-
}).then((res) => {
|
|
264
|
+
}).then(async (res) => {
|
|
265
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
259
266
|
expect(res.headers.get('content-type')).to.equal('application/pdf');
|
|
260
267
|
expect(res.status).to.equal(200);
|
|
261
268
|
});
|
|
@@ -279,7 +286,8 @@ describe('/chromium/pdf API', function () {
|
|
|
279
286
|
'content-type': 'application/json',
|
|
280
287
|
},
|
|
281
288
|
method: 'POST',
|
|
282
|
-
}).then((res) => {
|
|
289
|
+
}).then(async (res) => {
|
|
290
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
283
291
|
expect(res.headers.get('content-type')).to.equal('application/pdf');
|
|
284
292
|
expect(res.status).to.equal(200);
|
|
285
293
|
});
|
|
@@ -300,7 +308,8 @@ describe('/chromium/pdf API', function () {
|
|
|
300
308
|
'content-type': 'application/json',
|
|
301
309
|
},
|
|
302
310
|
method: 'POST',
|
|
303
|
-
}).then((res) => {
|
|
311
|
+
}).then(async (res) => {
|
|
312
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
304
313
|
expect(res.headers.get('content-type')).to.equal('application/pdf');
|
|
305
314
|
expect(res.status).to.equal(200);
|
|
306
315
|
});
|
|
@@ -324,7 +333,8 @@ describe('/chromium/pdf API', function () {
|
|
|
324
333
|
'content-type': 'application/json',
|
|
325
334
|
},
|
|
326
335
|
method: 'POST',
|
|
327
|
-
}).then((res) => {
|
|
336
|
+
}).then(async (res) => {
|
|
337
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
328
338
|
expect(res.headers.get('content-type')).to.equal('application/pdf');
|
|
329
339
|
expect(res.status).to.equal(200);
|
|
330
340
|
});
|
|
@@ -350,7 +360,8 @@ describe('/chromium/pdf API', function () {
|
|
|
350
360
|
'content-type': 'application/json',
|
|
351
361
|
},
|
|
352
362
|
method: 'POST',
|
|
353
|
-
}).then((res) => {
|
|
363
|
+
}).then(async (res) => {
|
|
364
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
354
365
|
expect(res.headers.get('content-type')).to.equal('application/pdf');
|
|
355
366
|
expect(res.status).to.equal(200);
|
|
356
367
|
});
|
|
@@ -368,7 +379,8 @@ describe('/chromium/pdf API', function () {
|
|
|
368
379
|
'content-type': 'application/json',
|
|
369
380
|
},
|
|
370
381
|
method: 'POST',
|
|
371
|
-
}).then((res) => {
|
|
382
|
+
}).then(async (res) => {
|
|
383
|
+
await res.body?.pipeTo(new WritableStream({}));
|
|
372
384
|
expect(res.headers.get('x-response-code')).to.not.be.undefined;
|
|
373
385
|
expect(res.headers.get('x-response-url')).to.not.be.undefined;
|
|
374
386
|
expect(res.headers.get('x-response-ip')).to.not.be.undefined;
|
package/src/shared/pdf.http.ts
CHANGED
|
@@ -29,7 +29,6 @@ import {
|
|
|
29
29
|
} from '@browserless.io/browserless';
|
|
30
30
|
import { Page } from 'puppeteer-core';
|
|
31
31
|
import { ServerResponse } from 'http';
|
|
32
|
-
import { Stream } from 'stream';
|
|
33
32
|
|
|
34
33
|
export interface BodySchema {
|
|
35
34
|
addScriptTag?: Array<Parameters<Page['addScriptTag']>[0]>;
|
|
@@ -237,11 +236,16 @@ export default class ChromiumPDFPostRoute extends BrowserHTTPRoute {
|
|
|
237
236
|
}
|
|
238
237
|
}
|
|
239
238
|
|
|
240
|
-
const
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
239
|
+
const pdfStream = await page.createPDFStream(options);
|
|
240
|
+
const writableStream = new WritableStream({
|
|
241
|
+
write(chunk) {
|
|
242
|
+
res.write(chunk);
|
|
243
|
+
},
|
|
244
|
+
close() {
|
|
245
|
+
res.end();
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
await pdfStream.pipeTo(writableStream);
|
|
245
249
|
|
|
246
250
|
page.close().catch(noop);
|
|
247
251
|
|