eugef / node-mocks-http

Mock 'http' objects for testing Express,js, Next.js and Koa routing functions
Other
755 stars 134 forks source link

Implement response.getHeaders() #217

Closed sergioregueira closed 4 years ago

sergioregueira commented 4 years ago

As commented in #211, I have just implemented the response.getHeaders() method (defined in OutgoingMessage).

Node.js specification says the method returns a shallow copy, so I serialize and parse the internal _headers object before returning it to avoid additional dependencies.

sergioregueira commented 4 years ago

Furthermore, if you agree, I would like to replace the references in unit tests to response._getHeaders() (flagged as deprecated in 2.0) with response.getHeaders() (excluding the specific tests of that method).

eugef commented 4 years ago

Hi @sergioregueira , thanks for the PR. it looks good to me. Please go ahead and do the changes in unit tests.

sergioregueira commented 4 years ago

Unit tests changed. Take a look at the other pull request before merging this one to fix the non related CI errors.

eugef commented 4 years ago

@sergioregueira could you rebase your branch against the latest master - the build should become green

sergioregueira commented 4 years ago

Branch rebased and eslint errors fixed.

eugef commented 4 years ago

Great, thanks