32 #ifndef QORE_HTTP_CLIENT_OBJECT_INTERN_H_
33 #define QORE_HTTP_CLIENT_OBJECT_INTERN_H_
39 #define make_protocol(a, b) ((a) * ((b) ? -1 : 1))
40 #define get_port(a) ((a) * (((a) < 0) ? -1 : 1))
41 #define get_ssl(a) (((a) < 0) ? true : false)
44 typedef std::map<std::string, int> prot_map_t;
45 typedef std::map<std::string, bool, ltstrcase> method_map_t;
46 typedef std::set<std::string, ltstrcase> strcase_set_t;
47 typedef std::map<std::string, std::string> header_map_t;
59 DLLLOCAL con_info(
int n_port = 0) : port(n_port) {
62 DLLLOCAL
bool has_url()
const {
76 if (!url.
getPort() && !host.empty()) {
78 int val = strtol(host.c_str(), &aux, 10);
79 if (aux == (host.c_str() + host.size())) {
80 host = HTTPCLIENT_DEFAULT_HOST;
93 if (username.empty() && !password.empty()) {
94 xsink->
raiseException(
"HTTP-CLIENT-URL-ERROR",
"invalid authorization credentials: password set without "
99 if (!username.empty() && password.empty()) {
100 xsink->
raiseException(
"HTTP-CLIENT-URL-ERROR",
"invalid authorization credentials: username set without "
105 if (!port && !host.empty() && host[0] ==
'/') {
114 unix_urlencoded_path = tmp_path.
c_str();
120 DLLLOCAL
QoreStringNode* get_url(
bool suppress_password =
false)
const {
127 if (!username.empty()) {
128 if (suppress_password) {
129 pstr->
sprintf(
"%s@", username.c_str());
131 pstr->
sprintf(
"%s:%s@", username.c_str(), password.c_str());
138 for (
unsigned i = 0; i < host.size(); ++i) {
141 case ' ': pstr->
concat(
"%20");
break;
142 case '/': pstr->
concat(
"%2f");
break;
143 default: pstr->
concat(c);
break;
147 pstr->
concat(host.c_str());
149 if (port && port != 80) {
155 pstr->
concat(path.c_str());
160 DLLLOCAL
void setUserPassword(
const char *user,
const char *pass) {
161 assert(user && pass);
166 DLLLOCAL
void clearUserPassword() {
171 DLLLOCAL
void clear() {
177 unix_urlencoded_path.clear();
183 DLLLOCAL
extern method_map_t method_map;
184 DLLLOCAL
extern strcase_set_t header_ignore;
187 DLLLOCAL
void do_event(Queue *event_queue,
int64 id,
int event);
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 string encoding functions in Qore
Definition: QoreEncoding.h:83
This is the hash or associative list container type in Qore, dynamically allocated only,...
Definition: QoreHashNode.h:50
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:93
DLLEXPORT void concat(const QoreString *str, ExceptionSink *xsink)
concatenates a string and converts encodings if necessary
DLLEXPORT int sprintf(const char *fmt,...)
this will concatentate a formatted string to the existing string according to the format string and t...
DLLEXPORT int concatEncodeUrl(ExceptionSink *xsink, const QoreString &url, bool encode_all=false)
concatenates a URL-encoded version of the c-string passed
DLLEXPORT const char * c_str() const
returns the string's buffer; this data should not be changed
DLLEXPORT const char * getBuffer() 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
helps with parsing URLs and provides access to URL components through Qore data structures
Definition: QoreURL.h:44
DLLEXPORT const QoreString * getPassword() const
returns the password in the URL or 0 if none given
DLLEXPORT const QoreString * getHost() const
returns the hostname of the URL
DLLEXPORT const QoreString * getPath() const
returns the path component of the URL or 0 if none given
DLLEXPORT const QoreString * getUserName() const
returns the user name in the URL or 0 if none given
DLLEXPORT int getPort() const
returns the port number given in the URL or 0 if none present
long long int64
64bit integer type, cannot use int64_t here since it breaks the API on some 64-bit systems due to equ...
Definition: common.h:260