aboutsummaryrefslogtreecommitdiff
path: root/src/ssl/mod.rs
diff options
context:
space:
mode:
authorAndrew Dunham <[email protected]>2014-09-04 18:07:13 -0700
committerAndrew Dunham <[email protected]>2014-09-04 19:02:05 -0700
commitc4ede3d585982af32e51c0ccc3a6b7f98f3b7ad7 (patch)
tree42834d59ccdbdb43580c9a1945a5331109df1d48 /src/ssl/mod.rs
parentMerge pull request #35 from Kroisse/master (diff)
downloadrust-openssl-c4ede3d585982af32e51c0ccc3a6b7f98f3b7ad7.tar.xz
rust-openssl-c4ede3d585982af32e51c0ccc3a6b7f98f3b7ad7.zip
Allow getting the compression used in a connection
Diffstat (limited to 'src/ssl/mod.rs')
-rw-r--r--src/ssl/mod.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/ssl/mod.rs b/src/ssl/mod.rs
index 7c9b2d60..125efdcb 100644
--- a/src/ssl/mod.rs
+++ b/src/ssl/mod.rs
@@ -3,6 +3,7 @@ use std::io::{IoResult, IoError, EndOfFile, Stream, Reader, Writer};
use std::mem;
use std::ptr;
use std::rt::mutex::NativeMutex;
+use std::string;
use sync::one::{Once, ONCE_INIT};
use ssl::error::{SslError, SslSessionClosed, StreamError};
@@ -500,6 +501,21 @@ impl<S: Stream> SslStream<S> {
}
Ok(())
}
+
+ /// Get the compression currently in use. The result will be
+ /// either None, indicating no compression is in use, or a string
+ /// with the compression name.
+ pub fn get_compression(&self) -> Option<String> {
+ let ptr = unsafe { ffi::SSL_get_current_compression(self.ssl.ssl) };
+ if ptr == ptr::null() {
+ return None;
+ }
+
+ let meth = unsafe { ffi::SSL_COMP_get_name(ptr) };
+ let s = unsafe { string::raw::from_buf(meth as *const u8) };
+
+ Some(s)
+ }
}
impl<S: Stream> Reader for SslStream<S> {