feature/v32-tokens
Edward Shen 2021-03-23 12:59:49 -04:00
parent 91f420330b
commit 46eec93773
Signed by: edward
GPG Key ID: 19182661E818369F
2 changed files with 5 additions and 0 deletions

View File

@ -28,6 +28,7 @@ pub struct CachedImage {
}
impl CachedImage {
#[inline]
fn len(&self) -> usize {
self.data.capacity()
+ self
@ -47,6 +48,7 @@ impl CachedImage {
.unwrap_or_default()
}
#[inline]
fn shrink_to_fit(&mut self) {
self.data.shrink_to_fit();
self.content_length.as_mut().map(Vec::shrink_to_fit);

View File

@ -37,6 +37,7 @@ enum ServerResponse {
}
impl Responder for ServerResponse {
#[inline]
fn respond_to(self, req: &HttpRequest) -> HttpResponse {
match self {
Self::TokenValidationError(e) => e.respond_to(req),
@ -111,6 +112,7 @@ enum TokenValidationError {
}
impl Responder for TokenValidationError {
#[inline]
fn respond_to(self, _: &HttpRequest) -> HttpResponse {
push_headers(&mut HttpResponse::Forbidden()).finish()
}
@ -150,6 +152,7 @@ fn validate_token(
Ok(())
}
#[inline]
fn push_headers(builder: &mut HttpResponseBuilder) -> &mut HttpResponseBuilder {
builder
.insert_header((X_CONTENT_TYPE_OPTIONS, "nosniff"))