Skip to content
Snippets Groups Projects
Commit 7d4fc332 authored by Yann Garcia's avatar Yann Garcia
Browse files

Bug fixed in HTTP codec when Content-Length is no present

parent 6901c1c3
No related branches found
No related tags found
1 merge request!2Closing TTF T024/025
...@@ -113,6 +113,8 @@ int http_codec::decode(const OCTETSTRING &data, LibHttp__TypesAndValues::HttpMes ...@@ -113,6 +113,8 @@ int http_codec::decode(const OCTETSTRING &data, LibHttp__TypesAndValues::HttpMes
LibHttp__TypesAndValues::Headers headers; LibHttp__TypesAndValues::Headers headers;
std::string content_type; std::string content_type;
decode_headers(decoding_buffer, headers, content_type); decode_headers(decoding_buffer, headers, content_type);
loggers::get_instance().log("http_codec::decode: _dc.length=%d", _dc.length);
loggers::get_instance().log("http_codec::decode: decoding_buffer.get_len()=%d", decoding_buffer.get_len());
if (_dc.length > decoding_buffer.get_len()) { // HTTP response is fragmented if (_dc.length > decoding_buffer.get_len()) { // HTTP response is fragmented
// Need to bufferize the first packet and wait for the other fragments tp be received // Need to bufferize the first packet and wait for the other fragments tp be received
loggers::get_instance().warning("http_codec::decode: Need to bufferize the first packet and wait for the other fragments tp be received"); loggers::get_instance().warning("http_codec::decode: Need to bufferize the first packet and wait for the other fragments tp be received");
...@@ -417,8 +419,12 @@ int http_codec::decode_headers(TTCN_Buffer &decoding_buffer, LibHttp__TypesAndVa ...@@ -417,8 +419,12 @@ int http_codec::decode_headers(TTCN_Buffer &decoding_buffer, LibHttp__TypesAndVa
} break; } break;
case 1: case 1:
if (headers.is_bound()) { if (headers.is_bound()) {
loggers::get_instance().log_msg("<<< http_codec::decode_headers: ", headers); if (_dc.length == -1) { // content-Length header not found, force length to 0, assuming no body is present
return 0; loggers::get_instance().log("http_codec::decode_headers: Force _dc.length to 0");
_dc.length = 0;
}
loggers::get_instance().log_msg("<<< http_codec::decode_headers: ", headers);
return 0;
} else { } else {
loggers::get_instance().warning("http_codec::decode_headers: Failed to decode headers"); loggers::get_instance().warning("http_codec::decode_headers: Failed to decode headers");
return -1; return -1;
...@@ -431,7 +437,7 @@ int http_codec::decode_headers(TTCN_Buffer &decoding_buffer, LibHttp__TypesAndVa ...@@ -431,7 +437,7 @@ int http_codec::decode_headers(TTCN_Buffer &decoding_buffer, LibHttp__TypesAndVa
} }
int http_codec::decode_header(CHARSTRING &header_line, LibHttp__TypesAndValues::Header &header) { int http_codec::decode_header(CHARSTRING &header_line, LibHttp__TypesAndValues::Header &header) {
loggers::get_instance().log_msg(">>> http_codec::decode_header", header_line); loggers::get_instance().log_msg(">>> http_codec::decode_header: ", header_line);
try { try {
std::string str(static_cast<const char *>(header_line)); std::string str(static_cast<const char *>(header_line));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment