mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-24 22:37:35 +02:00
allow to override response body encoding
This commit is contained in:
@ -24,9 +24,6 @@ bitflags! {
|
||||
const KEEP_ALIVE = 0b0000_0010;
|
||||
const UPGRADE = 0b0000_0100;
|
||||
const NO_CHUNKING = 0b0000_1000;
|
||||
const ENC_BR = 0b0001_0000;
|
||||
const ENC_DEFLATE = 0b0010_0000;
|
||||
const ENC_GZIP = 0b0100_0000;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
//! Http response
|
||||
use std::cell::{Ref, RefMut};
|
||||
use std::io::Write;
|
||||
use std::{fmt, str};
|
||||
|
||||
@ -14,6 +15,7 @@ use serde_json;
|
||||
|
||||
use crate::body::{Body, BodyStream, MessageBody, ResponseBody};
|
||||
use crate::error::Error;
|
||||
use crate::extensions::Extensions;
|
||||
use crate::header::{Header, IntoHeaderValue};
|
||||
use crate::message::{ConnectionType, Message, ResponseHead};
|
||||
|
||||
@ -577,6 +579,20 @@ impl ResponseBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
/// Responses extensions
|
||||
#[inline]
|
||||
pub fn extensions(&self) -> Ref<Extensions> {
|
||||
let head = self.head.as_ref().expect("cannot reuse response builder");
|
||||
head.extensions.borrow()
|
||||
}
|
||||
|
||||
/// Mutable reference to a the response's extensions
|
||||
#[inline]
|
||||
pub fn extensions_mut(&mut self) -> RefMut<Extensions> {
|
||||
let head = self.head.as_ref().expect("cannot reuse response builder");
|
||||
head.extensions.borrow_mut()
|
||||
}
|
||||
|
||||
/// Set a body and generate `Response`.
|
||||
///
|
||||
/// `ResponseBuilder` can not be used after this call.
|
||||
|
Reference in New Issue
Block a user