Skip to Main Content
  • Questions
  • Receive http requests with more than 32k

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Norman.

Asked: October 19, 2017 - 4:28 pm UTC

Last updated: February 18, 2021 - 6:03 pm UTC

Version: 11.2.0.4

Viewed 1000+ times

You Asked

Hi Tom,

on more question :)
I´m using the utl_http package to exchange xml-data between different oracle databases.
Until now i´ve requested the mod_plsql (until 11g) or the apache (from 12c) on the other database, posted the data with utl_http.write_text and received it with (name_Array in OWA.vc_arr, value_array in OWA.vc_arr).
Meanwhile my amount of data is growing and growing .... up to over 32k.

Now i´ve ask myself if i could chunk it.

For sure i can set the header "Transfer-Encoding" to chunk the sending side...
utl_http.set_header (l_http_request, 'Transfer-Encoding', 'chunked');
... but how do i get more than 32k on the receiving side?
Maybe you could give me an example.

Thanks for your help :)

and we said...

You can read it in chunks, eg

set serverout on
declare
  l_url      varchar2(100) := '[your url]';
  l_req      utl_http.req;
  l_resp     utl_http.resp;
  l_content  clob;
  l_buffer   varchar2(32767);
begin
  dbms_lob.createtemporary(l_content, false);

  l_req  := utl_http.begin_request(l_url);
  l_resp := utl_http.get_response(l_req);

  begin
    loop
      utl_http.read_text(l_resp, l_buffer, 32000);
      dbms_lob.writeappend (l_content, length(l_buffer), l_buffer);
    end loop;
  exception
    when utl_http.end_of_body then
      utl_http.end_response(l_resp);
  end;

  dbms_output.put_line('Size='||length(l_content));

  dbms_lob.freetemporary(l_content);
end;
/




Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Very Useful

Shripad, January 22, 2020 - 9:41 am UTC

This was very useful. We can get the response in chunks.
Could not find this in any documentation.

This saved my life :)

Gnanam, February 18, 2021 - 1:36 pm UTC

its very helpful
Chris Saxon
February 18, 2021 - 6:03 pm UTC

Great to hear :)

More to Explore

PL/SQL

Check out more PL/SQL tutorials on our LiveSQL tool.