diff options
| author | Manuel Schölling <[email protected]> | 2015-04-30 20:00:30 +0200 |
|---|---|---|
| committer | Manuel Schölling <[email protected]> | 2015-04-30 20:00:30 +0200 |
| commit | c8fae312ad9a4350f3aa92b5aa09cc9f8971175e (patch) | |
| tree | 2de5d836c56e226ab99d04dee0681407c0ee53cb /openssl/src/ssl/tests.rs | |
| parent | Write through to underlying stream for every write call (diff) | |
| download | rust-openssl-c8fae312ad9a4350f3aa92b5aa09cc9f8971175e.tar.xz rust-openssl-c8fae312ad9a4350f3aa92b5aa09cc9f8971175e.zip | |
Add SslStream.pending()
Diffstat (limited to 'openssl/src/ssl/tests.rs')
| -rw-r--r-- | openssl/src/ssl/tests.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/openssl/src/ssl/tests.rs b/openssl/src/ssl/tests.rs index e6af551b..c9a2d73a 100644 --- a/openssl/src/ssl/tests.rs +++ b/openssl/src/ssl/tests.rs @@ -337,6 +337,30 @@ fn test_read() { io::copy(&mut stream, &mut io::sink()).ok().expect("read error"); } + +#[test] +fn test_pending() { + let tcp = TcpStream::connect("127.0.0.1:15418").unwrap(); + let mut stream = SslStream::new(&SslContext::new(Sslv23).unwrap(), tcp).unwrap(); + stream.write_all("GET /\r\n\r\n".as_bytes()).unwrap(); + stream.flush().unwrap(); + + // wait for the response and read first byte... + let mut buf = [0u8; 16*1024]; + stream.read(&mut buf[..1]).unwrap(); + + let pending = stream.pending(); + let len = stream.read(&mut buf[1..]).unwrap(); + + assert_eq!(pending, len); + + stream.read(&mut buf[..1]).unwrap(); + + let pending = stream.pending(); + let len = stream.read(&mut buf[1..]).unwrap(); + assert_eq!(pending, len); +} + /// Tests that connecting with the client using NPN, but the server not does not /// break the existing connection behavior. #[test] |