Loading ccsrc/Protocols/Http/http_codec.cc +28 −2 Original line number Diff line number Diff line Loading @@ -365,7 +365,12 @@ int http_codec::decode_header(CHARSTRING& header_line, LibItsHttp__TypesAndValue // Save the the body length loggers::get_instance().log("http_codec::decode_header: decoded Content-Length %s", m[2].str().c_str()); _dc.length = std::stoi(m[2].str()); } else if (m[1].str().compare("Transfer-Encoding") == 0) { if (m[2].str().find("chunked") != std::string::npos) { _dc.chunked = true; } } return 0; } catch(const std::logic_error& e) { Loading Loading @@ -459,7 +464,7 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod OCTETSTRING s(decoding_buffer.get_len() - decoding_buffer.get_pos(), decoding_buffer.get_data() + decoding_buffer.get_pos()); loggers::get_instance().log_msg("http_codec::decode_body: raw body=", s); // Align the payload length with the specified Content-lenght value loggers::get_instance().log("http_codec::decode_body: _dc.length=%d - body length=%d", _dc.length, s.lengthof()); loggers::get_instance().log("http_codec::decode_body: _dc.length=%d - body length=%d - chunked: %x", _dc.length, s.lengthof(), _dc.chunked); OCTETSTRING body; if (_dc.length != 0) { const unsigned char* p = static_cast<const unsigned char *>(s); Loading @@ -481,8 +486,29 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod counter += 1; } } loggers::get_instance().log("http_codec::decode_body: Counter=%d", counter); loggers::get_instance().log("http_codec::decode_body: counter=%d", counter); body = OCTETSTRING(body.lengthof() - counter, static_cast<const unsigned char*>(body)); if (_dc.chunked) { // Extract the size of the chunk <chunk size>\r[\n] counter = 0; while (counter < body.lengthof()) { if ((body[counter].get_octet() == '\r') || (body[counter].get_octet() == '\n')) { break; } counter += 1; } // End of 'while' statement loggers::get_instance().log("http_codec::decode_body: Chunked: counter=%d", counter); if (counter < body.lengthof()) { // Skip additional \n OCTETSTRING os(counter - 1, static_cast<const unsigned char*>(body)); loggers::get_instance().log_msg("http_codec::decode_body: os: ", os); int len = oct2int(os); loggers::get_instance().log("http_codec::decode_body: Chunk len: %d", len); if (body[counter].get_octet() == '\n') { counter += 1; } body = OCTETSTRING(len, counter + static_cast<const unsigned char*>(body)); } } loggers::get_instance().log_msg("http_codec::decode_body: Finalised body=", body); // Check if HTTP message body contains binary characters for (int i = 0; i < body.lengthof(); i++) { Loading ccsrc/Protocols/Http/http_codec.hh +2 −1 Original line number Diff line number Diff line Loading @@ -32,9 +32,10 @@ struct encoding_context { struct decoding_context { unsigned int length; unsigned char is_binary; bool chunked; decoding_context() { reset(); }; void reset() { length = -1; is_binary = 0x00; }; void reset() { length = -1; is_binary = 0x00; chunked = false; }; }; class http_codec: public codec < Loading etc/TestCodec/TestCodec.cfg +4 −3 Original line number Diff line number Diff line Loading @@ -12,8 +12,8 @@ LibCommon_Time.PX_TAC := 30.0 # you want to log into the file or display on console (standard error). LogFile := "../logs/%e.%h-%r.%s" FileMask := LOG_ALL | USER | DEBUG | MATCHING ConsoleMask := LOG_ALL | USER | DEBUG | MATCHING FileMask := LOG_ALL | USER | DEBUG | MATCHING | DEBUG_ENCDEC ConsoleMask := LOG_ALL | USER | DEBUG | MATCHING | DEBUG_ENCDEC #FileMask := ERROR | WARNING | USER | MATCHING | EXECUTOR_RUNTIME | VERDICTOP #ConsoleMask := ERROR | WARNING | USER | MATCHING | EXECUTOR_RUNTIME | VERDICTOP LogSourceInfo := Stack Loading Loading @@ -57,11 +57,12 @@ system.httpPort.params := "HTTP(codecs=held:held_codec;html:html_codec;json:json #TestCodec_Register.tc_register_request_2 #TestCodec_Invite.tc_invite_request_1 #TestCodec_Invite.tc_invite_request_2 TestCodec_Responses.tc_100_trying_1 #TestCodec_Responses.tc_100_trying_1 #TestCodec_HttpRequest.tc_http_get_1 #TestCodec_HttpResponse.tc_http_200_ok_1 #TestCodec_HttpPort.tc_http_map_1 #TestCodec_Xsd.tc_linear_ring_1 TestCodec_Xsd.tc_test_vendor_response_1 [GROUPS] # In this section you can specify groups of hosts. These groups can be used inside the Loading scripts/run_mtc_simu.bash 0 → 100755 +55 −0 Original line number Diff line number Diff line #!/bin/bash #set -evx clear CURPWD=`pwd` if [ ! "${PWD##*/}" == "objs" ] then cd ../objs if [ ! $? == 0 ] then echo "Please move to PROJECT/obj directory" exit 1 fi fi TITAN_LOG_DIR=../logs/simu if [ ! -d ${TITAN_LOG_DIR} ] then mkdir ${TITAN_LOG_DIR} else rm -f ${TITAN_LOG_DIR}/*.log fi CFG_FILES=../etc/simu/AtsNg112.cfg #LOG_FILES=`find ${TITAN_LOG_DIR} -name '*.log'` #mv ${LOG_FILES} ../logs #if [ "${OSTYPE}" == "cygwin" ] #then # # Remove dll # rm ./*.dll # ## Copy the new ones # cp ~/lib/libhelper.dll . # cp ~/lib/libconverter.dll . # cp ~/lib/liblogger.dll . # cp ~/lib/libttcn3_tri.dll . # cp ~/lib/libcomm.dll . #fi echo "> cmtc: to create the MTC server" echo "> smtc [module_name[[.control]|.testcase_name|.*]: when MyExample is connected, run the TCs in [EXECUTE] section" echo "> emtc: Terminate MTC." mctr ${CFG_FILES} LOG_FILES=`find ${TITAN_LOG_DIR} -name '*.log'` if [ "${TITAN_LOG_DIR}" != "" ] then ttcn3_logmerge -o ${TITAN_LOG_DIR}/merged.log ${LOG_FILES} ttcn3_logformat -o ${TITAN_LOG_DIR}/merged_formated.log ${TITAN_LOG_DIR}/merged.log mv ${TITAN_LOG_DIR}/merged_formated.log ${TITAN_LOG_DIR}/merged.log echo "log files were merged into ${TITAN_LOG_DIR}/merged.log" fi cd ${CURPWD} scripts/run_ptcs_simu.bash 0 → 100755 +20 −0 Original line number Diff line number Diff line #!/bin/bash #set -e #set -vx clear CURPWD=`pwd` if [ ! "${PWD##*/}" == "objs" ] then cd ../objs if [ ! $? == 0 ] then echo "Please move to PROJECT/obj directory" exit 1 fi fi @sudo LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) $(PWD)/../bin/$(EXECUTABLE) 127.0.0.1 12666 cd ${CURPWD} Loading
ccsrc/Protocols/Http/http_codec.cc +28 −2 Original line number Diff line number Diff line Loading @@ -365,7 +365,12 @@ int http_codec::decode_header(CHARSTRING& header_line, LibItsHttp__TypesAndValue // Save the the body length loggers::get_instance().log("http_codec::decode_header: decoded Content-Length %s", m[2].str().c_str()); _dc.length = std::stoi(m[2].str()); } else if (m[1].str().compare("Transfer-Encoding") == 0) { if (m[2].str().find("chunked") != std::string::npos) { _dc.chunked = true; } } return 0; } catch(const std::logic_error& e) { Loading Loading @@ -459,7 +464,7 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod OCTETSTRING s(decoding_buffer.get_len() - decoding_buffer.get_pos(), decoding_buffer.get_data() + decoding_buffer.get_pos()); loggers::get_instance().log_msg("http_codec::decode_body: raw body=", s); // Align the payload length with the specified Content-lenght value loggers::get_instance().log("http_codec::decode_body: _dc.length=%d - body length=%d", _dc.length, s.lengthof()); loggers::get_instance().log("http_codec::decode_body: _dc.length=%d - body length=%d - chunked: %x", _dc.length, s.lengthof(), _dc.chunked); OCTETSTRING body; if (_dc.length != 0) { const unsigned char* p = static_cast<const unsigned char *>(s); Loading @@ -481,8 +486,29 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod counter += 1; } } loggers::get_instance().log("http_codec::decode_body: Counter=%d", counter); loggers::get_instance().log("http_codec::decode_body: counter=%d", counter); body = OCTETSTRING(body.lengthof() - counter, static_cast<const unsigned char*>(body)); if (_dc.chunked) { // Extract the size of the chunk <chunk size>\r[\n] counter = 0; while (counter < body.lengthof()) { if ((body[counter].get_octet() == '\r') || (body[counter].get_octet() == '\n')) { break; } counter += 1; } // End of 'while' statement loggers::get_instance().log("http_codec::decode_body: Chunked: counter=%d", counter); if (counter < body.lengthof()) { // Skip additional \n OCTETSTRING os(counter - 1, static_cast<const unsigned char*>(body)); loggers::get_instance().log_msg("http_codec::decode_body: os: ", os); int len = oct2int(os); loggers::get_instance().log("http_codec::decode_body: Chunk len: %d", len); if (body[counter].get_octet() == '\n') { counter += 1; } body = OCTETSTRING(len, counter + static_cast<const unsigned char*>(body)); } } loggers::get_instance().log_msg("http_codec::decode_body: Finalised body=", body); // Check if HTTP message body contains binary characters for (int i = 0; i < body.lengthof(); i++) { Loading
ccsrc/Protocols/Http/http_codec.hh +2 −1 Original line number Diff line number Diff line Loading @@ -32,9 +32,10 @@ struct encoding_context { struct decoding_context { unsigned int length; unsigned char is_binary; bool chunked; decoding_context() { reset(); }; void reset() { length = -1; is_binary = 0x00; }; void reset() { length = -1; is_binary = 0x00; chunked = false; }; }; class http_codec: public codec < Loading
etc/TestCodec/TestCodec.cfg +4 −3 Original line number Diff line number Diff line Loading @@ -12,8 +12,8 @@ LibCommon_Time.PX_TAC := 30.0 # you want to log into the file or display on console (standard error). LogFile := "../logs/%e.%h-%r.%s" FileMask := LOG_ALL | USER | DEBUG | MATCHING ConsoleMask := LOG_ALL | USER | DEBUG | MATCHING FileMask := LOG_ALL | USER | DEBUG | MATCHING | DEBUG_ENCDEC ConsoleMask := LOG_ALL | USER | DEBUG | MATCHING | DEBUG_ENCDEC #FileMask := ERROR | WARNING | USER | MATCHING | EXECUTOR_RUNTIME | VERDICTOP #ConsoleMask := ERROR | WARNING | USER | MATCHING | EXECUTOR_RUNTIME | VERDICTOP LogSourceInfo := Stack Loading Loading @@ -57,11 +57,12 @@ system.httpPort.params := "HTTP(codecs=held:held_codec;html:html_codec;json:json #TestCodec_Register.tc_register_request_2 #TestCodec_Invite.tc_invite_request_1 #TestCodec_Invite.tc_invite_request_2 TestCodec_Responses.tc_100_trying_1 #TestCodec_Responses.tc_100_trying_1 #TestCodec_HttpRequest.tc_http_get_1 #TestCodec_HttpResponse.tc_http_200_ok_1 #TestCodec_HttpPort.tc_http_map_1 #TestCodec_Xsd.tc_linear_ring_1 TestCodec_Xsd.tc_test_vendor_response_1 [GROUPS] # In this section you can specify groups of hosts. These groups can be used inside the Loading
scripts/run_mtc_simu.bash 0 → 100755 +55 −0 Original line number Diff line number Diff line #!/bin/bash #set -evx clear CURPWD=`pwd` if [ ! "${PWD##*/}" == "objs" ] then cd ../objs if [ ! $? == 0 ] then echo "Please move to PROJECT/obj directory" exit 1 fi fi TITAN_LOG_DIR=../logs/simu if [ ! -d ${TITAN_LOG_DIR} ] then mkdir ${TITAN_LOG_DIR} else rm -f ${TITAN_LOG_DIR}/*.log fi CFG_FILES=../etc/simu/AtsNg112.cfg #LOG_FILES=`find ${TITAN_LOG_DIR} -name '*.log'` #mv ${LOG_FILES} ../logs #if [ "${OSTYPE}" == "cygwin" ] #then # # Remove dll # rm ./*.dll # ## Copy the new ones # cp ~/lib/libhelper.dll . # cp ~/lib/libconverter.dll . # cp ~/lib/liblogger.dll . # cp ~/lib/libttcn3_tri.dll . # cp ~/lib/libcomm.dll . #fi echo "> cmtc: to create the MTC server" echo "> smtc [module_name[[.control]|.testcase_name|.*]: when MyExample is connected, run the TCs in [EXECUTE] section" echo "> emtc: Terminate MTC." mctr ${CFG_FILES} LOG_FILES=`find ${TITAN_LOG_DIR} -name '*.log'` if [ "${TITAN_LOG_DIR}" != "" ] then ttcn3_logmerge -o ${TITAN_LOG_DIR}/merged.log ${LOG_FILES} ttcn3_logformat -o ${TITAN_LOG_DIR}/merged_formated.log ${TITAN_LOG_DIR}/merged.log mv ${TITAN_LOG_DIR}/merged_formated.log ${TITAN_LOG_DIR}/merged.log echo "log files were merged into ${TITAN_LOG_DIR}/merged.log" fi cd ${CURPWD}
scripts/run_ptcs_simu.bash 0 → 100755 +20 −0 Original line number Diff line number Diff line #!/bin/bash #set -e #set -vx clear CURPWD=`pwd` if [ ! "${PWD##*/}" == "objs" ] then cd ../objs if [ ! $? == 0 ] then echo "Please move to PROJECT/obj directory" exit 1 fi fi @sudo LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) $(PWD)/../bin/$(EXECUTABLE) 127.0.0.1 12666 cd ${CURPWD}