Skip to content

Commit b60a2c7

Browse files
authored
Release 0.6.0 (#225)
1 parent 92f597b commit b60a2c7

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,22 @@ const html = template(templateData);
125125
const pdf = await htmlPdf.create(html, options);
126126
```
127127

128+
### HTTP Headers
129+
130+
Specify additional headers you wish to send with your request via `CreateOptions.extraHTTPHeaders`.
131+
132+
```js
133+
const options: HtmlPdf.CreateOptions = {
134+
port: 9222, // port Chrome is listening on
135+
extraHTTPHeaders: {
136+
'Authorization': 'Bearer 123',
137+
'X-Custom-Test-Header': 'This is great!',
138+
},
139+
};
140+
141+
const pdf = await HtmlPdf.create('https://httpbin.org/headers', options);
142+
```
143+
128144
### Custom Headers and Footers
129145

130146
_Note: Requires Chrome 65 or later._

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "html-pdf-chrome",
3-
"version": "0.5.0",
3+
"version": "0.6.0",
44
"description": "HTML to PDF converter via Chrome/Chromium",
55
"main": "lib/src/index.js",
66
"scripts": {

test/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,21 @@ describe('HtmlPdf', () => {
121121
expect(pdf.getRawTextContent()).to.startWith('Cookies:status=Passed!');
122122
});
123123

124-
it('should generate a PDF and send extra http headers', async () => {
124+
it('should generate a PDF and send extra HTTP headers', async () => {
125125
const options: HtmlPdf.CreateOptions = {
126126
port,
127127
extraHTTPHeaders: {
128-
'X-Custom-Test-Header1' : 'Passed1!',
129-
'X-Custom-Test-Header2' : 'Passed2!',
128+
'Authorization': 'Bearer 123',
129+
'X-Custom-Test-Header': 'Passed1!',
130130
},
131131
};
132132

133-
const result = await HtmlPdf.create('http://httpbin.org/headers', options);
133+
const result = await HtmlPdf.create('https://httpbin.org/headers', options);
134134
const pdf = await getParsedPdf(result.toBuffer());
135135
const rawTextContent = pdf.getRawTextContent();
136136

137-
expect(rawTextContent).to.contain('X-Custom-Test-Header1').and.to.contain('Passed1!');
138-
expect(rawTextContent).to.contain('X-Custom-Test-Header2').and.to.contain('Passed2!');
137+
expect(rawTextContent).to.contain('Authorization').and.to.contain('Bearer 123');
138+
expect(rawTextContent).to.contain('X-Custom-Test-Header').and.to.contain('Passed1!');
139139
});
140140

141141
it('should proxy console messages', async () => {

0 commit comments

Comments
 (0)