Include trailing newline in response headers to match browsers.

- Some libraries are relying on it existing, even though the specs
  doesn't say it should.

Fix #91
This commit is contained in:
slackersoft 2015-01-23 13:11:42 -08:00
parent e7ae7e02de
commit 2d0bf42151
4 changed files with 9 additions and 9 deletions

View File

@ -257,7 +257,7 @@ getJasmineRequireObj().AjaxFakeRequest = function() {
responseHeaders.push(this.responseHeaders[i].name + ': ' +
this.responseHeaders[i].value);
}
return responseHeaders.join('\r\n');
return responseHeaders.join('\r\n') + '\r\n';
},
responseText: null,

View File

@ -535,8 +535,8 @@ describe('FakeRequest', function() {
request1.respondWith({ status: 200, responseHeaders: { 'X-Foo': 'bar' } });
request2.respondWith({ status: 200, responseHeaders: { 'X-Baz': 'quux' } });
expect(request1.getAllResponseHeaders()).toBe('X-Foo: bar');
expect(request2.getAllResponseHeaders()).toBe('X-Baz: quux');
expect(request1.getAllResponseHeaders()).toBe("X-Foo: bar\r\n");
expect(request2.getAllResponseHeaders()).toBe("X-Baz: quux\r\n");
});
it('retrieves all response headers', function() {
@ -553,7 +553,7 @@ describe('FakeRequest', function() {
]
});
expect(request.getAllResponseHeaders()).toBe("X-Header-1: foo\r\nX-Header-2: bar\r\nX-Header-1: baz");
expect(request.getAllResponseHeaders()).toBe("X-Header-1: foo\r\nX-Header-2: bar\r\nX-Header-1: baz\r\n");
});
it('sets the content-type header to the specified contentType when no other headers are supplied', function() {
@ -564,7 +564,7 @@ describe('FakeRequest', function() {
request.respondWith({ status: 200, contentType: 'text/plain' });
expect(request.getResponseHeader('content-type')).toBe('text/plain');
expect(request.getAllResponseHeaders()).toBe('Content-Type: text/plain');
expect(request.getAllResponseHeaders()).toBe("Content-Type: text/plain\r\n");
});
it('sets a default content-type header if no contentType and headers are supplied', function() {
@ -575,7 +575,7 @@ describe('FakeRequest', function() {
request.respondWith({ status: 200 });
expect(request.getResponseHeader('content-type')).toBe('application/json');
expect(request.getAllResponseHeaders()).toBe('Content-Type: application/json');
expect(request.getAllResponseHeaders()).toBe("Content-Type: application/json\r\n");
});
it('has no responseXML by default', function() {

View File

@ -267,7 +267,7 @@ describe("Jasmine Mock Ajax (for toplevel)", function() {
"X-Header1: header 1 value",
"X-Header2: header 2 value",
"X-Header3: header 3 value"
].join("\r\n"));
].join("\r\n") + "\r\n");
});
});
@ -295,7 +295,7 @@ describe("Jasmine Mock Ajax (for toplevel)", function() {
expect(response.getAllResponseHeaders()).toBe([
"X-Header: header value 1",
"X-Header: header value 2"
].join("\r\n"));
].join("\r\n") + "\r\n");
});
});

View File

@ -212,7 +212,7 @@ getJasmineRequireObj().AjaxFakeRequest = function() {
responseHeaders.push(this.responseHeaders[i].name + ': ' +
this.responseHeaders[i].value);
}
return responseHeaders.join('\r\n');
return responseHeaders.join('\r\n') + '\r\n';
},
responseText: null,