File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 1
1
/target
2
2
** /* .rs.bk
3
- Cargo.lock
3
+ Cargo.lock
4
+ .idea
5
+ .DS_Store
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ use std::str::from_utf8;
4
4
use futures:: future:: { self , Future } ;
5
5
use futures:: stream:: Stream ;
6
6
use reqwest as r;
7
- use reqwest:: r#async as ra;
7
+ use reqwest:: { r#async as ra, Url } ;
8
8
9
9
/*
10
10
* TODO remove debug output
@@ -136,6 +136,20 @@ impl Client {
136
136
} )
137
137
}
138
138
139
+ /// Construct a new `Client` (via a [`ClientBuilder`]). This will not
140
+ /// perform any network activity until [`.stream()`] is called.
141
+ ///
142
+ /// [`ClientBuilder`]: struct.ClientBuilder.html
143
+ /// [`.stream()`]: #method.stream
144
+ pub fn for_str ( str_url : & str ) -> Result < ClientBuilder > {
145
+ let url = Url :: parse ( str_url)
146
+ . map_err ( |e| Error :: HttpRequest ( Box :: new ( e) ) ) ?;
147
+ Ok ( ClientBuilder {
148
+ url : url,
149
+ headers : r:: header:: HeaderMap :: new ( ) ,
150
+ } )
151
+ }
152
+
139
153
/// Connect to the server and begin consuming the stream. Produces a
140
154
/// [`Stream`] of [`Event`]s.
141
155
///
You can’t perform that action at this time.
0 commit comments