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 __HTTP_CONNECTION_HANDLER_H__
00037 #define __HTTP_CONNECTION_HANDLER_H__
00038
00039 #include "base/fscapi.h"
00040
00041 #if defined(FUN_IPHONE)
00042 #include <SystemConfiguration/SystemConfiguration.h>
00043 #include <SystemConfiguration/SCNetworkReachability.h>
00044 #include <CFNetwork/CFNetwork.h>
00045 #else
00046 #include <CoreServices/CoreServices.h>
00047 #endif
00048
00049 #include "http/URL.h"
00050 #include "http/Proxy.h"
00051 #include "http/TransportAgent.h"
00052 #include "base/Log.h"
00053 #include "http/HttpAuthentication.h"
00054 #include "inputStream/OutputStream.h"
00055
00056 BEGIN_FUNAMBOL_NAMESPACE
00057
00058 struct StreamDataHandle
00059 {
00060 CFReadStreamRef responseStream;
00061 OutputStream* os;
00062 pthread_t threadId;
00063 StringBuffer responseBuffer;
00064 bool stopStreamReading;
00065 int requestSize;
00066 bool streamConnected;
00067 int chunkSize;
00068 };
00069
00070 typedef enum {
00071 E_SUCCESS = 0,
00072 E_THREAD_CREATE,
00073 E_THREAD_JOIN,
00074 E_ALREADY_RUNNING
00075 } connection_handler_err_t;
00076
00077 class HttpConnectionHandler
00078 {
00079 public:
00080 HttpConnectionHandler();
00081 ~HttpConnectionHandler();
00082
00083 int startConnectionHandler(CFReadStreamRef stream, int requestSize);
00084 int startConnectionHandler(CFReadStreamRef stream, OutputStream& os, int chunkSize);
00085
00086 const char* getRequestReponse() const;
00087
00088 private:
00089 bool readerThreadRunning;
00090 StreamDataHandle* handle;
00091 };
00092
00093 END_FUNAMBOL_NAMESPACE
00094
00095 #endif
00096