src/include/posix/http/CurlTransportAgent.h

00001 /*
00002  * Copyright (C) 2003-2007 Funambol
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  */
00018 
00019 #ifndef INCL_CURL_TRANSPORT_AGENT
00020     #define INCL_CURL_TRANSPORT_AGENT
00021 
00023     #include "base/fscapi.h"
00024 
00025     #include "http/URL.h"
00026     #include "http/Proxy.h"
00027     #include "http/TransportAgent.h"
00028 
00029     #include "curl/curl.h"
00030 
00031     /*
00032      * This class is the transport agent responsible for messages exchange
00033      * over an HTTP connection. It uses libcurl.
00034      */
00035 
00036     class CurlTransportAgent : public TransportAgent {
00037         CURL *easyhandle;
00038         char proxyauth[DIM_USERNAME + 1 + DIM_PASSWORD];
00039 
00040         char *sendbuffer;
00041         size_t sent, sendbuffersize;
00042         static size_t sendData(void *ptr, size_t size, size_t nmemb, void *stream);
00043 
00044         char *responsebuffer;
00045         size_t received, responsebuffersize;
00046         static size_t receiveData(void *buffer, size_t size, size_t nmemb, void *stream);
00047 
00048         char curlerrortxt[CURL_ERROR_SIZE];
00049         
00050         static int debugCallback(CURL *easyhandle, curl_infotype type, char *data, size_t size, void *unused);
00051 
00052     public:
00053         CurlTransportAgent();
00054         CurlTransportAgent(URL& url, Proxy& proxy, unsigned int responseTimeout = DEFAULT_MAX_TIMEOUT);
00055         ~CurlTransportAgent();
00056 
00057         char* sendMessage(const char* msg);
00058         void setUserAgent(const char* ua);
00059 
00060     };
00061 
00063 #endif

Generated on Fri Apr 27 12:29:19 2007 for Funambol C++ Client Library by  doxygen 1.5.2