Skip to content

Commit

Permalink
fix(ajax): Fix case-insensitive headers in HTTP request
Browse files Browse the repository at this point in the history
In RFC 7230 and RFC 7540 is written, that HTTP headers is case-insensitive, so this is fix for correct serializing request body base on HTTP headers.
  • Loading branch information
Tomas Dostal committed Jan 15, 2019
1 parent f150e95 commit e00d126
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/observables/dom/ajax-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,26 @@ describe('ajax', () => {
expect(MockXMLHttpRequest.mostRecent.data).to.equal('{"🌟":"🚀"}');
});

it('should send json body not mattered on case-sensitivity of HTTP headers', () => {
const body = {
hello: 'world'
};

const requestObj = {
url: '/flibbertyJibbet',
method: '',
body: body,
headers: {
'cOnTeNt-TyPe': 'application/json; charset=UTF-8'
}
};

ajax(requestObj).subscribe();

expect(MockXMLHttpRequest.mostRecent.url).to.equal('/flibbertyJibbet');
expect(MockXMLHttpRequest.mostRecent.data).to.equal('{"hello":"world"}');
});

it('should error if send request throws', (done: MochaDone) => {
const expected = new Error('xhr send failure');

Expand Down

0 comments on commit e00d126

Please sign in to comment.