Combine request headers with the same name
This commit is contained in:
parent
80af85b4cf
commit
0b2b4a4a2e
@ -185,7 +185,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
},
|
||||
|
||||
setRequestHeader: function(header, value) {
|
||||
this.requestHeaders[header] = value;
|
||||
if(this.requestHeaders.hasOwnProperty(header)) {
|
||||
this.requestHeaders[header] = [this.requestHeaders[header], value].join(', ');
|
||||
} else {
|
||||
this.requestHeaders[header] = value;
|
||||
}
|
||||
},
|
||||
|
||||
abort: function() {
|
||||
|
@ -37,6 +37,12 @@ describe("FakeXMLHttpRequest", function() {
|
||||
expect(xhr.requestHeaders['X-Header-1']).toEqual('one');
|
||||
});
|
||||
|
||||
it('should combine request headers with the same header name', function() {
|
||||
xhr.setRequestHeader('X-Header-1', 'two');
|
||||
expect(objectKeys(xhr.requestHeaders).length).toEqual(1);
|
||||
expect(xhr.requestHeaders['X-Header-1']).toEqual('one, two');
|
||||
});
|
||||
|
||||
describe("when setting headers on another xhr object", function() {
|
||||
beforeEach(function() {
|
||||
xhr2.setRequestHeader('X-Header-2', 'two');
|
||||
|
Loading…
Reference in New Issue
Block a user