00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef INCL_TRANSPORT_AGENT
00037 #define INCL_TRANSPORT_AGENT
00038
00040 #include "base/fscapi.h"
00041 #include "base/util/StringBuffer.h"
00042
00043 #include "http/URL.h"
00044 #include "http/Proxy.h"
00045
00046
00047
00048
00049 #define DEFAULT_MAX_TIMEOUT 300
00050
00051
00052
00053
00054
00055 #define DEFAULT_MAX_MSG_SIZE 512000
00056
00057
00058
00059
00060
00061 #define DEFAULT_INTERNET_READ_BUFFER_SIZE 4096
00062 #include "base/globalsdef.h"
00063
00064 #include "base/util/StringMap.h"
00065
00066 BEGIN_NAMESPACE
00067
00068
00069 #define TA_PropertyAcceptEncoding "Accept-Encoding"
00070 #define TA_PropertyContentType "Content-Type"
00071 #define TA_PropertyContentLength "Content-Length"
00072 #define TA_PropertyUncompressedContentLength "Uncompressed-Content-Length"
00073 #define TA_PropertyUserAgent "User-Agent"
00074 #define TA_PropertyContentEncoding "Content-Encoding"
00075
00076
00077
00078
00079
00080
00081 class TransportAgent {
00082
00083 protected:
00084 URL url;
00085 Proxy proxy;
00086
00087 unsigned int timeout;
00088 unsigned int maxmsgsize;
00089 unsigned int readBufferSize;
00090 StringBuffer userAgent;
00091 bool compression;
00092
00093
00094 StringBuffer SSLServerCertificates;
00095 bool SSLVerifyServer;
00096 bool SSLVerifyHost;
00097
00098 unsigned int responseSize;
00099
00100 StringMap requestProperties;
00101 StringMap responseProperties;
00102 int responseCode;
00103
00104 public:
00105 TransportAgent();
00106 TransportAgent(const URL& url,
00107 Proxy& proxy,
00108 unsigned int responseTimeout = DEFAULT_MAX_TIMEOUT,
00109 unsigned int maxmsgsize = DEFAULT_MAX_MSG_SIZE);
00110
00111 virtual ~TransportAgent();
00112
00113
00114
00115
00116
00117
00118
00119 virtual void setURL(const URL& newURL);
00120
00121
00122
00123
00124 virtual URL& getURL();
00125
00131 virtual void setTimeout(unsigned int t);
00132
00136 virtual unsigned int getTimeout();
00137
00143 virtual void setMaxMsgSize(unsigned int t);
00144
00148 virtual unsigned int getMaxMsgSize();
00149
00155 virtual void setReadBufferSize(unsigned int t);
00156
00157 virtual void setUserAgent(const char* ua);
00158
00159 virtual void setCompression(bool newCompression);
00160 virtual bool getCompression();
00161
00162 virtual const char* getUserAgent();
00163
00169 void setResponseMime(const char *mime);
00170
00176 const char* getResponseMime();
00177
00183 const char* getResponseProperty(const char *pname);
00184
00188 unsigned int getResponseSize();
00189
00193 void setResponseCode(int respCode);
00194
00198 int getResponseCode();
00199
00203 virtual unsigned int getReadBufferSize();
00204
00210 virtual const char* getSSLServerCertificates() const {
00211 return SSLServerCertificates.c_str();
00212 }
00213 virtual void setSSLServerCertificates(const char *value) {
00214 SSLServerCertificates = value ? value : "";
00215 }
00216
00224 virtual bool getSSLVerifyServer() const { return SSLVerifyServer; }
00225 virtual void setSSLVerifyServer(bool value) { SSLVerifyServer = value; }
00226
00234 virtual bool getSSLVerifyHost() const { return SSLVerifyHost; }
00235 virtual void setSSLVerifyHost(bool value) { SSLVerifyHost = value; }
00236
00244 virtual char* sendMessage(const char* msg) = 0;
00245
00251 virtual char* sendMessage(const char* data, const unsigned int size) = 0;
00252
00256 virtual void setProperty(const char *propName, const char * const propValue);
00257
00261 virtual char* query(ArrayList& httpHeaders, long* protocolResponseCode);
00262
00263 };
00264
00265
00266 END_NAMESPACE
00267
00269 #endif