Commit f750f1ab authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen
Browse files

Merge branch 'fix_PDU_session_establishment_reject' into 'develop'

Fix pdu session establishment reject

See merge request !59
parents 0bc2e054 2f8109e4
......@@ -40,6 +40,7 @@
#include <nghttp2/asio_http2_server.h>
#include "smf_config.hpp"
#include "3gpp_conversions.hpp"
#include "mime_parser.hpp"
extern smf::smf_config smf_cfg;
......@@ -102,21 +103,35 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
Logger::smf_api_server().debug("Got result for promise ID %d", promise_id);
nlohmann::json json_data = {};
mime_parser parser = {};
std::string json_format = {};
std::string body = {};
response.headers().add<Pistache::Http::Header::Location>(
sm_context_response.get_smf_context_uri()); // Location header
sm_context_response.get_json_data(json_data);
std::string json_format;
sm_context_response.get_json_format(json_format);
if (!json_data.empty()) {
if (sm_context_response.n1_sm_msg_is_set()) { // add N1 container if
// available
parser.create_multipart_related_content(
body, json_data.dump(), CURL_MIME_BOUNDARY,
sm_context_response.get_n1_sm_message(),
multipart_related_content_part_e::NAS, json_format);
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType(
"multipart/related; boundary=" + std::string(CURL_MIME_BOUNDARY)));
} else if (!json_data.empty()) { // if not, include json data if available
response.headers().add<Pistache::Http::Header::Location>(
sm_context_response.get_smf_context_uri()); // Location header
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType(json_format));
response.send(
Pistache::Http::Code(sm_context_response.get_http_code()),
json_data.dump().c_str());
} else {
body = json_data.dump().c_str();
} else { // otherwise, send reply without content
response.send(Pistache::Http::Code(sm_context_response.get_http_code()));
return;
}
response.send(
Pistache::Http::Code(sm_context_response.get_http_code()), body);
}
} // namespace api
} // namespace smf_server
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment