]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
http2: remove to_vec for comparisons 7713/head
authorPhilippe Antoine <pantoine@oisf.net>
Sun, 24 Jul 2022 19:54:24 +0000 (21:54 +0200)
committerVictor Julien <vjulien@oisf.net>
Tue, 9 Aug 2022 08:54:57 +0000 (10:54 +0200)
Ticket: #5454

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

index 40ef9b55d38ccd225fadd423eb07be6db09c539c..164ff3224d021304733102860dcf086f0f6f650c 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 eed1999a08b552f89131031b8d58cff59302e57f..a6452aef2157549e81ae545ee967321f3358dbd2 100644 (file)
@@ -416,7 +416,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);
                 }
             }
@@ -440,7 +440,7 @@ pub fn http2_frames_get_header_value_vec(
     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 {
                         vec.extend_from_slice(&block.value);
                         found = 1;
@@ -477,7 +477,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 3b06e4ed9b949f3ca91e22dc9b3ba37f65fce7ca..533ea491b0e562dc98efcf904055f212d4b8e9c1 100644 (file)
@@ -194,7 +194,7 @@ impl HTTP2Transaction {
 
     fn handle_headers(&mut self, blocks: &Vec<parser::HTTP2FrameHeaderBlock>, dir: Direction) {
         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);
             }
         }
index 34217ed40bd244c2844253ed3401b039aca0a2cf..5d42c12f793216003efeb4b5111f28bdc056add2 100644 (file)
@@ -169,12 +169,12 @@ pub fn http2_range_close(
 ) {
     let added = if let Some(c) = unsafe { SC } {
         let added = (c.HTPFileCloseHandleRange)(
-                files,
-                flags,
-                tx.file_range,
-                data.as_ptr(),
-                data.len() as u32,
-                );
+            files,
+            flags,
+            tx.file_range,
+            data.as_ptr(),
+            data.len() as u32,
+        );
         (c.HttpRangeFreeBlock)(tx.file_range);
         added
     } else {