Skip to content

Commit

Permalink
Clean up initial body copy
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Oct 18, 2023
1 parent b05cf5b commit dbb0102
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,14 @@ where
ReaderHint::ToEnd
};

// Move the body part of the bytes in the header buffer to the beginning of the buffer
let header_buf = self.header_buf;
for i in 0..self.raw_body_read {
header_buf[i] = header_buf[self.header_len + i];
}
// From now on, the header buffer is now the body buffer as all header bytes have been overwritten
let body_buf = header_buf;
// Move the body part of the bytes in the header buffer to the beginning of the buffer.
self.header_buf
.copy_within(self.header_len..self.header_len + self.raw_body_read, 0);

ResponseBody {
conn: self.conn,
reader_hint,
body_buf,
body_buf: self.header_buf,
raw_body_read: self.raw_body_read,
}
}
Expand Down

0 comments on commit dbb0102

Please sign in to comment.