Add a http get command
This commit is contained in:
2 files changed
+23
-1
No files matched your search
@@ -0,0 +1,17 @@
|
||||
#include "../lib/http.h"
|
||||
#include <cJSON.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void http_get_command(int argc, char *argv[]) {
|
||||
for (int i = 0; i < argc; i++) {
|
||||
if (i > 0)
|
||||
putchar(' ');
|
||||
char *body = http_get(argv[i]);
|
||||
if (!body) {
|
||||
printf("Failed to GET url \"%s\"\n", argv[i]);
|
||||
return;
|
||||
}
|
||||
printf("%s\n", body);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ void base64_decode_command(int argc, char *argv[]);
|
||||
void base64_encode_command(int argc, char *argv[]);
|
||||
void echo_command(int argc, char *argv[]);
|
||||
void version_command(int argc, char *argv[]);
|
||||
void http_get_command(int argc, char *argv[]);
|
||||
}
|
||||
|
||||
const std::vector<Command> commands = {
|
||||
@@ -23,7 +24,11 @@ const std::vector<Command> commands = {
|
||||
{"base64-encode",
|
||||
"A base64 encode command, \"base64-encode <encoded-text> "
|
||||
"[encoded-text2]\"",
|
||||
base64_encode_command}};
|
||||
base64_encode_command},
|
||||
{"http-get",
|
||||
"A HTTP get command, \"http-get <url> "
|
||||
"[encoded-text2]\"",
|
||||
http_get_command}};
|
||||
|
||||
const std::vector<Command> &getCommands() { return commands; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user