Skip to content

Commit

Permalink
fix 'Response header names specified via respond function should be l…
Browse files Browse the repository at this point in the history
…ower cased' (close DevExpress#1704)
  • Loading branch information
[email protected] authored and [email protected] committed Jul 31, 2018
1 parent da0bab1 commit c269be7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/request-pipeline/request-hooks/response-mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ export default class ResponseMock {
else
response._body = this.body;

response.headers = this._lowerCaseHeaderNames(response.headers);

return new IncomingMessageMock(response);
}
}
23 changes: 18 additions & 5 deletions test/server/request-hook-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,27 @@ const ConfigureResponseEventOptions = require('../../lib/session/events/configur
const noop = require('lodash').noop;

describe('ResponseMock', () => {
it('Header names should be lowercased', () => {
const body = '<html><body><h1>Test</h1></body></html>';
const mock = new ResponseMock(body, 200, { 'Access-Control-Allow-Origin': '*' });
const response = mock.getResponse();
describe('Header names should be lowercased', () => {
it('"Headers" parameter', () => {
const body = '<html><body><h1>Test</h1></body></html>';
const mock = new ResponseMock(body, 200, { 'Access-Control-Allow-Origin': '*' });
const response = mock.getResponse();

expect(response.headers['access-control-allow-origin']).eql('*');
});

expect(response.headers['access-control-allow-origin']).eql('*');
it('Respond function', () => {
const mock = new ResponseMock((req, res) => {
res.headers['Access-Control-Allow-Origin'] = '*';
});

const response = mock.getResponse();

expect(response.headers['access-control-allow-origin']).eql('*');
});
});


describe('Validation', () => {
it('Body', () => {
expect(() => {
Expand Down

0 comments on commit c269be7

Please sign in to comment.