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_MAC_TRANSPORT_AGENT
00037 #define INCL_MAC_TRANSPORT_AGENT
00038
00040 #include "base/fscapi.h"
00041
00042 #if defined(FUN_IPHONE)
00043 #include <SystemConfiguration/SystemConfiguration.h>
00044 #include <SystemConfiguration/SCNetworkReachability.h>
00045 #include <CFNetwork/CFNetwork.h>
00046 #else
00047 #include <CoreServices/CoreServices.h>
00048 #endif
00049
00050 #include "http/URL.h"
00051 #include "http/Proxy.h"
00052 #include "http/TransportAgent.h"
00053 #include "base/Log.h"
00054 #include "http/HttpAuthentication.h"
00055
00056 #define ERR_HTTP_TIME_OUT ERR_TRANSPORT_BASE+ 7
00057 #define ERR_HTTP_NOT_FOUND ERR_TRANSPORT_BASE+60
00058 #define ERR_HTTP_REQUEST_TIMEOUT ERR_TRANSPORT_BASE+61
00059 #define ERR_HTTP_INFLATE ERR_TRANSPORT_BASE+70
00060 #define ERR_HTTP_DEFLATE ERR_TRANSPORT_BASE+71
00061
00062
00063
00065 #define MAX_RETRIES 3 // Max number of attempts sending http requests.
00066
00067
00068 BEGIN_NAMESPACE
00069
00070 class MacTransportAgent : public TransportAgent {
00071 private:
00072 HttpAuthentication *auth;
00073 bool addHttpAuthentication(CFHTTPMessageRef* request);
00074
00075 public:
00076 MacTransportAgent();
00077 MacTransportAgent(const URL& url, Proxy& proxy, unsigned int responseTimeout = DEFAULT_MAX_TIMEOUT);
00078 ~MacTransportAgent();
00079
00080 char* sendMessage(const char* msg);
00081 char* sendMessage(const char* msg, const unsigned int length);
00082 private:
00083 char* sendBuffer(const void * data, const unsigned int size);
00084 void setAuthentication(HttpAuthentication *httpAuth);
00085 };
00086
00087 END_NAMESPACE
00088
00090 #endif
00091