
p.location-badge.
  exported from <a href='../http'>angular2/http</a>
  defined in <a href="https://github.com/angular/angular/tree/3a0410a/modules/angular2/src/http/backends/mock_backend.ts#L6-L106">angular2/src/http/backends/mock_backend.ts (line 6)</a>

: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
  <a href='MockBackend-class.html'><code>MockBackend</code></a> 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

      <a href='Request-class.html'><code>Request</code></a> 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 <a href='Response-class.html'><code>Response</code></a>. 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 <a href='Http-class.html'><code>Http</code></a>.
      
      #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 <a href='Response-class.html'><code>Response</code></a> 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 <a href='Response-class.html'><code>Response</code></a> observable returned
      from <a href='Http-class.html'><code>Http</code></a>.
      
      




