fix($http): return empty headers, ignore properties in Object prototype

Fix response headers with an empty value Empty response header values are legal
(http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html).

The headers getter fn will now only return null if the header property is not an own property.

Closes #7779
Closes #10113
Closes #10091
This commit is contained in:
Jamshid Afshar
2014-11-17 03:29:22 -06:00
committed by Caitlin Potter
parent f7fde935d5
commit 637c020f82
2 changed files with 17 additions and 2 deletions

View File

@@ -816,6 +816,17 @@ describe('$http', function() {
});
it('should handle empty response header', function() {
$httpBackend.expect('GET', '/url', undefined)
.respond(200, '', { 'Custom-Empty-Response-Header': '', 'Constructor': '' });
$http.get('/url').success(callback);
$httpBackend.flush();
expect(callback).toHaveBeenCalledOnce();
expect(callback.mostRecentCall.args[2]('custom-empty-response-Header')).toBe('');
expect(callback.mostRecentCall.args[2]('ToString')).toBe(null);
expect(callback.mostRecentCall.args[2]('Constructor')).toBe('');
});
it('should have delete()', function() {
$httpBackend.expect('DELETE', '/url').respond('');
$http['delete']('/url');