Skip to content

Commit

Permalink
feat: add POST headers into the header order collector (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
barjin authored Jun 9, 2023
1 parent af2cf7c commit 91bf091
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/header-order-collector/collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async function getHeadersFor(launcher, httpVersion) {
}

try {
await page.click('a', { timeout: 1000 });
await page.click('[type="submit"]', { timeout: 1000 });

const headerNames = await page.evaluate(() => {
return JSON.parse(document.body.innerText);
Expand Down
7 changes: 5 additions & 2 deletions packages/header-order-collector/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ function extractHeaderNames(rawHeaders) {
app.get('/', (req, res) => {
res.header('set-cookie', 'A=1; Path=/headers; HttpOnly');
res.send(`
<a href="/headers">Click here</a> to see the headers.
<form action="/headers" method="POST">
<input type="text" name="foo" value="bar" />
<input type="submit" value="Submit" />
</form>
`)
})

app.get('/headers', (req, res) => {
app.all('/headers', (req, res) => {
const rawHeaders = req.rawHeaders;
const headerNames = extractHeaderNames(rawHeaders);
res.json(headerNames);
Expand Down
5 changes: 4 additions & 1 deletion packages/header-order-collector/serverv2.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ server.on('stream', (stream, headers) => {
':status': 200,
});
stream.end(`
<a href="/headers">Click here</a> to see the headers.
<form action="/headers" method="POST">
<input type="text" name="foo" value="bar" />
<input type="submit" value="Submit" />
</form>
`);
});

Expand Down

0 comments on commit 91bf091

Please sign in to comment.