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
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -113,6 +113,8 @@ int http_codec::decode(const OCTETSTRING &data, LibHttp__TypesAndValues::HttpMes
      LibHttp__TypesAndValues::Headers headers;
      std::string                      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
        // 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,6 +419,10 @@ int http_codec::decode_headers(TTCN_Buffer &decoding_buffer, LibHttp__TypesAndVa
      } break;
      case 1:
        if (headers.is_bound()) {
          if (_dc.length == -1) { // content-Length header not found, force length to 0, assuming no body is present
            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 {
@@ -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) {
  loggers::get_instance().log_msg(">>> http_codec::decode_header", header_line);
  loggers::get_instance().log_msg(">>> http_codec::decode_header: ", header_line);

  try {
    std::string          str(static_cast<const char *>(header_line));