00001 #include <unistd.h> 00002 #include <string> 00003 #include <iostream> 00004 00005 #include <archon/util/exception.H> 00006 #include <archon/util/web_client.H> 00007 00008 using namespace std; 00009 using namespace Archon::Utilities; 00010 00011 int main() throw() 00012 { 00013 set_unexpected(Exception::terminal<exceptionCatchInfo>); 00014 set_terminate (Exception::terminal<exceptionCatchInfo>); 00015 00016 Ref<Web::Client> client = Web::Client::get("foo", "bar"); 00017 00018 Ref<Web::Client::Response> response1 = client->request(Web::Client::Request::get(Uri("http://freestyle2.nike.com"))); 00019 00020 /* 00021 Ref<Web::Client::Response> response2 = client->request(Web::Client::Request::get(Uri("http://www.dkvet.dk/ordboeger/dansk-eng%20ordbog.htm"))); 00022 Ref<Web::Client::Response> response3 = client->request(Web::Client::Request::get(Uri("http://www.oracle.com"))); 00023 Ref<Web::Client::Response> response4 = client->request(Web::Client::Request::get(Uri("http://freestyle.nike.com"))); 00024 Ref<Web::Client::Response> response5 = client->request(Web::Client::Request::get(Uri("http://www.sun.com"))); 00025 Ref<Web::Client::Response> response6 = client->request(Web::Client::Request::get(Uri("http://www.oracle.com"))); 00026 */ 00027 00028 /* 00029 cerr << "Content-Type: " << response1->getContentType() << "\n"; 00030 cerr << "Content-Type: " << response2->getContentType() << "\n"; 00031 cerr << "Content-Type: " << response3->getContentType() << "\n"; 00032 cerr << "Content-Type: " << response4->getContentType() << "\n"; 00033 cerr << "Content-Type: " << response5->getContentType() << "\n"; 00034 cerr << "Content-Type: " << response6->getContentType() << "\n"; 00035 */ 00036 00037 for(;;) 00038 { 00039 char b[1024]; 00040 int n = response1->read(b, 1024); 00041 if(!n) break; 00042 write(STDOUT_FILENO, b, n); 00043 } 00044 00045 return 0; 00046 }