00001 //--------------------------------------------------------------------------
00002 // Copyright (C) 2014-2017 Cisco and/or its affiliates. All rights reserved.
00003 //
00004 // This program is free software; you can redistribute it and/or modify it
00005 // under the terms of the GNU General Public License Version 2 as published
00006 // by the Free Software Foundation. You may not use, modify or distribute
00007 // this program under any other version of the GNU General Public License.
00008 //
00009 // This program is distributed in the hope that it will be useful, but
00010 // WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License along
00015 // with this program; if not, write to the Free Software Foundation, Inc.,
00016 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017 //--------------------------------------------------------------------------
00018 // http_transaction.h author Tom Peters <thopeter@cisco.com>
00019
00020 #ifndef TRANSACTION_H
00021 #define TRANSACTION_H
00022
00023 #include "http_enum.h"
00024 #include "http_flow_data.h"
00025
00026 class HttpMsgRequest;
00027 class HttpMsgStatus;
00028 class HttpMsgHeader;
00029 class HttpMsgTrailer;
00030 class HttpMsgSection;
00031 class HttpMsgBody;
00032 class HttpMsgHeadShared;
00033 class HttpInfractions;
00034 class HttpEventGen;
00035
00036 class HttpTransaction
00037 {
00038 public:
00039 static HttpTransaction* attach_my_transaction(HttpFlowData* session_data,
00040 HttpEnums::SourceId source_id);
00041 static void delete_transaction(HttpTransaction* transaction);
00042
00043 HttpMsgRequest* get_request() const { return request; }
00044 void set_request(HttpMsgRequest* request_) { request = request_; }
00045
00046 HttpMsgStatus* get_status() const { return status; }
00047 void set_status(HttpMsgStatus* status_) { status = status_; }
00048
00049 HttpMsgHeader* get_header(HttpEnums::SourceId source_id) const { return header[source_id]; }
00050 void set_header(HttpMsgHeader* header_, HttpEnums::SourceId source_id)
00051 { header[source_id] = header_; }
00052
00053 HttpMsgTrailer* get_trailer(HttpEnums::SourceId source_id) const
00054 { return trailer[source_id]; }
00055 void set_trailer(HttpMsgTrailer* trailer_, HttpEnums::SourceId source_id)
00056 { trailer[source_id] = trailer_; }
00057
00058 HttpMsgBody* get_body() const { return latest_body; }
00059 void set_body(HttpMsgBody* latest_body_);
00060
00061 HttpInfractions* get_infractions(HttpEnums::SourceId source_id);
00062 HttpEventGen* get_events(HttpEnums::SourceId source_id);
00063
00064 void set_one_hundred_response();
00065 bool final_response() const { return !second_response_expected; }
00066
00067 private:
00068 HttpTransaction() = default;
00069 ~HttpTransaction();
00070
00071 HttpMsgRequest* request = nullptr;
00072 HttpMsgStatus* status = nullptr;
00073 HttpMsgHeader* header[2] = { nullptr, nullptr };
00074 HttpMsgTrailer* trailer[2] = { nullptr, nullptr };
00075 HttpMsgBody* latest_body = nullptr;
00076 HttpInfractions* infractions[2] = { nullptr, nullptr };
00077 HttpEventGen* events[2] = { nullptr, nullptr };
00078
00079 bool response_seen = false;
00080 bool one_hundred_response = false;
00081 bool second_response_expected = false;
00082
00083 // This is a form of reference counting that prevents premature/double deletion of a
00084 // transaction in the fairly rare case where the request and response are received in
00085 // parallel.
00086 bool shared_ownership = false;
00087 };
00088
00089 #endif
00090
END OF CODE