From de8f8f87b69b562d8afb71b1dd19d8ae41478256 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Wed, 23 Apr 2014 16:26:18 -0500 Subject: [PATCH] Adapt more of HTTP analyzer to use cached file analysis IDs. Some EndOfFile calls can re-use a cached file ID. --- src/analyzer/protocol/http/HTTP.cc | 24 +++++++++++++++++++----- src/analyzer/protocol/http/HTTP.h | 1 + 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/analyzer/protocol/http/HTTP.cc b/src/analyzer/protocol/http/HTTP.cc index f676643b7c..bc0081ab52 100644 --- a/src/analyzer/protocol/http/HTTP.cc +++ b/src/analyzer/protocol/http/HTTP.cc @@ -583,9 +583,16 @@ void HTTP_Message::Done(const int interrupted, const char* detail) top_level->EndOfData(); if ( is_orig || MyHTTP_Analyzer()->HTTP_ReplyCode() != 206 ) - // multipart/byteranges may span multiple connections - file_mgr->EndOfFile(MyHTTP_Analyzer()->GetAnalyzerTag(), - MyHTTP_Analyzer()->Conn(), is_orig); + { + // multipart/byteranges may span multiple connections, so don't EOF. + HTTP_Entity* he = dynamic_cast(top_level); + + if ( he && ! he->FileID().empty() ) + file_mgr->EndOfFile(he->FileID()); + else + file_mgr->EndOfFile(MyHTTP_Analyzer()->GetAnalyzerTag(), + MyHTTP_Analyzer()->Conn(), is_orig); + } if ( http_message_done ) { @@ -663,8 +670,15 @@ void HTTP_Message::EndEntity(mime::MIME_Entity* entity) Done(); else if ( is_orig || MyHTTP_Analyzer()->HTTP_ReplyCode() != 206 ) - file_mgr->EndOfFile(MyHTTP_Analyzer()->GetAnalyzerTag(), - MyHTTP_Analyzer()->Conn(), is_orig); + { + HTTP_Entity* he = dynamic_cast(entity); + + if ( he && ! he->FileID().empty() ) + file_mgr->EndOfFile(he->FileID()); + else + file_mgr->EndOfFile(MyHTTP_Analyzer()->GetAnalyzerTag(), + MyHTTP_Analyzer()->Conn(), is_orig); + } } void HTTP_Message::SubmitHeader(mime::MIME_Header* h) diff --git a/src/analyzer/protocol/http/HTTP.h b/src/analyzer/protocol/http/HTTP.h index 48a611b63b..0318dc9601 100644 --- a/src/analyzer/protocol/http/HTTP.h +++ b/src/analyzer/protocol/http/HTTP.h @@ -46,6 +46,7 @@ public: int64_t BodyLength() const { return body_length; } int64_t HeaderLength() const { return header_length; } void SkipBody() { deliver_body = 0; } + const string& FileID() const { return precomputed_file_id; } protected: class UncompressedOutput;