Skip to content

Commit

Permalink
feat: echo request headers (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed May 3, 2020
1 parent cda5da0 commit 8444136
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"webpack-bundle-analyzer": "^3.7.0",
"webpack-cli": "^3.3.10",
"webpack-merge": "^4.2.2",
"yargs": "^15.1.0",
"yargs": "^15.3.1",
"yargs-parser": "^18.1.3"
},
"devDependencies": {
Expand Down
6 changes: 6 additions & 0 deletions test/utils/echo-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,10 @@ describe('echo server spec', () => {
const res = Buffer.from(await req.arrayBuffer())
expect(res).to.be.deep.eq(Buffer.from('hello world'))
})

it('get with headers', async () => {
const req = await http.get('echo/headers', { base: url, headers: { foo: 'bar' } })
const res = await req.json()
expect(res).to.deep.include({ foo: 'bar' })
})
})
3 changes: 3 additions & 0 deletions utils/echo-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class EchoServer {
.all('/echo/query', (req, res) => {
send(res, 200, req.query)
})
.all('/echo/headers', (req, res) => {
send(res, 200, req.headers)
})
.all('/echo', (req, res) => {
send(res, 200, req)
})
Expand Down

0 comments on commit 8444136

Please sign in to comment.