73 #define MAX_THREADS 1024 74 #define MAX_IN_QUEUE 128 94 info(0,
"Starting fetch %ld", i);
95 id = gw_malloc(
sizeof(
long));
104 debug(
"", 0,
"Started request %ld.", *
id);
129 if (
id == NULL || ret == -1) {
130 error(0,
"http POST failed");
134 debug(
"", 0,
"Done with request %ld", *(
long *)
id);
156 debug(
"", 0,
"Parsed xmlrpc");
168 debug(
"xr", 0,
"Got fault response with code:%ld and description: %s",
191 long i, succeeded, failed;
229 while (in_queue > 0) {
238 info(0,
"This thread: %ld succeeded, %ld failed.", succeeded, failed);
244 info(0,
"Usage: test_xmlrpc [options] xml_source");
245 info(0,
"where options are:");
247 info(0,
" send XML-RPC source as POST HTTP request to URL");
248 info(0,
"-v number");
249 info(0,
" set log level for stderr logging");
251 info(0,
" don't print the body or headers of the HTTP response");
252 info(0,
"-r number");
253 info(0,
" make `number' requests, repeating URLs as necessary");
254 info(0,
"-p domain.name");
255 info(0,
" use `domain.name' as a proxy");
256 info(0,
"-P portnumber");
257 info(0,
" connect to proxy at port `portnumber'");
259 info(0,
" use HTTPS scheme to access SSL-enabled proxy server");
260 info(0,
"-e domain1:domain2:...");
261 info(0,
" set exception list for proxy use");
263 info(0,
" use HTTPS scheme to access SSL-enabled HTTP server");
264 info(0,
"-c ssl_client_cert_key_file");
265 info(0,
" use this file as the SSL certificate and key file");
269 int main(
int argc,
char **argv)
271 int i, opt, num_threads;
293 exceptions_regex = NULL;
297 while ((opt =
getopt(argc, argv,
"hvr:t:p:u:P:Se:a:sc:")) != EOF) {
313 num_threads = atoi(
optarg);
338 p = strtok(NULL,
":");
350 p = strtok(NULL,
"");
367 error(0,
"Invalid option %c", opt);
369 panic(0,
"Stopping");
375 error(0,
"Missing arguments");
377 panic(0,
"Stopping");
389 panic(0,
"client certkey file need to be given!");
409 panic(0,
"Cannot read the XML document");
429 if (num_threads == 0)
432 for (i = 0; i < num_threads; ++i)
434 for (i = 0; i < num_threads; ++i)
440 run_time = difftime(end,
start);
441 info(0,
"%ld requests in %f seconds, %f requests/s.",
448 if (output != NULL) {
void error(int err, const char *fmt,...)
void info(int err, const char *fmt,...)
static int receive_reply(HTTPCaller *caller)
#define xmlrpc_send_call(call, http_ref, url, headers, ref)
int xmlrpc_is_fault(XMLRPCDocument *response)
void http_header_add(List *headers, char *name, char *contents)
void counter_destroy(Counter *counter)
void gwlist_append(List *list, void *item)
void gwthread_join(long thread)
static HTTPCaller * caller
static Octstr * content_file
void http_add_basic_auth(List *headers, Octstr *username, Octstr *password)
static Octstr * ssl_client_certkey_file
int octstr_print(FILE *f, Octstr *ostr)
long xmlrpc_get_faultcode(XMLRPCDocument *faultresponse)
#define xmlrpc_parse_response(post_body)
#define octstr_get_cstr(ostr)
int xmlrpc_parse_status(XMLRPCDocument *xrdoc)
unsigned long counter_increase(Counter *counter)
Octstr * xmlrpc_get_faultstring(XMLRPCDocument *faultresponse)
int main(int argc, char **argv)
void http_destroy_headers(List *headers)
int getopt(int argc, char **argv, char *opts)
#define xmlrpc_parse_call(post_body)
Counter * counter_create(void)
void log_set_output_level(enum output_level level)
void octstr_destroy(Octstr *ostr)
static Octstr * proxy_username
#define gwthread_create(func, arg)
#define octstr_create(cstr)
void octstr_destroy_item(void *os)
static void client_thread(void *arg)
void gwthread_sleep(double seconds)
#define http_receive_result(caller, status, final_url, headers, body)
Octstr * octstr_read_file(const char *filename)
static Octstr * auth_username
void http_use_proxy(Octstr *hostname, int port, int ssl, List *exceptions, Octstr *username, Octstr *password, Octstr *exceptions_regex)
#define xmlrpc_destroy_call(call)
void debug(const char *place, int err, const char *fmt,...)
HTTPCaller * http_caller_create(void)
void gwlib_shutdown(void)
static Octstr * auth_password
void http_caller_destroy(HTTPCaller *caller)
#define xmlrpc_print_call(call)
static void start_request(HTTPCaller *caller, List *reqh, long i)
static XMLRPCDocument * msg
static Octstr * extra_headers
Octstr * xmlrpc_parse_error(XMLRPCDocument *xrdoc)
static Octstr * proxy_password
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)