p.location-badge. exported from angular2/http defined in angular2/src/http/backends/mock_backend.ts (line 6) :markdown Connection class used by MockBackend This class is typically not instantiated directly, but instances can be retrieved by subscribing to the `connections` Observable of MockBackend in order to mock responses to requests. .l-main-section h2 Members .l-sub-section h3 constructor pre.prettyprint code. constructor(req: Request) :markdown .l-sub-section h3 readyState :markdown Describes the state of the connection, based on `XMLHttpRequest.readyState`, but with additional states. For example, state 5 indicates an aborted connection. .l-sub-section h3 request :markdown Request instance used to create the connection. .l-sub-section h3 response :markdown [RxJS Observable](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observable.md) of Response. Can be subscribed to in order to be notified when a response is available. .l-sub-section h3 dispose pre.prettyprint code. dispose() :markdown Changes the `readyState` of the connection to a custom state of 5 (cancelled). .l-sub-section h3 mockRespond pre.prettyprint code. mockRespond(res: Response) :markdown Sends a mock response to the connection. This response is the value that is emitted to the `Observable` returned by Http. #Example ``` var connection; backend.connections.subscribe(c => connection = c); http.request('data.json').subscribe(res => console.log(res.text())); connection.mockRespond(new Response('fake response')); //logs 'fake response' ``` .l-sub-section h3 mockDownload pre.prettyprint code. mockDownload(res: Response) :markdown Not yet implemented! Sends the provided Response to the `downloadObserver` of the `Request` associated with this connection. .l-sub-section h3 mockError pre.prettyprint code. mockError(err?) :markdown Emits the provided error object as an error to the Response observable returned from Http.