diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/http.c | 6 | ||||
-rw-r--r-- | main/json.c | 27 |
2 files changed, 17 insertions, 16 deletions
diff --git a/main/http.c b/main/http.c index aff38c3aa..ec9517f2c 100644 --- a/main/http.c +++ b/main/http.c @@ -153,6 +153,8 @@ static const struct ast_cfhttp_methods_text { { AST_HTTP_POST, "POST" }, { AST_HTTP_HEAD, "HEAD" }, { AST_HTTP_PUT, "PUT" }, + { AST_HTTP_DELETE, "DELETE" }, + { AST_HTTP_OPTIONS, "OPTIONS" }, }; const char *ast_get_http_method(enum ast_http_method method) @@ -897,6 +899,10 @@ static void *httpd_helper_thread(void *data) http_method = AST_HTTP_HEAD; } else if (!strcasecmp(method,"PUT")) { http_method = AST_HTTP_PUT; + } else if (!strcasecmp(method,"DELETE")) { + http_method = AST_HTTP_DELETE; + } else if (!strcasecmp(method,"OPTIONS")) { + http_method = AST_HTTP_OPTIONS; } uri = ast_skip_blanks(uri); /* Skip white space */ diff --git a/main/json.c b/main/json.c index 2aa53875b..1ff563871 100644 --- a/main/json.c +++ b/main/json.c @@ -338,20 +338,15 @@ int ast_json_object_iter_set(struct ast_json *object, struct ast_json_iter *iter /*! * \brief Default flags for JSON encoding. */ -static size_t dump_flags(void) +static size_t dump_flags(enum ast_json_encoding_format format) { - /* There's a chance this could become a runtime flag */ - int flags = JSON_COMPACT; -#ifdef AST_DEVMODE - /* In dev mode, write readable JSON */ - flags = JSON_INDENT(2) | JSON_PRESERVE_ORDER; -#endif - return flags; + return format == AST_JSON_PRETTY ? + JSON_INDENT(2) | JSON_PRESERVE_ORDER : JSON_COMPACT; } -char *ast_json_dump_string(struct ast_json *root) +char *ast_json_dump_string_format(struct ast_json *root, enum ast_json_encoding_format format) { - return json_dumps((json_t *)root, dump_flags()); + return json_dumps((json_t *)root, dump_flags(format)); } static int write_to_ast_str(const char *buffer, size_t size, void *data) @@ -385,25 +380,25 @@ static int write_to_ast_str(const char *buffer, size_t size, void *data) return 0; } -int ast_json_dump_str(struct ast_json *root, struct ast_str **dst) +int ast_json_dump_str_format(struct ast_json *root, struct ast_str **dst, enum ast_json_encoding_format format) { - return json_dump_callback((json_t *)root, write_to_ast_str, dst, dump_flags()); + return json_dump_callback((json_t *)root, write_to_ast_str, dst, dump_flags(format)); } -int ast_json_dump_file(struct ast_json *root, FILE *output) +int ast_json_dump_file_format(struct ast_json *root, FILE *output, enum ast_json_encoding_format format) { if (!root || !output) { return -1; } - return json_dumpf((json_t *)root, output, dump_flags()); + return json_dumpf((json_t *)root, output, dump_flags(format)); } -int ast_json_dump_new_file(struct ast_json *root, const char *path) +int ast_json_dump_new_file_format(struct ast_json *root, const char *path, enum ast_json_encoding_format format) { if (!root || !path) { return -1; } - return json_dump_file((json_t *)root, path, dump_flags()); + return json_dump_file((json_t *)root, path, dump_flags(format)); } /*! |