Loading ccsrc/Protocols/Http/http_layer.cc +41 −26 Original line number Diff line number Diff line Loading @@ -188,7 +188,7 @@ void http_layer::receive_data(OCTETSTRING &p_data, params ¶ms) { if (_device_mode) { loggers::get_instance().log("http_layer::receive_data: Device mode set"); OCTETSTRING os; OCTETSTRING os(0, nullptr); if (http_message.ischosen(LibHttp__TypesAndValues::HttpMessage::ALT_response)) { if (http_message.response().body().ispresent()) { LibHttp__MessageBodyTypes::HttpMessageBody &body = Loading Loading @@ -224,6 +224,10 @@ void http_layer::receive_data(OCTETSTRING &p_data, params ¶ms) { os = char2oct(body.text__body()); params.insert(std::pair<std::string, std::string>(params::serialization, "txt")); } } else { loggers::get_instance().warning("http_layer::receive_data: No body present"); http_message.response().body().set_to_omit(); } // Add additional message information params.insert(std::pair<std::string, std::string>(params::type, "response")); params.insert(std::pair<std::string, std::string>(params::protocol_binding, "HTTP")); Loading @@ -237,6 +241,20 @@ void http_layer::receive_data(OCTETSTRING &p_data, params ¶ms) { params.insert(std::pair<std::string, std::string>(static_cast<const char*>(http_message.response().header()[i].header__name()), "")); } else if (v.lengthof() == 1) { params.insert(std::pair<std::string, std::string>(static_cast<const char*>(http_message.response().header()[i].header__name()), v[0])); std::string h = static_cast<const char*>(http_message.response().header()[i].header__name()); if ((os.lengthof() == 0) && ((h.compare("Content-Type") == 0) || (h.compare("Content-type") == 0) || (h.compare("content-type") == 0))) { // Force the serialization parameter to be set according to the Content-Type header std::string s = std::string(static_cast<const char*>(v[0])); if (s.find("json") != std::string::npos) { loggers::get_instance().warning("http_layer::receive_data: Force serialization to json"); params[params::serialization] = "json"; } else if (s.find("cbor") != std::string::npos) { loggers::get_instance().warning("http_layer::receive_data: Force serialization to cbor"); params[params::serialization] = "cbor"; } else if (s.find("xml") != std::string::npos) { loggers::get_instance().warning("http_layer::receive_data: Force serialization to xml"); params[params::serialization] = "xml"; } } } else { std::ostringstream oss; int j = 0; Loading @@ -249,9 +267,6 @@ void http_layer::receive_data(OCTETSTRING &p_data, params ¶ms) { } } // End of 'for' statement receive_to_all_layers(os, params); } else { loggers::get_instance().warning("http_layer::receive_data: No body present"); } } else { loggers::get_instance().warning("http_layer::receive_data: An HTTP response is expected"); } Loading Loading
ccsrc/Protocols/Http/http_layer.cc +41 −26 Original line number Diff line number Diff line Loading @@ -188,7 +188,7 @@ void http_layer::receive_data(OCTETSTRING &p_data, params ¶ms) { if (_device_mode) { loggers::get_instance().log("http_layer::receive_data: Device mode set"); OCTETSTRING os; OCTETSTRING os(0, nullptr); if (http_message.ischosen(LibHttp__TypesAndValues::HttpMessage::ALT_response)) { if (http_message.response().body().ispresent()) { LibHttp__MessageBodyTypes::HttpMessageBody &body = Loading Loading @@ -224,6 +224,10 @@ void http_layer::receive_data(OCTETSTRING &p_data, params ¶ms) { os = char2oct(body.text__body()); params.insert(std::pair<std::string, std::string>(params::serialization, "txt")); } } else { loggers::get_instance().warning("http_layer::receive_data: No body present"); http_message.response().body().set_to_omit(); } // Add additional message information params.insert(std::pair<std::string, std::string>(params::type, "response")); params.insert(std::pair<std::string, std::string>(params::protocol_binding, "HTTP")); Loading @@ -237,6 +241,20 @@ void http_layer::receive_data(OCTETSTRING &p_data, params ¶ms) { params.insert(std::pair<std::string, std::string>(static_cast<const char*>(http_message.response().header()[i].header__name()), "")); } else if (v.lengthof() == 1) { params.insert(std::pair<std::string, std::string>(static_cast<const char*>(http_message.response().header()[i].header__name()), v[0])); std::string h = static_cast<const char*>(http_message.response().header()[i].header__name()); if ((os.lengthof() == 0) && ((h.compare("Content-Type") == 0) || (h.compare("Content-type") == 0) || (h.compare("content-type") == 0))) { // Force the serialization parameter to be set according to the Content-Type header std::string s = std::string(static_cast<const char*>(v[0])); if (s.find("json") != std::string::npos) { loggers::get_instance().warning("http_layer::receive_data: Force serialization to json"); params[params::serialization] = "json"; } else if (s.find("cbor") != std::string::npos) { loggers::get_instance().warning("http_layer::receive_data: Force serialization to cbor"); params[params::serialization] = "cbor"; } else if (s.find("xml") != std::string::npos) { loggers::get_instance().warning("http_layer::receive_data: Force serialization to xml"); params[params::serialization] = "xml"; } } } else { std::ostringstream oss; int j = 0; Loading @@ -249,9 +267,6 @@ void http_layer::receive_data(OCTETSTRING &p_data, params ¶ms) { } } // End of 'for' statement receive_to_all_layers(os, params); } else { loggers::get_instance().warning("http_layer::receive_data: No body present"); } } else { loggers::get_instance().warning("http_layer::receive_data: An HTTP response is expected"); } Loading