summaryrefslogtreecommitdiffstats
path: root/src/errors.rs
diff options
context:
space:
mode:
authorDylan McKay <me@dylanmckay.io>2018-12-22 23:29:45 +1300
committerdoug tangren <d.tangren@gmail.com>2018-12-22 19:29:45 +0900
commit6b5f0c0f9ddfac9c052210c5dbf3224020646127 (patch)
tree7310447a251e66e5d061f5da00b07b6ce498fc8a /src/errors.rs
parent79d65c286025c551a775c0964d168e6feb4b3409 (diff)
Support interactive stdin/stdout streams (#136)
* Support interactive stdin/stdout streams This adds support for streaming stdin, stderr, and stdout independently to a running container. The underlying API is futures-based, meaning the code is implemented asynchronously. A synchronous API is also exposed, which is implemented by simply waiting on the asynchronous API futures. This also modifies the existing Tty logic so that the storage type of the data is a Vec<u8> rather than a String. This is also how the Rust standard library persists data from the standard streams. In my particular application, I'm using stdin/stdout as the communication method between a container a host application. In it, a byte-based protocol is used. Streaming works by performing a TCP upgrade; upgrading a higher-level HTTP connection to a lower-level TCP byte stream upon agreement with the server. Docker will automatically upgrade HTTP container log requests to TCP byte streams of a custom std{in,out,err} multiplexing protocol if the client requests it with the 'Connection: Upgrade' header. * Return an error rather than panic when Docker refuses to upgrade to TCP * Add interpret-as-string accessors to tty::Chunk Also updates the examples to use them.
Diffstat (limited to 'src/errors.rs')
-rw-r--r--src/errors.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/errors.rs b/src/errors.rs
index 36be662..fa408c2 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -17,6 +17,7 @@ pub enum Error {
Encoding(FromUtf8Error),
InvalidResponse(String),
Fault { code: StatusCode, message: String },
+ ConnectionNotUpgraded,
}
impl From<SerdeError> for Error {
@@ -59,6 +60,7 @@ impl fmt::Display for Error {
write!(f, "Response doesn't have the expected format: {}", cause)
}
Error::Fault { code, .. } => write!(f, "{}", code),
+ Error::ConnectionNotUpgraded => write!(f, "expected the docker host to upgrade the HTTP connection but it did not"),
}
}
}