-- w3c.sql

SET SERVEROUTPUT ON

DECLARE
  line VARCHAR2(2048);
  request UTL_HTTP.req;
  response UTL_HTTP.resp;
BEGIN
  request := UTL_HTTP.BEGIN_REQUEST('http://www.w3c.org');
  UTL_HTTP.SET_HEADER(request, 'User-Agent', 'Mozilla/4.0');
  response := UTL_HTTP.GET_RESPONSE(request);
  FOR x in 1 .. 10 LOOP
    UTL_HTTP.READ_LINE(response, line, TRUE);
    dbms_output.put_line(substr(line,1,255));
  END LOOP;
  UTL_HTTP.END_RESPONSE(response);
EXCEPTION
  WHEN UTL_HTTP.END_OF_BODY THEN
    UTL_HTTP.END_RESPONSE(response);
END;
/
