0 Replies Latest reply on Jul 12, 2017 2:25 PM by Mark Sta Ana

    Is this an ORDS bug?

    Mark Sta Ana

      I've noticed that I get no data from my template if set the owa_util.mime_header's blclose_header to false.

       

      Setting this parameter to

      • false a single new line is set and the http headers remain open to be extended.
      • true will send two new lines and close the http headers.

       

      The general gist of my PL/SQL block for the GET Handler looks like this (full test code to follow)....

       

      DECLARE
          l_clob   CLOB;
      BEGIN
          SELECT
              '<xml>hello world</xml>'
          INTO
              l_clob
          FROM
              dual;
      
          owa_util.mime_header(
              ccontent_type   => 'text/xml',
              bclose_header   => ???,
              ccharset        => 'ISO-8859-4'
          );
      
          htp.print(l_clob);
      END;
      

       

      Here's the curl output from two templates I've setup with the owa_util.mime_header's bclose_header set.

       

      Where the parameter is set to true (which works)

      $ curl -v http://oracle.rocks:8080/ords/scott/reporting/mime_works
      * About to connect() to oracle.rocks port 8080 (#0)
      *   Trying 1.2.3.4... connected
      * Connected to oracle.rocks (1.2.3.4) port 8080 (#0)
      > GET /ords/scott/reporting/mime_works HTTP/1.1
      > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
      > Host: oracle.rocks:8080
      > Accept: */*
      >
      < HTTP/1.1 200 OK
      < Content-Type: text/xml; charset=ISO-8859-4
      < ETag: "WaloI8WDL3PY2G0ZN6+I8C+c0FxVaUBuDc/v7LKXTpE6dTuJR1s2bLF/0hqW2fVzaXNYpr9TFXqucyoq6dO2Xw=="
      < Transfer-Encoding: chunked
      <
      <xml>hello world</xml>
      * Connection #0 to host oracle.rocks left intact
      * Closing connection #0
      

       

      Where the parameter is set to false (which doesn't works)

       

      $ curl -v http://oracle.rocks:8080/ords/scott/reporting/mime_bug
      * About to connect() to oracle.rocks port 8080 (#0)
      *   Trying 1.2.3.4... connected
      * Connected to oracle.rocks (1.2.3.4) port 8080 (#0)
      > GET /ords/scott/reporting/mime_bug HTTP/1.1
      > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
      > Host: oracle.rocks:8080
      > Accept: */*
      >
      < HTTP/1.1 200 OK
      < Content-Type: text/xml; charset=ISO-8859-4
      < ETag: "YRq3u9iWCk3bDs3vq+9w44eFey97arSyuIHaUB70jNACTfNASf6381sH71Vh5SEUHN0qECBaAJgwGVRKR3ZhtA=="
      < Transfer-Encoding: chunked
      <
      * Connection #0 to host oracle.rocks left intact
      * Closing connection #0
      
      

       

      Finally test script, I've not had a chance to test with ORDS 3.0.10.

       

      BEGIN
        ORDS.DEFINE_MODULE(
            p_module_name    => 'reporting',
            p_base_path      => '/reporting/',
            p_items_per_page =>  0,
            p_status         => 'PUBLISHED',
            p_comments       => NULL);      
        ORDS.DEFINE_TEMPLATE(
            p_module_name    => 'reporting',
            p_pattern        => 'mime_bug',
            p_priority       => 0,
            p_etag_type      => 'HASH',
            p_etag_query     => NULL,
            p_comments       => NULL);
        ORDS.DEFINE_HANDLER(
            p_module_name    => 'reporting',
            p_pattern        => 'mime_bug',
            p_method         => 'GET',
            p_source_type    => 'plsql/block',
            p_items_per_page =>  0,
            p_mimes_allowed  => '',
            p_comments       => NULL,
            p_source         => 
      'DECLARE
          l_clob   CLOB;
      BEGIN
          SELECT
              ''<xml>hello world</xml>''
          INTO
              l_clob
          FROM
              dual;
      
          owa_util.mime_header(
              ccontent_type   => ''text/xml'',
              bclose_header   => false,
              ccharset        => ''ISO-8859-4''
          );
      
          htp.print(l_clob);
      END;'
            );
        ORDS.DEFINE_TEMPLATE(
            p_module_name    => 'reporting',
            p_pattern        => 'mime_works',
            p_priority       => 0,
            p_etag_type      => 'HASH',
            p_etag_query     => NULL,
            p_comments       => NULL);
        ORDS.DEFINE_HANDLER(
            p_module_name    => 'reporting',
            p_pattern        => 'mime_works',
            p_method         => 'GET',
            p_source_type    => 'plsql/block',
            p_items_per_page =>  0,
            p_mimes_allowed  => '',
            p_comments       => NULL,
            p_source         => 
      'DECLARE
          l_clob   CLOB;
      BEGIN
          SELECT
              ''<xml>hello world</xml>''
          INTO
              l_clob
          FROM
              dual;
      
          owa_util.mime_header(
              ccontent_type   => ''text/xml'',
              bclose_header   => true,
              ccharset        => ''ISO-8859-4''
          );
      
          htp.print(l_clob);
      END;'
            );
        COMMIT; 
      END;
      

       

      It wouldn't surprise me if this turns out to be a bug in OWA_UTIL...