-- http.sql

SET SERVEROUTPUT ON

DECLARE
    line      VARCHAR2(2048);
    request   UTL_HTTP.req;
    response  UTL_HTTP.resp;
BEGIN
    request := UTL_HTTP.BEGIN_REQUEST('http://www.example.com');
    UTL_HTTP.SET_HEADER(request, 'User-Agent', 'Mozilla/4.0');
    response := UTL_HTTP.GET_RESPONSE(request);
    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;
/
