<?php
/*
 * test_http_image_request.php
 *
 * @(#) $Header: /opt2/ena/metal/http/test_http_image_request.php,v 1.5 2015/05/26 09:04:17 mlemos Exp $
 *
 */

	require("http.php");

	set_time_limit(0);
	$http=new http_class;
	$url="http://www.phpclasses.org/graphics/logo.gif";
	$error=$http->GetRequestArguments($url,$arguments);
	$error=$http->Open($arguments);
	if($error=="")
	{
		$error=$http->SendRequest($arguments);
		if($error=="")
		{
			$headers=array();
			$error=$http->ReadReplyHeaders($headers);
			if($error=="")
			{
				for(Reset($headers),$header=0;$header<count($headers);Next($headers),$header++)
				{
					$header_name=Key($headers);
					if(GetType($headers[$header_name])!="array")
					{
						switch(strtolower($header_name))
						{
							case "content-type":
							case "content-length":
								Header($header_name.": ".$headers[$header_name]);
								break;
						}
					}
				}
				for(;;)
				{
					$error=$http->ReadReplyBody($body,1000);
					if($error!=""
					|| strlen($body)==0)
						break;
					echo $body;
				}
			}
		}
		$http->Close();
	}
	if($error!="")
	{
?>
<HTML>
<HEAD>
<TITLE>Error</TITLE>
</HEAD>
<BODY>
<H1><CENTER>Could not retrieve the resource. Error: <?php echo $error; ?></CENTER><H1>
<HR>
</BODY>
</HTML>
<?php
	}
?>