web_client.H

00001 /*
00002  * This file is part of the "Archon" framework.
00003  * (http://files3d.sourceforge.net)
00004  *
00005  * Copyright © 2002 by Kristian Spangsege and Brian Kristiansen.
00006  *
00007  * Permission to use, copy, modify, and distribute this software and
00008  * its documentation under the terms of the GNU General Public License is
00009  * hereby granted. No representations are made about the suitability of
00010  * this software for any purpose. It is provided "as is" without express
00011  * or implied warranty. See the GNU General Public License
00012  * (http://www.gnu.org/copyleft/gpl.html) for more details.
00013  *
00014  * The characters in this file are ISO8859-1 encoded.
00015  *
00016  * The documentation in this file is in "Doxygen" style
00017  * (http://www.doxygen.org).
00018  */
00019 
00020 #ifndef ARCHON_UTILITIES_WEB_CLIENT_H
00021 #define ARCHON_UTILITIES_WEB_CLIENT_H
00022 
00023 #include <string>
00024 #include <vector>
00025 
00026 #include <archon/util/exception.H>
00027 #include <archon/util/ref.H>
00028 #include <archon/util/stream.H>
00029 #include <archon/util/uri.H>
00030 
00031 namespace Archon
00032 {
00033   namespace Utilities
00034   {
00038     namespace Web
00039     {
00040       using namespace std;
00041 
00042       struct RequestException: virtual Exception
00043       {
00044         RequestException(string l, string m): Exception(l, m) {}
00045       };
00046 
00047       struct Client: RefObjectBase
00048       {
00053         static Ref<Client> get(string applicationName,
00054                                string applicationVersion,
00055                                int maxSockets = 32)
00056           throw(UnexpectedException);
00057 
00067         static Ref<Client> get(string applicationName,
00068                                string applicationVersion,
00069                                string cacheRootPath, long cacheSize,
00070                                int maxSockets = 32)
00071           throw(UnexpectedException);
00072 
00073 
00074         struct Request: RefObjectBase
00075         {
00076           static Ref<Request> get(const Uri &);
00077 
00078           const Uri &getUri() { return uri; }
00079 
00080         protected:
00081           Request(const Uri &uri): uri(uri) {}
00082 
00083           Uri uri;
00084         };
00085 
00086         struct Response: virtual Stream::ReaderBase<char>
00087         {
00088           virtual string getContentType() = 0;
00089 
00090         protected:
00091           Response() {}
00092         };
00093 
00094         virtual Ref<Response> request(Ref<Request>) throw(RequestException) = 0;
00095 
00096       protected:
00097         Client() {}
00098       };
00099     }
00100   }
00101 }
00102 
00103 #endif // ARCHON_UTILITIES_WEB_CLIENT_H

Generated on Sun Jul 30 22:55:46 2006 for Archon by  doxygen 1.4.4