Struct HttpResponse

Source
pub struct HttpResponse { /* private fields */ }

Implementations§

Source§

impl HttpResponse

Source

pub fn init(stream: Rc<RefCell<TcpStream>>, version: &str) -> Self

Source

pub fn json<T>(self, data: T)
where T: Serialize,

Set-Cookie: =; Path=; Expires=; HttpOnly; Secure; SameSite=<strict|lax|none>

  1. : • cookie-name: Cookie 的键名。 • cookie-value: Cookie 的值,支持 Base64 编码以存储复杂数据。
  2. Path: • 指定 Cookie 的作用范围。例如,Path=/ 使 Cookie 在整个网站有效。
  3. Expires 或 Max-Age: • Expires: 设置具体过期时间(UTC 格式)。 • Max-Age: 设置相对过期时间(秒数)。
  4. HttpOnly: • 限制 Cookie 只能通过 HTTP 请求访问,JavaScript 无法读取(防止 XSS 攻击)。
  5. Secure: • 仅在 HTTPS 请求中发送(提升安全性)。
  6. SameSite: • Strict: 禁止跨站点发送 Cookie(最安全)。 • Lax: 允许部分跨站点请求(如导航链接)。 • None: 允许所有跨站点发送 Cookie,需配合 Secure。

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.