Commit 2561f841 authored by garciay's avatar garciay
Browse files

Update HTTP Ng112 to ITS

parent 709c4cdb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ public: //! \publicsection
  static const std::string& port;                  //! Commsignia HTTP server port. Default: 80
  static const std::string& use_ssl;               //! Set to 1 to use SSL to communicate with the HTTP server. Default: false

  static const std::string& codecs;                //! List of codecs to use for HTTP application layers

  /*!
   * \brief Default constructor
+2 −0
Original line number Diff line number Diff line
@@ -72,6 +72,8 @@ const std::string& params::server = std::string("server");
const std::string& params::port = std::string("port");
const std::string& params::use_ssl = std::string("use_ssl");

const std::string& params::codecs = std::string("codecs");

void params::convert(params& p_param, const std::string p_parameters) {
  // Sanity checks
  if (p_parameters.length() == 0) {
+16 −17
Original line number Diff line number Diff line
@@ -329,24 +329,23 @@ int http_codec::encode_body(const LibItsHttp__MessageBodyTypes::HttpMessageBody&
  } else if (p_message_body.ischosen(LibItsHttp__MessageBodyTypes::HttpMessageBody::ALT_text__body)) {
    p_encoding_buffer = OCTETSTRING(p_message_body.text__body().lengthof(), (unsigned char*)static_cast<const char*>(p_message_body.text__body()));
  } else if (p_message_body.ischosen(LibItsHttp__MessageBodyTypes::HttpMessageBody::ALT_xml__body)) {
    loggers::get_instance().error("http_codec::encode_body: Failed to encode HTTP message body");
    const LibItsHttp__XmlMessageBodyTypes::XmlBody& xml_body = p_message_body.xml__body();
    if (xml_body.ischosen(LibItsHttp__XmlMessageBodyTypes::XmlBody::ALT_raw)) {
      p_encoding_buffer = OCTETSTRING(xml_body.raw().lengthof(), (unsigned char*)static_cast<const char*>(xml_body.raw()));
      } else if (xml_body.ischosen(LibItsHttp__XmlMessageBodyTypes::XmlBody::ALT_locationRequest)) {
        if (_codecs["held"].get() != nullptr) {
    } else {
      std::map<std::string, std::unique_ptr<codec<Record_Type, Record_Type> > >::const_iterator it = _codecs.find("held");
      if (it != _codecs.cend()) {
        loggers::get_instance().log("http_codec::encode_body: Call 'held_codec'");
        _codecs["held"]->encode((Record_Type&)xml_body, p_encoding_buffer);
        } else {
          loggers::get_instance().warning("http_codec::encode_body: Failed to encode HELD message");
          return -1;
      } else
        loggers::get_instance().warning("http_codec::encode_body: Unsupported HTTP codec, use raw field as default");
        p_encoding_buffer = OCTETSTRING(xml_body.raw().lengthof(), (unsigned char*)static_cast<const char*>(xml_body.raw()));
        // TODO Add new HTTP message codec here
      }
      } else if (xml_body.ischosen(LibItsHttp__XmlMessageBodyTypes::XmlBody::ALT_locationResponse)) {
        loggers::get_instance().warning("http_codec::encode_body: No variant to encode");
      } else {
        // TODO To be continued
    }
  } else {
    loggers::get_instance().warning("http_codec::encode_body: Failed to encode HTTP message body");
    loggers::get_instance().log("http_codec::encode_body: Failed to encode HTTP message body");
    return -1;
  }
  loggers::get_instance().log_msg("http_codec::encode_body: HTTP message ", p_encoding_buffer);
@@ -435,13 +434,13 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod
      }
    } else if (p["decode_str"].find("<html>") != std::string::npos) { // Try to identify HTML
      loggers::get_instance().log("http_codec::decode_body: Find html message");
      LibItsHttp__MessageBodyTypes::TextBody txt_body;
      LibItsHttp__MessageBodyTypes::HtmlBody html_body;
      loggers::get_instance().error("http_codec::decode_body: Not supported");
    } else {
      loggers::get_instance().log("http_codec::decode_body: Use textBdy as default");
      LibItsHttp__MessageBodyTypes::TextBody text_body;
      message_body.text__body() = CHARSTRING(body.lengthof(), (char*)static_cast<const unsigned char*>(body));
    }
      }*/
  }
  
  return 0;
+1 −1

File changed.

Contains only whitespace changes.