Borrow compression string
This commit is contained in:
parent
f1c68e3544
commit
9be0aab9ac
|
|
@ -955,27 +955,24 @@ impl SslRef {
|
||||||
///
|
///
|
||||||
/// The result will be either None, indicating no compression is in use, or
|
/// The result will be either None, indicating no compression is in use, or
|
||||||
/// a string with the compression name.
|
/// a string with the compression name.
|
||||||
pub fn compression(&self) -> Option<String> {
|
pub fn compression(&self) -> Option<&str> {
|
||||||
self._compression()
|
self._compression()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(osslconf = "OPENSSL_NO_COMP"))]
|
#[cfg(not(osslconf = "OPENSSL_NO_COMP"))]
|
||||||
fn _compression(&self) -> Option<String> {
|
fn _compression(&self) -> Option<&str> {
|
||||||
let ptr = unsafe { ffi::SSL_get_current_compression(self.as_ptr()) };
|
unsafe {
|
||||||
|
let ptr = ffi::SSL_get_current_compression(self.as_ptr());
|
||||||
if ptr == ptr::null() {
|
if ptr == ptr::null() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
let meth = ffi::SSL_COMP_get_name(ptr);
|
||||||
let meth = unsafe { ffi::SSL_COMP_get_name(ptr) };
|
Some(str::from_utf8(CStr::from_ptr(meth as *const _).to_bytes()).unwrap())
|
||||||
let s = unsafe {
|
}
|
||||||
String::from_utf8(CStr::from_ptr(meth as *const _).to_bytes().to_vec()).unwrap()
|
|
||||||
};
|
|
||||||
|
|
||||||
Some(s)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(osslconf = "OPENSSL_NO_COMP")]
|
#[cfg(osslconf = "OPENSSL_NO_COMP")]
|
||||||
fn _compression(&self) -> Option<String> {
|
fn _compression(&self) -> Option<&str> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue