pub struct HttpResponse { /* private fields */ }
Implementations§
Source§impl HttpResponse
impl HttpResponse
pub fn init(stream: Rc<RefCell<TcpStream>>, version: &str) -> Self
pub fn json<T>(self, data: T)where
T: Serialize,
Set-Cookie:
和 : • cookie-name: Cookie 的键名。 • cookie-value: Cookie 的值,支持 Base64 编码以存储复杂数据。 - Path: • 指定 Cookie 的作用范围。例如,Path=/ 使 Cookie 在整个网站有效。
- Expires 或 Max-Age: • Expires: 设置具体过期时间(UTC 格式)。 • Max-Age: 设置相对过期时间(秒数)。
- HttpOnly: • 限制 Cookie 只能通过 HTTP 请求访问,JavaScript 无法读取(防止 XSS 攻击)。
- Secure: • 仅在 HTTPS 请求中发送(提升安全性)。
- SameSite: • Strict: 禁止跨站点发送 Cookie(最安全)。 • Lax: 允许部分跨站点请求(如导航链接)。 • None: 允许所有跨站点发送 Cookie,需配合 Secure。
Auto Trait Implementations§
impl Freeze for HttpResponse
impl !RefUnwindSafe for HttpResponse
impl !Send for HttpResponse
impl !Sync for HttpResponse
impl Unpin for HttpResponse
impl !UnwindSafe for HttpResponse
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