pub struct Response {
pub config: Config,
pub status: Status,
pub headers: JsonValue,
pub cookies: JsonValue,
pub body: Vec<u8>,
pub body_text: JsonValue,
pub stream_id: u32,
pub key: String,
pub version: String,
pub scheme: Arc<Mutex<Scheme>>,
/* private fields */
}
Expand description
响应
Fields§
§config: Config
§status: Status
§headers: JsonValue
§body: Vec<u8>
消息体
body_text: JsonValue
§stream_id: u32
HTTP2 使用
key: String
ws 通信密钥
version: String
ws 版本
scheme: Arc<Mutex<Scheme>>
Implementations§
Source§impl Response
impl Response
pub fn default(config: Config, scheme: Arc<Mutex<Scheme>>) -> Self
pub fn status(&mut self, code: i32) -> &mut Self
Sourcepub fn set_request(&mut self, request: &mut Request)
pub fn set_request(&mut self, request: &mut Request)
设置 请求内容
pub fn header(&mut self, key: &str, value: &str) -> &mut Self
pub fn update_body(&mut self)
pub fn get_date(&mut self, s: i64) -> String
Sourcepub fn download(&mut self, filename: &Path) -> &mut Self
pub fn download(&mut self, filename: &Path) -> &mut Self
下载 返回
§Panics
This function will panic if:
filename.extension()
returnsNone
- The extension cannot be converted to a valid UTF-8 string
- The filename cannot be converted to a valid UTF-8 string
Sourcepub fn file(&mut self, filename: &Path) -> &mut Self
pub fn file(&mut self, filename: &Path) -> &mut Self
Serves a file for inline display in the browser.
§Panics
This function will panic if the file extension cannot be converted to a string, or if the filename cannot be converted to a valid UTF-8 string.
pub fn websocket(&mut self, key: &str) -> &mut Self
Trait Implementations§
Source§impl Handler for Response
impl Handler for Response
Source§fn on_options(&mut self, response: &mut Response)
fn on_options(&mut self, response: &mut Response)
预检请求处理 OPTIONS
Source§fn on_request(&mut self, _request: Request, _response: &mut Response)
fn on_request(&mut self, _request: Request, _response: &mut Response)
请求 处理
Source§fn on_response(&mut self, request: Request, response: &mut Response)
fn on_response(&mut self, request: Request, response: &mut Response)
响应 处理
fn on_frame(&mut self) -> Result<()>
Source§fn on_shutdown(&mut self)
fn on_shutdown(&mut self)
关机监听
Auto Trait Implementations§
impl Freeze for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnwindSafe for Response
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more