@@ -3,10 +3,12 @@ import {makeTypeError} from 'angular2/src/core/facade/exceptions';
33import { Injectable } from 'angular2/angular2' ;
44import { RequestOptionsArgs , Connection , ConnectionBackend } from './interfaces' ;
55import { Request } from './static_request' ;
6+ import { Response } from './static_response' ;
67import { BaseRequestOptions , RequestOptions } from './base_request_options' ;
78import { RequestMethods } from './enums' ;
9+ import { Observable } from 'angular2/angular2' ;
810
9- function httpRequest ( backend : ConnectionBackend , request : Request ) : any {
11+ function httpRequest ( backend : ConnectionBackend , request : Request ) : Observable < Response > {
1012 return backend . createConnection ( request ) . response ;
1113}
1214
@@ -96,7 +98,7 @@ export class Http {
9698 * object can be provided as the 2nd argument. The options object will be merged with the values
9799 * of {@link BaseRequestOptions} before performing the request.
98100 */
99- request ( url : string | Request , options ?: RequestOptionsArgs ) : any {
101+ request ( url : string | Request , options ?: RequestOptionsArgs ) : Observable < Response > {
100102 var responseObservable : any ;
101103 if ( isString ( url ) ) {
102104 responseObservable = httpRequest (
@@ -113,15 +115,15 @@ export class Http {
113115 /**
114116 * Performs a request with `get` http method.
115117 */
116- get ( url : string , options ?: RequestOptionsArgs ) : any {
118+ get ( url : string , options ?: RequestOptionsArgs ) : Observable < Response > {
117119 return httpRequest ( this . _backend , new Request ( mergeOptions ( this . _defaultOptions , options ,
118120 RequestMethods . Get , url ) ) ) ;
119121 }
120122
121123 /**
122124 * Performs a request with `post` http method.
123125 */
124- post ( url : string , body : string , options ?: RequestOptionsArgs ) : any {
126+ post ( url : string , body : string , options ?: RequestOptionsArgs ) : Observable < Response > {
125127 return httpRequest (
126128 this . _backend ,
127129 new Request ( mergeOptions ( this . _defaultOptions . merge ( new RequestOptions ( { body : body } ) ) ,
@@ -131,7 +133,7 @@ export class Http {
131133 /**
132134 * Performs a request with `put` http method.
133135 */
134- put ( url : string , body : string , options ?: RequestOptionsArgs ) : any {
136+ put ( url : string , body : string , options ?: RequestOptionsArgs ) : Observable < Response > {
135137 return httpRequest (
136138 this . _backend ,
137139 new Request ( mergeOptions ( this . _defaultOptions . merge ( new RequestOptions ( { body : body } ) ) ,
@@ -141,15 +143,15 @@ export class Http {
141143 /**
142144 * Performs a request with `delete` http method.
143145 */
144- delete ( url : string , options ?: RequestOptionsArgs ) : any {
146+ delete ( url : string , options ?: RequestOptionsArgs ) : Observable < Response > {
145147 return httpRequest ( this . _backend , new Request ( mergeOptions ( this . _defaultOptions , options ,
146148 RequestMethods . Delete , url ) ) ) ;
147149 }
148150
149151 /**
150152 * Performs a request with `patch` http method.
151153 */
152- patch ( url : string , body : string , options ?: RequestOptionsArgs ) : any {
154+ patch ( url : string , body : string , options ?: RequestOptionsArgs ) : Observable < Response > {
153155 return httpRequest (
154156 this . _backend ,
155157 new Request ( mergeOptions ( this . _defaultOptions . merge ( new RequestOptions ( { body : body } ) ) ,
@@ -159,7 +161,7 @@ export class Http {
159161 /**
160162 * Performs a request with `head` http method.
161163 */
162- head ( url : string , options ?: RequestOptionsArgs ) : any {
164+ head ( url : string , options ?: RequestOptionsArgs ) : Observable < Response > {
163165 return httpRequest ( this . _backend , new Request ( mergeOptions ( this . _defaultOptions , options ,
164166 RequestMethods . Head , url ) ) ) ;
165167 }
@@ -177,7 +179,7 @@ export class Jsonp extends Http {
177179 * object can be provided as the 2nd argument. The options object will be merged with the values
178180 * of {@link BaseRequestOptions} before performing the request.
179181 */
180- request ( url : string | Request , options ?: RequestOptionsArgs ) : any {
182+ request ( url : string | Request , options ?: RequestOptionsArgs ) : Observable < Response > {
181183 var responseObservable : any ;
182184 if ( isString ( url ) ) {
183185 url = new Request ( mergeOptions ( this . _defaultOptions , options , RequestMethods . Get , url ) ) ;
0 commit comments