@@ -18,17 +18,43 @@ import {
1818 * Spec](https://fetch.spec.whatwg.org/#request-class),
1919 * but is considered a static value whose body can be accessed many times. There are other
2020 * differences in the implementation, but this is the most significant.
21+ *
22+ * `Request` instances are typically created by higher-level classes, like {@link Http} and
23+ * {@link Jsonp}, but it may occasionally be useful to explicitly create `Request` instances.
24+ * One such example is when creating services that wrap higher-level services, like {@link Http},
25+ * where it may be useful to generate a `Request` with arbitrary headers and search params.
26+ *
27+ * ```
28+ * import {Injectable, Injector} from 'angular2/angular2';
29+ * import {HTTP_BINDINGS, Http, Request} from 'angular2/http';
30+ *
31+ * @Injectable ()
32+ * class AutoAuthenticator {
33+ * constructor(public http:Http) {}
34+ * request(url:string) {
35+ * return this.http.request(new Request({
36+ * method: 0, //GET.
37+ * url: url,
38+ * search: 'password=123'
39+ * }));
40+ * }
41+ * }
42+ *
43+ * var injector = Injector.resolveAndCreate([HTTP_BINDINGS, AutoAuthenticator]);
44+ * var authenticator = injector.get(AutoAuthenticator);
45+ * authenticator.request('people.json').toRx().subscribe(res => {
46+ * //URL should have included '?password=123'
47+ * console.log('people', res.json());
48+ * });
49+ * ```
2150 */
2251export class Request {
2352 /**
2453 * Http method with which to perform the request.
25- *
26- * Defaults to GET.
2754 */
2855 method : RequestMethods ;
2956 /**
30- * Headers object based on the `Headers` class in the [Fetch
31- * Spec](https://fetch.spec.whatwg.org/#headers-class). {@link Headers} class reference.
57+ * {@link Headers } instance
3258 */
3359 headers : Headers ;
3460 /** Url of the remote resource */
0 commit comments