All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
QoreHTTPClient.h
/* -*- mode: c++; indent-tabs-mode: nil -*- */
/*
QoreHTTPClient.h
Qore Programming Language
Copyright (C) 2006 - 2013 QoreTechnologies
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef QORE_HTTP_CLIENT_H_
#define QORE_HTTP_CLIENT_H_
#include <qore/common.h>
#include <qore/AbstractPrivateData.h>
#include <qore/QoreThreadLock.h>
#include <qore/QoreSocket.h>
#define HTTPCLIENT_DEFAULT_PORT 80
#define HTTPCLIENT_DEFAULT_HOST "localhost"
#define HTTPCLIENT_DEFAULT_TIMEOUT 300000
#define HTTPCLIENT_DEFAULT_MAX_REDIRECTS 5
class Queue;
class QoreHTTPClient : public AbstractPrivateData {
private:
struct qore_qtc_private *priv;
DLLLOCAL QoreHTTPClient(const QoreHTTPClient&);
DLLLOCAL QoreHTTPClient& operator=(const QoreHTTPClient&);
protected:
DLLEXPORT void lock();
DLLEXPORT void unlock();
public:
DLLEXPORT QoreHTTPClient();
DLLEXPORT virtual ~QoreHTTPClient();
DLLEXPORT int setOptions(const QoreHashNode *opts, ExceptionSink* xsink);
DLLEXPORT void setDefaultPort(int prt);
DLLEXPORT void setDefaultPath(const char *pth);
DLLEXPORT void addProtocol(const char *prot, int port, bool ssl = false);
DLLEXPORT void setTimeout(int to);
DLLEXPORT int getTimeout() const;
DLLEXPORT void setEncoding(const QoreEncoding *qe);
DLLEXPORT const QoreEncoding *getEncoding() const;
DLLEXPORT int setHTTPVersion(const char* version, ExceptionSink* xsink);
DLLEXPORT const char* getHTTPVersion() const;
DLLEXPORT void setHTTP11(bool h11);
DLLEXPORT bool isHTTP11() const;
DLLEXPORT int setURL(const char *url, ExceptionSink *xsink);
DLLEXPORT QoreStringNode *getURL();
DLLEXPORT void setUserPassword(const char *user, const char *pass);
DLLEXPORT void clearUserPassword();
DLLEXPORT int setProxyURL(const char *proxy, ExceptionSink *xsink);
DLLEXPORT QoreStringNode *getProxyURL();
DLLEXPORT void clearProxyURL();
DLLEXPORT void setProxyUserPassword(const char *user, const char *pass);
DLLEXPORT void clearProxyUserPassword();
DLLEXPORT void setSecure(bool is_secure);
DLLEXPORT bool isSecure() const;
DLLEXPORT void setProxySecure(bool is_secure);
DLLEXPORT bool isProxySecure() const;
DLLEXPORT void setMaxRedirects(int max);
DLLEXPORT int getMaxRedirects() const;
DLLEXPORT long verifyPeerCertificate();
DLLEXPORT const char *getSSLCipherName();
DLLEXPORT const char *getSSLCipherVersion();
DLLEXPORT int connect(ExceptionSink *xsink);
DLLEXPORT void disconnect();
DLLEXPORT QoreHashNode *send(const char *meth, const char *path, const QoreHashNode *headers, const void *data, unsigned size, bool getbody, QoreHashNode *info, ExceptionSink *xsink);
DLLEXPORT AbstractQoreNode *get(const char *path, const QoreHashNode *headers, QoreHashNode *info, ExceptionSink *xsink);
DLLEXPORT QoreHashNode *head(const char *path, const QoreHashNode *headers, QoreHashNode *info, ExceptionSink *xsink);
DLLEXPORT AbstractQoreNode *post(const char *path, const QoreHashNode *headers, const void *data, unsigned size, QoreHashNode *info, ExceptionSink *xsink);
DLLEXPORT void setDefaultHeaderValue(const char *header, const char *val);
using AbstractPrivateData::deref;
DLLEXPORT virtual void deref(ExceptionSink *xsink);
DLLEXPORT void setConnectTimeout(int ms);
DLLEXPORT int getConnectTimeout() const;
DLLEXPORT int setNoDelay(bool nodelay);
DLLEXPORT void setEventQueue(Queue *cbq, ExceptionSink *xsink);
DLLEXPORT bool getNoDelay() const;
DLLEXPORT bool isConnected() const;
DLLEXPORT QoreHashNode* getPeerInfo(ExceptionSink* xsink) const;
DLLEXPORT QoreHashNode* getSocketInfo(ExceptionSink* xsink) const;
DLLLOCAL static void static_init();
DLLLOCAL void cleanup(ExceptionSink *xsink);
};
#endif