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 username");
98 if (!username.empty() && password.empty()) {
99 xsink->
raiseException(
"HTTP-CLIENT-URL-ERROR",
"invalid authorization credentials: username set without password");
103 if (!port && !host.empty() && host[0] ==
'/') {
112 unix_urlencoded_path = tmp_path.
c_str();
124 if (!username.empty())
125 pstr->
sprintf(
"%s:%s@", username.c_str(), password.c_str());
130 for (
unsigned i = 0; i < host.size(); ++i) {
133 case ' ': pstr->
concat(
"%20");
break;
134 case '/': pstr->
concat(
"%2f");
break;
135 default: pstr->
concat(c);
break;
140 pstr->
concat(host.c_str());
141 if (port && port != 80)
146 pstr->
concat(path.c_str());
151 DLLLOCAL
void setUserPassword(
const char *user,
const char *pass) {
152 assert(user && pass);
157 DLLLOCAL
void clearUserPassword() {
162 DLLLOCAL
void clear() {
168 unix_urlencoded_path.clear();
174 DLLLOCAL
extern method_map_t method_map;
175 DLLLOCAL
extern strcase_set_t header_ignore;
177 DLLLOCAL
void do_content_length_event(Queue *event_queue,
int64 id,
int len);
179 DLLLOCAL
void do_event(Queue *event_queue,
int64 id,
int event);
DLLEXPORT const char * c_str() const
returns the string's buffer; this data should not be changed
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
DLLEXPORT int sprintf(const char *fmt,...)
this will concatentate a formatted string to the existing string according to the format string and t...
helps with parsing URLs and provides access to URL components through Qore data structures ...
Definition: QoreURL.h:39
DLLEXPORT AbstractQoreNode * raiseException(const char *err, const char *fmt,...)
appends a Qore-language exception to the list
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:81
Qore's string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:50
DLLEXPORT const char * getBuffer() 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
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:46
DLLEXPORT const QoreString * getPassword() const
returns the password in the URL or 0 if none given
DLLEXPORT int concatEncodeUrl(ExceptionSink *xsink, const QoreString &url, bool encode_all=false)
concatenates a URL-encoded version of the c-string passed
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
DLLEXPORT const QoreString * getHost() const
returns the hostname of the URL
DLLEXPORT const QoreString * getUserName() const
returns the user name in the URL or 0 if none given
DLLEXPORT const QoreString * getPath() const
returns the path component of the URL or 0 if none given
DLLEXPORT int getPort() const
returns the port number given in the URL or 0 if none present