#include <getopt.h>
#include <stdio.h>
#include <string.h>
static void
{
fprintf(stderr, "Finished with error, response code: %d\n",
return;
}
uint16_t idx;
printf("[COOKIE] %.*s : %.*s\n",
break;
printf("[HEADER] %.*s : %.*s\n",
default:
break;
}
}
}
}
static int
{
int r;
if (r < 0)
fprintf(stderr, "ERROR: Could not parse the post fields - \'%s\'\n", value);
return r;
}
static int
{
char *sep;
uint16_t i;
int ret = 0;
#define CREATE_PARAM(_key, _filename, _value) \
(struct sol_http_param_value) { \
.type = SOL_HTTP_PARAM_POST_DATA, \
.value.data.filename = _filename, \
.value.data.key = _key, \
.value.data.value = _value \
}
bool ok;
sep = memchr(token->
data,
'=', token->
len);
if (sep) {
value.data = sep + 1;
value.len = token->
len -
key.len - 1;
} else {
value.data = NULL;
value.len = 0;
}
if (value.data && (value.data[0] == '@')) {
value.data++;
value.len--;
} else {
}
if (!ok) {
fprintf(stderr, "[ERROR] Could not add the HTTP param %.*s:%.*s\n",
ret = -1;
goto exit;
}
}
#undef CREATE_PARAM
exit:
return ret;
}
static int
{
char *sep;
size_t len = strlen(value);
sep = memchr(value, ':', len);
if (sep) {
val.data = sep + 1;
val.len = len -
key.len - 1;
} else {
val.data = NULL;
val.len = 0;
}
param.value.key_value.key =
key;
param.value.key_value.value = val;
fprintf(stderr, "Could not add the HTTP param %.*s:%.*s",
return -1;
}
return 0;
}
static void
{
char *url = NULL;
static const struct option opts[] = {
{ "verbose", no_argument, NULL, 'v' },
{ "header", required_argument, NULL, 'H' },
{ "data", required_argument, NULL, 'd' },
{ "form", required_argument, NULL, 'F' },
{ "help", no_argument, NULL, 'h' },
{ 0, 0, 0, 0 }
};
while ((c = getopt_long(argc, argv, "vH:d:F:h", opts, &opt_idx)) != -1) {
switch (c) {
case 'v':
break;
case 'd':
goto err;
break;
case 'F':
goto err;
break;
case 'H':
goto err;
break;
case 'h':
default:
fprintf(stderr,
"Usage: %s <url> \n\t-v, --verbose Make it more talkative\n"
"\t-H, --header <\"Header\"> pass custom header to server\n"
"\t-F, --form <\"post data\"> Specify HTTP mulitpart POST data\n"
"\t syntax: key=value (for post value) or key=@value to post "
"the contents of the file value\n"
"\t-d, --data <\"post fields\"> HTTP POST fields (NOT encoded)\n",
argv[0]);
return;
}
}
url = argv[optind];
if (!url) {
fprintf(stderr, "ERROR: missing url.\n");
goto err;
}
if (!pending) {
fprintf(stderr, "ERROR: Failed to create the request\n");
goto err;
}
return;
err:
return;
}
static void
{
}