Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/angular2/src/http/static_response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export class Response {
constructor(responseOptions: ResponseOptions) {
this._body = responseOptions.body;
this.status = responseOptions.status;
this.ok = (this.status >= 200 && this.status <= 299);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think success would be a better field name.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, let's follow the spec.

this.statusText = responseOptions.statusText;
this.headers = responseOptions.headers;
this.type = responseOptions.type;
Expand Down
24 changes: 24 additions & 0 deletions modules/angular2/test/http/static_response_spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {
describe,
expect,
it,
} from 'angular2/testing_internal';

import {ResponseOptions} from 'angular2/src/http/base_response_options';
import {Response} from 'angular2/src/http/static_response';



export function main() {
describe('Response', () => {
it('should be ok for 200 statuses', () => {
expect(new Response(new ResponseOptions({status: 200})).ok).toEqual(true);
expect(new Response(new ResponseOptions({status: 299})).ok).toEqual(true);
});

it('should not be ok for non 200 statuses', () => {
expect(new Response(new ResponseOptions({status: 199})).ok).toEqual(false);
expect(new Response(new ResponseOptions({status: 300})).ok).toEqual(false);
});
});
}