create or replace function Get_Http_Request (
p_url in varchar2, p_user in varchar2, p_password in varchar2 )
return varchar2
is
v_req Utl_Http.req;
v_resp Utl_Http.resp;
v_name varchar2(255);
v_value varchar2(1023);
v_buffer varchar2(80);
v_msg varchar2(32767);
begin
Utl_Http.Set_Response_Error_Check ( enable => true );
Utl_Http.Set_Proxy (
proxy => 'www-proxy.us.oracle.com',
no_proxy_domains => 'us.oracle.com' );
v_req := Utl_Http.Begin_Request (
url => p_url,
method => 'GET' );
Utl_Http.Set_Authentication (
r => v_req,
username => p_user,
password => p_password,
scheme => 'Basic',
for_proxy => false /* this info is for the target web server */ );
Utl_Http.Set_Header (
r => v_req,
name => 'User-Agent',
value => 'Mozilla/4.0' );
v_resp := Utl_Http.Get_Response ( r => v_req );
for i in 1..Utl_Http.Get_Header_Count ( r => v_resp )
loop
Utl_Http.Get_Header (
r => v_resp,
n => i,
name => v_name,
value => v_value );
if lower(v_name) = 'content-type'
then
if Instr( Lower(v_value), 'text/xml' ) < 1
then raise_application_error ( -20997,
'Get_Http_Request: unexpected Content-Type: ' || v_value ); end if;
end if;
end loop;
begin
loop
Utl_Http.Read_Text (
r => v_resp,
data => v_buffer );
v_msg := v_msg || v_buffer;
end loop;
exception when Utl_Http.End_Of_Body then null;
end;
Utl_Http.End_Response ( r => v_resp );
return v_msg;
end Get_Http_Request;
/