This commit is contained in:
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 { impl CachedImage {
#[inline]
fn len(&self) -> usize { fn len(&self) -> usize {
self.data.capacity() self.data.capacity()
+ self + self
@ -47,6 +48,7 @@ impl CachedImage {
.unwrap_or_default() .unwrap_or_default()
} }
#[inline]
fn shrink_to_fit(&mut self) { fn shrink_to_fit(&mut self) {
self.data.shrink_to_fit(); self.data.shrink_to_fit();
self.content_length.as_mut().map(Vec::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 { impl Responder for ServerResponse {
#[inline]
fn respond_to(self, req: &HttpRequest) -> HttpResponse { fn respond_to(self, req: &HttpRequest) -> HttpResponse {
match self { match self {
Self::TokenValidationError(e) => e.respond_to(req), Self::TokenValidationError(e) => e.respond_to(req),
@ -111,6 +112,7 @@ enum TokenValidationError {
} }
impl Responder for TokenValidationError { impl Responder for TokenValidationError {
#[inline]
fn respond_to(self, _: &HttpRequest) -> HttpResponse { fn respond_to(self, _: &HttpRequest) -> HttpResponse {
push_headers(&mut HttpResponse::Forbidden()).finish() push_headers(&mut HttpResponse::Forbidden()).finish()
} }
@ -150,6 +152,7 @@ fn validate_token(
Ok(()) Ok(())
} }
#[inline]
fn push_headers(builder: &mut HttpResponseBuilder) -> &mut HttpResponseBuilder { fn push_headers(builder: &mut HttpResponseBuilder) -> &mut HttpResponseBuilder {
builder builder
.insert_header((X_CONTENT_TYPE_OPTIONS, "nosniff")) .insert_header((X_CONTENT_TYPE_OPTIONS, "nosniff"))