32 #ifndef _QORE_CLASS_HTTPCLIENTPOLLOPERATION_H
34 #define _QORE_CLASS_HTTPCLIENTPOLLOPERATION_H
36 #include "qore/intern/QC_AbstractPollOperation.h"
37 #include "qore/QoreHttpClientObject.h"
40 constexpr
int HCPG_CONNECT = 1;
43 constexpr
int HCPS_NONE = 0;
45 constexpr
int SPS_CONNECTING = 1;
46 constexpr
int SPS_CONNECTING_SSL = 2;
47 constexpr
int SPS_CONNECTED = 3;
49 class HTTPClientPollOperation :
public AbstractPollOperation {
53 if (*goal ==
"connect") {
56 state = SPS_CONNECTING;
58 xsink->
raiseException(
"INVALID-GOAL",
"invalid goal \"%s\"; known goal: \"connect\"", goal->
c_str());
63 if (ROdereference()) {
69 DLLLOCAL
virtual bool goalReached()
const {
70 return state == SPS_CONNECTED;
77 case SPS_CONNECTING: {
78 int rc = checkContinuePoll(xsink);
80 rv = *xsink ? nullptr : getHTTPClientPollInfoHash(xsink, rc);
85 if (sgoal == SPG_CONNECT) {
86 state = SPS_CONNECTED;
90 assert(sgoal == SPG_CONNECT_SSL);
91 state = SPS_CONNECTING_SSL;
93 poll_state.reset(client->startSslConnect(xsink, client->priv->cert ? client->priv->cert->getData() :
nullptr,
94 client->priv->pk ? client->priv->pk->getData() :
nullptr));
103 case SPS_CONNECTING_SSL: {
104 int rc = checkContinuePoll(xsink);
106 rv = *xsink ? nullptr : getHTTPClientPollInfoHash(xsink, rc);
110 state = SPS_CONNECTED;
122 state = SPS_CONNECTED;
129 unique_ptr<AbstractPollState> poll_state;
133 int state = SPS_NONE;
135 DLLLOCAL
virtual const char* getStateImpl()
const {
142 case SPS_CONNECTING_SSL:
143 return "connecting-ssl";
153 assert(poll_state.get());
156 int rc = poll_state->continuePoll(xsink);
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
DLLEXPORT AbstractQoreNode * raiseException(const char *err, const char *fmt,...)
appends a Qore-language exception to the list
defines a Qore-language class
Definition: QoreClass.h:249
This is the hash or associative list container type in Qore, dynamically allocated only,...
Definition: QoreHashNode.h:50
provides a way to communicate with HTTP servers using Qore data structures
Definition: QoreHttpClientObject.h:51
virtual DLLEXPORT void deref(ExceptionSink *xsink)
decrements the reference count and deletes the object when it reaches 0
contains constants, classes, and subnamespaces in QoreProgram objects
Definition: QoreNamespace.h:65
the implementation of Qore's object data type, reference counted, dynamically-allocated only
Definition: QoreObject.h:60
DLLEXPORT const char * c_str() const
returns the string's buffer; this data should not be changed
Qore's string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:50