Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POST empty body request - 500 in @4.2.1 #402

Closed
losikov opened this issue Oct 20, 2020 · 3 comments
Closed

POST empty body request - 500 in @4.2.1 #402

losikov opened this issue Oct 20, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@losikov
Copy link

losikov commented Oct 20, 2020

Describe the bug
POST request with empty body. Expect to get 415 status code, and response body set in server.use((err, req, res, next) => {})
The issue is for 4.2.1, works as expected in 4.2.0.

To Reproduce

import request from 'supertest'
...
  it('should return 415 to a omitted request body', done => {
    request(server)
      .post('/api/v1/users/login')
      .set('Accept', 'application/json')
      .expect('Content-Type', /json/)
      .expect(415)
      .end(function(err, res) {
        console.log(res.body)
        if (err) return done(err)
        done()
      })
  })

Actual behavior
Statuc code: 500
Content-Type: text/html; charset=utf-8
Body: {}

Expected behavior
Statuc code: 415
Content-Type: application/json
Body: set in server.use((err, req, res, next) => {})

@cdimascio
Copy link
Owner

@losikov thanks for the issue. Will have a look

@cdimascio
Copy link
Owner

cdimascio commented Oct 21, 2020

This PR is the likely culprit. Feel free to have a look
#398

@cdimascio
Copy link
Owner

@losikov fixed in4.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants