Skip to content

Commit

Permalink
Unnecessary BytesMut (#2414)
Browse files Browse the repository at this point in the history
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
  • Loading branch information
takkuumi and davidpdrsn authored Dec 17, 2023
1 parent 72ccde5 commit 584c328
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions axum/src/extract/raw_form.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use async_trait::async_trait;
use axum_core::extract::{FromRequest, Request};
use bytes::{Bytes, BytesMut};
use bytes::Bytes;
use http::Method;

use super::{
Expand Down Expand Up @@ -39,13 +39,11 @@ where

async fn from_request(req: Request, state: &S) -> Result<Self, Self::Rejection> {
if req.method() == Method::GET {
let mut bytes = BytesMut::new();

if let Some(query) = req.uri().query() {
bytes.extend(query.as_bytes());
return Ok(Self(Bytes::copy_from_slice(query.as_bytes())));
}

Ok(Self(bytes.freeze()))
Ok(Self(Bytes::new()))
} else {
if !has_content_type(req.headers(), &mime::APPLICATION_WWW_FORM_URLENCODED) {
return Err(InvalidFormContentType.into());
Expand Down

0 comments on commit 584c328

Please sign in to comment.