]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
http2: remove to_vec for comparisons
authorPhilippe Antoine <pantoine@oisf.net>
Sun, 24 Jul 2022 19:54:24 +0000 (21:54 +0200)
committerPhilippe Antoine <pantoine@oisf.net>
Wed, 7 Sep 2022 07:24:45 +0000 (09:24 +0200)
Ticket: #5454
(cherry picked from commit 9b4a133777e8d25eda0f9f44095bc4a10d8cce21)

Conflict fixed by Philippe Antoine

rust/src/http2/decompression.rs
rust/src/http2/detect.rs
rust/src/http2/http2.rs

index f158785e8732eb063f00c7b4a86f7436ffcaffb8..67f46cc634a9005239156a54cbe511d17c0b30ec 100644 (file)
@@ -168,13 +168,13 @@ impl HTTP2DecoderHalf {
     pub fn http2_encoding_fromvec(&mut self, input: &[u8]) {
         //use first encoding...
         if self.encoding == HTTP2ContentEncoding::HTTP2ContentEncodingUnknown {
-            if *input == "gzip".as_bytes().to_vec() {
+            if input == b"gzip" {
                 self.encoding = HTTP2ContentEncoding::HTTP2ContentEncodingGzip;
                 self.decoder = HTTP2Decompresser::GZIP(GzDecoder::new(HTTP2cursor::new()));
-            } else if *input == "deflate".as_bytes().to_vec() {
+            } else if input == b"deflate" {
                 self.encoding = HTTP2ContentEncoding::HTTP2ContentEncodingDeflate;
                 self.decoder = HTTP2Decompresser::DEFLATE(DeflateDecoder::new(HTTP2cursor::new()));
-            } else if *input == "br".as_bytes().to_vec() {
+            } else if input == b"br" {
                 self.encoding = HTTP2ContentEncoding::HTTP2ContentEncodingBr;
                 self.decoder = HTTP2Decompresser::BROTLI(brotli::Decompressor::new(
                     HTTP2cursor::new(),
index 24436843edfa2ce60b607a821203670262bcc7f4..8a7300ac3b56ef31fbb751ff60654a5a842e34b9 100644 (file)
@@ -489,7 +489,7 @@ fn http2_frames_get_header_firstvalue<'a>(
     for i in 0..frames.len() {
         if let Some(blocks) = http2_header_blocks(&frames[i]) {
             for block in blocks.iter() {
-                if block.name == name.as_bytes().to_vec() {
+                if block.name == name.as_bytes() {
                     return Ok(&block.value);
                 }
             }
@@ -512,7 +512,7 @@ fn http2_frames_get_header_value<'a>(
     for i in 0..frames.len() {
         if let Some(blocks) = http2_header_blocks(&frames[i]) {
             for block in blocks.iter() {
-                if block.name == name.as_bytes().to_vec() {
+                if block.name == name.as_bytes() {
                     if found == 0 {
                         single = Ok(&block.value);
                         found = 1;
index 6536d4141a10ddb8fdc103c0c6f7a71d5770796a..c9aee2c9698ec6059d2157591ea297a8d9d8f6fc 100644 (file)
@@ -180,7 +180,7 @@ impl HTTP2Transaction {
     #[cfg(feature = "decompression")]
     fn handle_headers(&mut self, blocks: &Vec<parser::HTTP2FrameHeaderBlock>, dir: u8) {
         for i in 0..blocks.len() {
-            if blocks[i].name == "content-encoding".as_bytes().to_vec() {
+            if blocks[i].name == b"content-encoding" {
                 self.decoder.http2_encoding_fromvec(&blocks[i].value, dir);
             }
         }