Skip to content

Instantly share code, notes, and snippets.

@hackvan
Last active March 31, 2020 22:16
Show Gist options
  • Save hackvan/ff61f9e4e0461bf09739 to your computer and use it in GitHub Desktop.
Save hackvan/ff61f9e4e0461bf09739 to your computer and use it in GitHub Desktop.
PL/SQL Oracle: Ejemplo para realizar una solicitud de una página HTML.
create or replace procedure getInfoHTTP(pHost Varchar2
,pPort Varchar2
,pUrl Varchar2) is
req utl_http.req;
res utl_http.resp;
vResult CLOB;
begin
utl_http.set_transfer_timeout(30);
dbms_output.put_line('Request> URL: ' ||pUrl);
req := utl_http.begin_request(pUrl, 'GET', 'HTTP/1.1');
utl_http.set_header(req, 'user-agent', 'Mozilla/4.0');
utl_http.set_header(req, 'content-type', 'text/html;charset=UTF-8');
utl_http.set_header(req, 'host', pHost || ':' || pPort);
res := utl_http.get_response(req);
dbms_output.put_line('Response> status_code: "' ||res.status_code || '"');
dbms_output.put_line('Response> reason_phrase: "' ||res.reason_phrase || '"');
dbms_output.put_line('Response> http_version: "' ||res.http_version || '"');
Begin
Loop
utl_http.read_line(res, vResult);
dbms_output.put_line(vResult);
End Loop;
utl_http.end_response(res);
Exception
When utl_http.end_of_body Then
utl_http.end_response(res);
End;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment