@@ -25,8 +25,7 @@ extern crate base64;
25
25
extern crate rand;
26
26
extern crate ring;
27
27
extern crate time;
28
- extern crate url;
29
- #[ cfg( feature="hyper" ) ] extern crate hyper;
28
+ pub extern crate url;
30
29
31
30
#[ cfg( test) ] mod tests;
32
31
@@ -106,8 +105,6 @@ impl fmt::Display for ParseOAuthAuthorizationHeaderError {
106
105
107
106
/// `Authorization` header for OAuth.
108
107
///
109
- /// If you enable `"hyper"` feature, this implements `hyper::header::Scheme` trait.
110
- ///
111
108
/// # Example
112
109
/// ```
113
110
/// # use oauthcli::OAuthAuthorizationHeader;
@@ -196,17 +193,6 @@ impl std::str::FromStr for OAuthAuthorizationHeader {
196
193
}
197
194
}
198
195
199
- #[ cfg( feature="hyper" ) ]
200
- impl hyper:: header:: Scheme for OAuthAuthorizationHeader {
201
- fn scheme ( ) -> Option < & ' static str > {
202
- Some ( "OAuth" )
203
- }
204
-
205
- fn fmt_scheme ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
206
- f. write_str ( & self . s )
207
- }
208
- }
209
-
210
196
fn base_string_url ( url : & Url ) -> String {
211
197
let scheme = url. scheme ( ) ;
212
198
@@ -266,14 +252,8 @@ fn gen_timestamp() -> u64 {
266
252
return x as u64 ;
267
253
}
268
254
269
- /// Generate a string for `oauth_timestamp`.
270
- #[ deprecated( since = "1.0.0" ) ]
271
- pub fn timestamp ( ) -> String {
272
- gen_timestamp ( ) . to_string ( )
273
- }
274
-
275
255
/// Generate a string for `oauth_nonce`.
276
- pub fn nonce ( ) -> String {
256
+ fn nonce ( ) -> String {
277
257
use rand:: Rng ;
278
258
279
259
rand:: thread_rng ( ) . gen_ascii_chars ( )
@@ -351,14 +331,14 @@ impl<'a> OAuthAuthorizationHeaderBuilder<'a> {
351
331
}
352
332
353
333
/// Sets a custom timestamp.
354
- /// If you don't call `timestamp()`, it will use the current time.
334
+ /// If you don't call `timestamp()`, the current time will be used .
355
335
pub fn timestamp ( & mut self , timestamp : u64 ) -> & mut Self {
356
336
self . timestamp = Some ( timestamp) ;
357
337
self
358
338
}
359
339
360
340
/// Sets a custom nonce.
361
- /// If you don't call `nonce()`, it will use a random string.
341
+ /// If you don't call `nonce()`, a random string will be used .
362
342
pub fn nonce < T : Into < Cow < ' a , str > > > ( & mut self , nonce : T ) -> & mut Self {
363
343
self . nonce = Some ( nonce. into ( ) ) ;
364
344
self
@@ -489,38 +469,3 @@ impl<'a> OAuthAuthorizationHeaderBuilder<'a> {
489
469
self . finish_impl ( true )
490
470
}
491
471
}
492
-
493
- /// Generate `Authorization` header for OAuth.
494
- /// The return value starts with `"OAuth "`.
495
- ///
496
- /// # Panics
497
- /// This function will panic if:
498
- /// - either `token` or `token_secret` is specified.
499
- /// - `timestamp` is not valid for u64.
500
- /// - `url` is not valid for HTTP or HTTPS.
501
- #[ deprecated( since = "1.0.0" , note = "Use OAuthAuthorizationHeaderBuilder" ) ]
502
- pub fn authorization_header < P > ( method : & str , url : Url , realm : Option < & str > ,
503
- consumer_key : & str , consumer_secret : & str , token : Option < & str > ,
504
- token_secret : Option < & str > , signature_method : SignatureMethod ,
505
- timestamp : & str , nonce : & str , callback : Option < & str > ,
506
- verifier : Option < & str > , params : P )
507
- -> String where P : Iterator < Item = ( String , String ) >
508
- {
509
- let mut builder = OAuthAuthorizationHeaderBuilder :: new ( method, & url, consumer_key, consumer_secret, signature_method) ;
510
-
511
- builder. request_parameters ( params)
512
- . timestamp ( timestamp. parse ( ) . expect ( "Couldn't parse `timestamp` parameter" ) )
513
- . nonce ( nonce) ;
514
-
515
- match ( token, token_secret) {
516
- ( Some ( x) , Some ( y) ) => { builder. token ( x, y) ; } ,
517
- ( None , None ) => ( ) ,
518
- _ => panic ! ( "Both `token` and `token_secret` parameter are required" )
519
- }
520
-
521
- if let Some ( x) = realm { builder. realm ( x) ; }
522
- if let Some ( x) = callback { builder. callback ( x) ; }
523
- if let Some ( x) = verifier { builder. verifier ( x) ; }
524
-
525
- builder. finish ( ) . to_string ( )
526
- }
0 commit comments