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)
44typedef std::map<std::string, int> prot_map_t;
45typedef std::map<std::string, bool, ltstrcase> method_map_t;
46typedef std::set<std::string, ltstrcase> strcase_set_t;
47typedef 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 mask_password =
false)
const {
127 bool has_username_or_password =
false;
128 if (!username.empty()) {
130 has_username_or_password =
true;
132 if (!password.empty()) {
139 if (!has_username_or_password) {
140 has_username_or_password =
true;
143 if (has_username_or_password) {
150 for (
unsigned i = 0; i < host.size(); ++i) {
153 case ' ': pstr->
concat(
"%20");
break;
154 case '/': pstr->
concat(
"%2f");
break;
155 default: pstr->
concat(c);
break;
159 pstr->
concat(host.c_str());
161 if (port && ((!ssl && port != 80) || (ssl && port != 443))) {
167 pstr->
concat(path.c_str());
172 DLLLOCAL
void setUserPassword(
const char *user,
const char *pass) {
173 assert(user && pass);
178 DLLLOCAL
void clearUserPassword() {
183 DLLLOCAL
void clear() {
189 unix_urlencoded_path.clear();
195DLLLOCAL
extern method_map_t method_map;
196DLLLOCAL
extern strcase_set_t header_ignore;
199DLLLOCAL
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:50
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 const char * c_str() const
returns the string's buffer; this data should not be changed
DLLEXPORT void concat(const QoreString *str, ExceptionSink *xsink)
concatenates a string and converts encodings if necessary
DLLEXPORT const char * getBuffer() const
returns the string's buffer; this data should not be changed
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
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 * 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
DLLEXPORT const QoreString * getPassword() const
returns the password in the URL or 0 if none given
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