Skip to content

Commit

Permalink
fix: send response body with status text for invalid methods
Browse files Browse the repository at this point in the history
  • Loading branch information
tinfoil-knight authored and danez committed Jan 3, 2023
1 parent c5eac34 commit 00f6ef2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/commands/dev/dev.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const startStaticServer = async ({ settings }) => {
server.addHook('onRequest', (req, reply, done) => {
const validMethods = ['GET', 'HEAD']
if (!validMethods.includes(req.method)) {
reply.code(405).send()
reply.code(405).send('Method Not Allowed')
}
done()
})
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/500.command.dev.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ test('should handle form submission with a background function', async (t) => {
})
})

test('should not handle form submission when content type is `text/plain`', async (t) => {
test.only('should not handle form submission when content type is `text/plain`', async (t) => {
await withSiteBuilder('site-with-form-text-plain', async (builder) => {
builder
.withContentFile({
Expand Down Expand Up @@ -197,6 +197,7 @@ test('should not handle form submission when content type is `text/plain`', asyn
},
})
.catch((error) => error.response)
t.is(response.statusCode, 405)
t.is(response.body, 'Method Not Allowed')
})
})
Expand Down

0 comments on commit 00f6ef2

Please sign in to comment.