mirror of https://github.com/fafhrd91/actix-web
implement responder for byte vec
This commit is contained in:
parent
b0a363a7ae
commit
4b1a24b56f
|
@ -1,14 +1,17 @@
|
|||
# Changes
|
||||
|
||||
## Unreleased - 2021-xx-xx
|
||||
### Added
|
||||
- Implement `From<Vec<u8>>` for `Response<Vec<u8>>`. [#????]
|
||||
|
||||
### Changed
|
||||
- `error::DispatcherError` enum is now marked `#[non_exhaustive]`. [#2624]
|
||||
|
||||
|
||||
### Fixed
|
||||
- Issue where handlers that took payload but then dropped without reading it to EOF it would cause keep-alive connections to become stuck. [#2624]
|
||||
|
||||
[#2624]: https://github.com/actix/actix-web/pull/2624
|
||||
[#????]: https://github.com/actix/actix-web/pull/????
|
||||
|
||||
|
||||
## 3.0.0-rc.1 - 2022-01-31
|
||||
|
|
|
@ -285,6 +285,24 @@ impl From<&'static [u8]> for Response<&'static [u8]> {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Vec<u8>> for Response<Vec<u8>> {
|
||||
fn from(val: Vec<u8>) -> Self {
|
||||
let mut res = Response::with_body(StatusCode::OK, val);
|
||||
let mime = mime::APPLICATION_OCTET_STREAM.try_into_value().unwrap();
|
||||
res.headers_mut().insert(header::CONTENT_TYPE, mime);
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&Vec<u8>> for Response<Vec<u8>> {
|
||||
fn from(val: &Vec<u8>) -> Self {
|
||||
let mut res = Response::with_body(StatusCode::OK, val.clone());
|
||||
let mime = mime::APPLICATION_OCTET_STREAM.try_into_value().unwrap();
|
||||
res.headers_mut().insert(header::CONTENT_TYPE, mime);
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for Response<String> {
|
||||
fn from(val: String) -> Self {
|
||||
let mut res = Response::with_body(StatusCode::OK, val);
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
# Changes
|
||||
|
||||
## Unreleased - 2021-xx-xx
|
||||
### Added
|
||||
- Implement `Responder` for `Vec<u8>`. [#????]
|
||||
|
||||
[#????]: https://github.com/actix/actix-web/pull/????
|
||||
|
||||
## 4.0.0-rc.2 - 2022-02-02
|
||||
### Added
|
||||
|
|
|
@ -132,6 +132,7 @@ macro_rules! impl_responder_by_forward_into_base_response {
|
|||
}
|
||||
|
||||
impl_responder_by_forward_into_base_response!(&'static [u8]);
|
||||
impl_responder_by_forward_into_base_response!(Vec<u8>);
|
||||
impl_responder_by_forward_into_base_response!(Bytes);
|
||||
impl_responder_by_forward_into_base_response!(BytesMut);
|
||||
|
||||
|
|
Loading…
Reference in New Issue