mirror of https://github.com/fafhrd91/actix-web
fix(actix-http): encode correctly camel case header with n+2 hyphens
Closes #2674
This commit is contained in:
parent
7b8a392ef5
commit
206f8ae62c
|
@ -1,5 +1,9 @@
|
|||
# Changes
|
||||
|
||||
## Unreleased
|
||||
### Fixed
|
||||
- Encode correctly camel case header with n+2 hyphens [#2674]
|
||||
|
||||
## Unreleased - 2021-xx-xx
|
||||
### Added
|
||||
- Response headers can be sent as camel case using `res.head_mut().set_camel_case_headers(true)`. [#2587]
|
||||
|
@ -10,7 +14,6 @@
|
|||
[#2538]: https://github.com/actix/actix-web/pull/2538
|
||||
[#2587]: https://github.com/actix/actix-web/pull/2587
|
||||
|
||||
|
||||
## 3.0.0-beta.18 - 2022-01-04
|
||||
### Added
|
||||
- `impl Eq` for `header::ContentEncoding`. [#2501]
|
||||
|
|
|
@ -517,6 +517,7 @@ unsafe fn write_camel_case(value: &[u8], buf: *mut u8, len: usize) {
|
|||
if let Some(c @ b'a'..=b'z') = iter.next() {
|
||||
buffer[index] = c & 0b1101_1111;
|
||||
}
|
||||
index += 1;
|
||||
}
|
||||
|
||||
index += 1;
|
||||
|
@ -528,7 +529,7 @@ mod tests {
|
|||
use std::rc::Rc;
|
||||
|
||||
use bytes::Bytes;
|
||||
use http::header::AUTHORIZATION;
|
||||
use http::header::{AUTHORIZATION, UPGRADE_INSECURE_REQUESTS};
|
||||
|
||||
use super::*;
|
||||
use crate::{
|
||||
|
@ -559,6 +560,9 @@ mod tests {
|
|||
head.headers
|
||||
.insert(CONTENT_TYPE, HeaderValue::from_static("plain/text"));
|
||||
|
||||
head.headers
|
||||
.insert(UPGRADE_INSECURE_REQUESTS, HeaderValue::from_static("1"));
|
||||
|
||||
let mut head = RequestHeadType::Owned(head);
|
||||
|
||||
let _ = head.encode_headers(
|
||||
|
@ -574,6 +578,7 @@ mod tests {
|
|||
assert!(data.contains("Connection: close\r\n"));
|
||||
assert!(data.contains("Content-Type: plain/text\r\n"));
|
||||
assert!(data.contains("Date: date\r\n"));
|
||||
assert!(data.contains("Upgrade-Insecure-Requests: 1\r\n"));
|
||||
|
||||
let _ = head.encode_headers(
|
||||
&mut bytes,
|
||||
|
|
Loading…
Reference in New Issue