@@ -1963,6 +1963,23 @@ impl<'a> Easy<'a> {
1963
1963
enable as c_long )
1964
1964
}
1965
1965
1966
+ /// Stores a private pointer-sized piece of data.
1967
+ ///
1968
+ /// This can be retrieved through the `private` function and otherwise
1969
+ /// libcurl does not tamper with this value. This corresponds to
1970
+ /// `CURLOPT_PRIVATE` and defaults to 0.
1971
+ pub fn set_private ( & mut self , private : usize ) -> Result < ( ) , Error > {
1972
+ self . setopt_ptr ( curl_sys:: CURLOPT_PRIVATE , private as * const _ )
1973
+ }
1974
+
1975
+ /// Fetches this handle's private pointer-sized piece of data.
1976
+ ///
1977
+ /// This corresponds to
1978
+ /// `CURLINFO_PRIVATE` and defaults to 0.
1979
+ pub fn private ( & mut self ) -> Result < usize , Error > {
1980
+ self . getopt_ptr ( curl_sys:: CURLINFO_PRIVATE ) . map ( |p| p as usize )
1981
+ }
1982
+
1966
1983
// =========================================================================
1967
1984
// getters
1968
1985
@@ -2395,8 +2412,7 @@ impl<'a> Easy<'a> {
2395
2412
fn getopt_bytes ( & mut self , opt : curl_sys:: CURLINFO )
2396
2413
-> Result < Option < & [ u8 ] > , Error > {
2397
2414
unsafe {
2398
- let mut p = 0 as * const c_char ;
2399
- try!( cvt ( curl_sys:: curl_easy_getinfo ( self . handle , opt, & mut p) ) ) ;
2415
+ let p = try!( self . getopt_ptr ( opt) ) ;
2400
2416
if p. is_null ( ) {
2401
2417
Ok ( None )
2402
2418
} else {
@@ -2405,6 +2421,15 @@ impl<'a> Easy<'a> {
2405
2421
}
2406
2422
}
2407
2423
2424
+ fn getopt_ptr ( & mut self , opt : curl_sys:: CURLINFO )
2425
+ -> Result < * const c_char , Error > {
2426
+ unsafe {
2427
+ let mut p = 0 as * const c_char ;
2428
+ try!( cvt ( curl_sys:: curl_easy_getinfo ( self . handle , opt, & mut p) ) ) ;
2429
+ Ok ( p)
2430
+ }
2431
+ }
2432
+
2408
2433
fn getopt_str ( & mut self , opt : curl_sys:: CURLINFO )
2409
2434
-> Result < Option < & str > , Error > {
2410
2435
match self . getopt_bytes ( opt) {
0 commit comments