ANNA Suite  2020b
Multipurpose development suite for Telco applications
Transport.hpp
Go to the documentation of this file.
1 // ANNA - Anna is Not Nothingness Anymore //
2 // //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
4 // //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7 
8 
9 #ifndef anna_http_Transport_hpp
10 #define anna_http_Transport_hpp
11 
12 #include <anna/core/DataBlock.hpp>
13 
14 #include <anna/comm/Transport.hpp>
17 
19 #include <anna/http/Message.hpp>
20 
21 namespace anna {
22 
23 namespace http {
24 
25 class EncodedBlock;
26 
27 namespace parser {
28 class Abstract;
29 }
30 
36 class Transport : public comm::Transport {
37 public:
42  Transport();
43 
47  virtual ~Transport() {;}
48 
54  int getContentLength() const { return a_contentLength; }
55 
61  http::Message* getInputMessage() noexcept(false);
62 
68  void setContentLength(const int contentLength) noexcept(false) { a_contentLength = contentLength; }
69 
75  void setBodyOffset(const int bodyOffset) noexcept(false) { a_bodyOffset = bodyOffset; }
76 
81  void clear() ;
82 
91  const http::Message* externalDecode(const char* buffer, const int length) noexcept(false);
92 
99  http::Message* allocateInputMessage(const Message::Type::_v type) noexcept(false);
100 
105  EncodedBlock* getEncodedBlock() ;
106 
115  const Tokenizer& split(const Token& token) noexcept(false);
116 
125  const Tokenizer& split(const Token& token, const char* separator) noexcept(false);
126 
135  const Tokenizer& split(const Token& token, const char separator) noexcept(false);
136 
141  static const char* className() { return "anna::http::Transport"; }
142 
147  static comm::TransportFactory& getFactory() { return st_factory; }
148 
149 private:
150  //-------------------------------------------------------------------------------------
151  // - a_parser: Analizador del mensaje HTTP. Realiza un analisis en profundidad para
152  // interpretar el contenido del mensaje.
153  // - a_contentLenth: TamaƱo indicado por la etiqueta HTTP Content-length.
154  // - a_bodyOffset: Indica el desplazamiento que hay que aplicar en http::Transport::decode
155  // para direccionar el contenido del mensaje HTTP.
156  // - a_result: El decode nos obliga a devolver un DataBlock => devolvemos el
157  // a_inputMessage que nos dara la direccion al http::Message al invocar a
158  // DataBlock::getData.
159  // - a_haveToClear: Indica si el metodo calculeSize debe iniciar el estado de la instancia.
160  // - a_inputMessage: Instancia del mensaje obtenida al realizar el analisis detallado
161  // del ultimo mensaje recibido.
162  //--------------------------------------------------------------------------------------
163  const parser::Abstract* a_parser;
164  int a_contentLength;
165  int a_bodyOffset;
166  DataBlock a_result;
167  bool a_haveToClear;
168  http::Message* a_inputMessage;
169  Tokenizer a_fullScope;
170  Tokenizer a_lineScope;
171  EncodedBlock* a_encodedBlock;
172  int a_lastChunkedByte;
173  const DataBlock* a_fullMessage;
174 
176 
177  void setParserState(const parser::Abstract* parser) noexcept(false);
178 
179  int calculeSize(const DataBlock&) noexcept(false);
180  const comm::Message* decode(const DataBlock&) noexcept(false);
181  const DataBlock& code(comm::Message&) noexcept(false);
182 
183  /*
184  static const Token* tryRequest (const Tokenizer&) ;
185  static const Token* tryResponse (const Tokenizer&) ;
186  */
187  friend class anna::Allocator <http::Transport>;
188  friend class parser::Abstract;
189 };
190 
191 }
192 }
193 #endif
194 
Definition: Message.hpp:30
void setBodyOffset(const int bodyOffset) noexcept(false)
Definition: Transport.hpp:75
Definition: EncodedBlock.hpp:18
Definition: Abstract.hpp:28
Definition: Transport.hpp:44
Definition: Tokenizer.hpp:22
static const char * className()
Definition: Transport.hpp:141
Definition: Token.hpp:20
Definition: Allocator.hpp:19
Definition: Message.hpp:26
void setContentLength(const int contentLength) noexcept(false)
Definition: Transport.hpp:68
_v
Definition: Message.hpp:46
Definition: TransportFactoryImpl.hpp:25
Definition: app.hpp:12
Definition: Transport.hpp:36
int getContentLength() const
Definition: Transport.hpp:54
const char contentLength[16]
static comm::TransportFactory & getFactory()
Definition: Transport.hpp:147
Definition: TransportFactory.hpp:30
virtual ~Transport()
Definition: Transport.hpp:47
Definition: DataBlock.hpp:24