#include "asterisk.h"
#include <time.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/signal.h>
#include <fcntl.h>
#include "asterisk/paths.h"
#include "asterisk/network.h"
#include "asterisk/cli.h"
#include "asterisk/tcptls.h"
#include "asterisk/http.h"
#include "asterisk/utils.h"
#include "asterisk/strings.h"
#include "asterisk/config.h"
#include "asterisk/stringfields.h"
#include "asterisk/ast_version.h"
#include "asterisk/manager.h"
#include "asterisk/_private.h"
#include "asterisk/astobj2.h"
Go to the source code of this file.
Data Structures | |
struct | ast_cfhttp_methods_text |
struct | http_uri_redirect |
struct | uri_redirects |
struct | uris |
Defines | |
#define | DO_SSL |
#define | HOOK_T ssize_t |
#define | LEN_T size_t |
#define | MAX_PREFIX 80 |
Functions | |
static int | __ast_http_load (int reload) |
static void | add_redirect (const char *value) |
Add a new URI redirect The entries in the redirect list are sorted by length, just like the list of URI handlers. | |
const char * | ast_get_http_method (enum ast_http_method method) |
Return http method name string. | |
void | ast_http_auth (struct ast_tcptls_session_instance *ser, const char *realm, const unsigned long nonce, const unsigned long opaque, int stale, const char *text) |
Send http "401 Unauthorized" response and close socket. | |
void | ast_http_error (struct ast_tcptls_session_instance *ser, int status_code, const char *status_title, const char *text) |
Send HTTP error message and close socket. | |
const char * | ast_http_ftype2mtype (const char *ftype) |
Return mime type based on extension. | |
ast_variable * | ast_http_get_cookies (struct ast_variable *headers) |
Get cookie from Request headers. | |
ast_variable * | ast_http_get_post_vars (struct ast_tcptls_session_instance *ser, struct ast_variable *headers) |
Get post variables from client Request Entity-Body, if content type is application/x-www-form-urlencoded. | |
int | ast_http_init (void) |
uint32_t | ast_http_manid_from_vars (struct ast_variable *headers) |
Return manager id, if exist, from request headers. | |
void | ast_http_prefix (char *buf, int len) |
Return the current prefix. | |
int | ast_http_reload (void) |
void | ast_http_send (struct ast_tcptls_session_instance *ser, enum ast_http_method method, int status_code, const char *status_title, struct ast_str *http_header, struct ast_str *out, const int fd, unsigned int static_content) |
Generic function for sending http/1.1 response. | |
int | ast_http_uri_link (struct ast_http_uri *urih) |
Register a URI handler. | |
void | ast_http_uri_unlink (struct ast_http_uri *urih) |
Unregister a URI handler. | |
void | ast_http_uri_unlink_all_with_key (const char *key) |
Unregister all handlers with matching key. | |
static char * | handle_show_http (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static int | handle_uri (struct ast_tcptls_session_instance *ser, char *uri, enum ast_http_method method, struct ast_variable *headers) |
static void | http_decode (char *s) |
static void * | httpd_helper_thread (void *arg) |
static int | httpstatus_callback (struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_vars, struct ast_variable *headers) |
static struct ast_variable * | parse_cookies (char *cookies) |
static int | static_callback (struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_vars, struct ast_variable *headers) |
Variables | |
static struct ast_cfhttp_methods_text | ast_http_methods_text [] |
static struct ast_cli_entry | cli_http [] |
static int | enablestatic |
static struct ast_tcptls_session_args | http_desc |
static struct ast_tls_config | http_tls_cfg |
static struct ast_tcptls_session_args | https_desc |
struct { | |
const char * ext | |
const char * mtype | |
} | mimetypes [] |
Limit the kinds of files we're willing to serve up. | |
static char | prefix [MAX_PREFIX] |
static struct ast_http_uri | staticuri |
static struct ast_http_uri | statusuri |
Definition in file http.c.
#define MAX_PREFIX 80 |
static int __ast_http_load | ( | int | reload | ) | [static] |
Definition at line 981 of file http.c.
References ahp, AST_CERTFILE, ast_config_load2(), ast_free, AST_RWLIST_REMOVE_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_sockaddr_from_sin, ast_strdup, ast_tls_read_conf(), ast_true(), ast_variable_browse(), ast_tls_config::certfile, ast_tls_config::cipher, CONFIG_FLAG_FILEUNCHANGED, config_flags, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, CONFIG_STATUS_FILEUNCHANGED, ast_tls_config::enabled, enabled, hp, http_desc, http_tls_cfg, https_desc, ast_tcptls_session_args::local_address, MAX_PREFIX, ast_variable::name, ast_variable::next, ast_tls_config::pvtfile, and ast_variable::value.
Referenced by ast_http_init(), and ast_http_reload().
00982 { 00983 struct ast_config *cfg; 00984 struct ast_variable *v; 00985 int enabled=0; 00986 int newenablestatic=0; 00987 struct hostent *hp; 00988 struct ast_hostent ahp; 00989 char newprefix[MAX_PREFIX] = ""; 00990 struct http_uri_redirect *redirect; 00991 struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; 00992 struct sockaddr_in tmp = {0,}; 00993 struct sockaddr_in tmp2 = {0,}; 00994 00995 cfg = ast_config_load2("http.conf", "http", config_flags); 00996 if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) { 00997 return 0; 00998 } 00999 01000 /* default values */ 01001 tmp.sin_family = AF_INET; 01002 tmp.sin_port = htons(8088); 01003 ast_sockaddr_from_sin(&http_desc.local_address, &tmp); 01004 01005 tmp2.sin_family = AF_INET; 01006 tmp2.sin_port = htons(8089); 01007 ast_sockaddr_from_sin(&https_desc.local_address, &tmp2); 01008 01009 http_tls_cfg.enabled = 0; 01010 if (http_tls_cfg.certfile) { 01011 ast_free(http_tls_cfg.certfile); 01012 } 01013 http_tls_cfg.certfile = ast_strdup(AST_CERTFILE); 01014 01015 if (http_tls_cfg.pvtfile) { 01016 ast_free(http_tls_cfg.pvtfile); 01017 } 01018 http_tls_cfg.pvtfile = ast_strdup(""); 01019 01020 if (http_tls_cfg.cipher) { 01021 ast_free(http_tls_cfg.cipher); 01022 } 01023 http_tls_cfg.cipher = ast_strdup(""); 01024 01025 AST_RWLIST_WRLOCK(&uri_redirects); 01026 while ((redirect = AST_RWLIST_REMOVE_HEAD(&uri_redirects, entry))) { 01027 ast_free(redirect); 01028 } 01029 AST_RWLIST_UNLOCK(&uri_redirects); 01030 01031 if (cfg) { 01032 v = ast_variable_browse(cfg, "general"); 01033 for (; v; v = v->next) { 01034 01035 /* handle tls conf */ 01036 if (!ast_tls_read_conf(&http_tls_cfg, &https_desc, v->name, v->value)) { 01037 continue; 01038 } 01039 01040 if (!strcasecmp(v->name, "enabled")) { 01041 enabled = ast_true(v->value); 01042 } else if (!strcasecmp(v->name, "enablestatic")) { 01043 newenablestatic = ast_true(v->value); 01044 } else if (!strcasecmp(v->name, "bindport")) { 01045 ast_sockaddr_set_port(&http_desc.local_address, 01046 atoi(v->value)); 01047 } else if (!strcasecmp(v->name, "bindaddr")) { 01048 if ((hp = ast_gethostbyname(v->value, &ahp))) { 01049 ast_sockaddr_to_sin(&http_desc.local_address, 01050 &tmp); 01051 memcpy(&tmp.sin_addr, hp->h_addr, sizeof(tmp.sin_addr)); 01052 ast_sockaddr_from_sin(&http_desc.local_address, 01053 &tmp); 01054 } else { 01055 ast_log(LOG_WARNING, "Invalid bind address '%s'\n", v->value); 01056 } 01057 } else if (!strcasecmp(v->name, "prefix")) { 01058 if (!ast_strlen_zero(v->value)) { 01059 newprefix[0] = '/'; 01060 ast_copy_string(newprefix + 1, v->value, sizeof(newprefix) - 1); 01061 } else { 01062 newprefix[0] = '\0'; 01063 } 01064 } else if (!strcasecmp(v->name, "redirect")) { 01065 add_redirect(v->value); 01066 } else { 01067 ast_log(LOG_WARNING, "Ignoring unknown option '%s' in http.conf\n", v->name); 01068 } 01069 } 01070 01071 ast_config_destroy(cfg); 01072 } 01073 /* if the https addres has not been set, default is the same as non secure http */ 01074 ast_sockaddr_to_sin(&http_desc.local_address, &tmp); 01075 ast_sockaddr_to_sin(&https_desc.local_address, &tmp2); 01076 if (!tmp2.sin_addr.s_addr) { 01077 tmp2.sin_addr = tmp.sin_addr; 01078 ast_sockaddr_from_sin(&https_desc.local_address, &tmp2); 01079 } 01080 if (!enabled) { 01081 ast_sockaddr_setnull(&http_desc.local_address); 01082 ast_sockaddr_setnull(&https_desc.local_address); 01083 } 01084 if (strcmp(prefix, newprefix)) { 01085 ast_copy_string(prefix, newprefix, sizeof(prefix)); 01086 } 01087 enablestatic = newenablestatic; 01088 ast_tcptls_server_start(&http_desc); 01089 if (ast_ssl_setup(https_desc.tls_cfg)) { 01090 ast_tcptls_server_start(&https_desc); 01091 } 01092 01093 return 0; 01094 }
static void add_redirect | ( | const char * | value | ) | [static] |
Add a new URI redirect The entries in the redirect list are sorted by length, just like the list of URI handlers.
Definition at line 928 of file http.c.
References ast_calloc, ast_log(), AST_RWLIST_EMPTY, AST_RWLIST_FIRST, AST_RWLIST_INSERT_AFTER, AST_RWLIST_INSERT_HEAD, AST_RWLIST_INSERT_TAIL, AST_RWLIST_NEXT, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_skip_blanks(), ast_strdupa, http_uri_redirect::dest, http_uri_redirect::entry, LOG_WARNING, strsep(), and http_uri_redirect::target.
00929 { 00930 char *target, *dest; 00931 struct http_uri_redirect *redirect, *cur; 00932 unsigned int target_len; 00933 unsigned int total_len; 00934 00935 dest = ast_strdupa(value); 00936 dest = ast_skip_blanks(dest); 00937 target = strsep(&dest, " "); 00938 target = ast_skip_blanks(target); 00939 target = strsep(&target, " "); /* trim trailing whitespace */ 00940 00941 if (!dest) { 00942 ast_log(LOG_WARNING, "Invalid redirect '%s'\n", value); 00943 return; 00944 } 00945 00946 target_len = strlen(target) + 1; 00947 total_len = sizeof(*redirect) + target_len + strlen(dest) + 1; 00948 00949 if (!(redirect = ast_calloc(1, total_len))) { 00950 return; 00951 } 00952 redirect->dest = redirect->target + target_len; 00953 strcpy(redirect->target, target); 00954 strcpy(redirect->dest, dest); 00955 00956 AST_RWLIST_WRLOCK(&uri_redirects); 00957 00958 target_len--; /* So we can compare directly with strlen() */ 00959 if (AST_RWLIST_EMPTY(&uri_redirects) 00960 || strlen(AST_RWLIST_FIRST(&uri_redirects)->target) <= target_len ) { 00961 AST_RWLIST_INSERT_HEAD(&uri_redirects, redirect, entry); 00962 AST_RWLIST_UNLOCK(&uri_redirects); 00963 00964 return; 00965 } 00966 00967 AST_RWLIST_TRAVERSE(&uri_redirects, cur, entry) { 00968 if (AST_RWLIST_NEXT(cur, entry) 00969 && strlen(AST_RWLIST_NEXT(cur, entry)->target) <= target_len ) { 00970 AST_RWLIST_INSERT_AFTER(&uri_redirects, cur, redirect, entry); 00971 AST_RWLIST_UNLOCK(&uri_redirects); 00972 return; 00973 } 00974 } 00975 00976 AST_RWLIST_INSERT_TAIL(&uri_redirects, redirect, entry); 00977 00978 AST_RWLIST_UNLOCK(&uri_redirects); 00979 }
const char* ast_get_http_method | ( | enum ast_http_method | method | ) |
Return http method name string.
Definition at line 132 of file http.c.
References ast_http_methods_text, and ast_cfhttp_methods_text::text.
00133 { 00134 return ast_http_methods_text[method].text; 00135 }
void ast_http_auth | ( | struct ast_tcptls_session_instance * | ser, | |
const char * | realm, | |||
const unsigned long | nonce, | |||
const unsigned long | opaque, | |||
int | stale, | |||
const char * | text | |||
) |
Send http "401 Unauthorized" response and close socket.
Definition at line 437 of file http.c.
References ast_free, ast_http_send(), AST_HTTP_UNKNOWN, ast_str_create(), and ast_str_set().
00440 { 00441 struct ast_str *http_headers = ast_str_create(128); 00442 struct ast_str *out = ast_str_create(512); 00443 00444 if (!http_headers || !out) { 00445 ast_free(http_headers); 00446 ast_free(out); 00447 return; 00448 } 00449 00450 ast_str_set(&http_headers, 0, 00451 "WWW-authenticate: Digest algorithm=MD5, realm=\"%s\", nonce=\"%08lx\", qop=\"auth\", opaque=\"%08lx\"%s\r\n" 00452 "Content-type: text/html", 00453 realm ? realm : "Asterisk", 00454 nonce, 00455 opaque, 00456 stale ? ", stale=true" : ""); 00457 00458 ast_str_set(&out, 0, 00459 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n" 00460 "<html><head>\r\n" 00461 "<title>401 Unauthorized</title>\r\n" 00462 "</head><body>\r\n" 00463 "<h1>401 Unauthorized</h1>\r\n" 00464 "<p>%s</p>\r\n" 00465 "<hr />\r\n" 00466 "<address>Asterisk Server</address>\r\n" 00467 "</body></html>\r\n", 00468 text ? text : ""); 00469 00470 ast_http_send(ser, AST_HTTP_UNKNOWN, 401, "Unauthorized", http_headers, out, 0, 0); 00471 return; 00472 }
void ast_http_error | ( | struct ast_tcptls_session_instance * | ser, | |
int | status_code, | |||
const char * | status_title, | |||
const char * | text | |||
) |
Send HTTP error message and close socket.
Definition at line 475 of file http.c.
References ast_free, ast_http_send(), AST_HTTP_UNKNOWN, ast_str_create(), and ast_str_set().
Referenced by auth_http_callback(), generic_http_callback(), handle_uri(), http_post_callback(), httpd_helper_thread(), httpstatus_callback(), phoneprov_callback(), and static_callback().
00476 { 00477 struct ast_str *http_headers = ast_str_create(40); 00478 struct ast_str *out = ast_str_create(256); 00479 00480 if (!http_headers || !out) { 00481 ast_free(http_headers); 00482 ast_free(out); 00483 return; 00484 } 00485 00486 ast_str_set(&http_headers, 0, "Content-type: text/html"); 00487 00488 ast_str_set(&out, 0, 00489 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n" 00490 "<html><head>\r\n" 00491 "<title>%d %s</title>\r\n" 00492 "</head><body>\r\n" 00493 "<h1>%s</h1>\r\n" 00494 "<p>%s</p>\r\n" 00495 "<hr />\r\n" 00496 "<address>Asterisk Server</address>\r\n" 00497 "</body></html>\r\n", 00498 status_code, status_title, status_title, text); 00499 00500 ast_http_send(ser, AST_HTTP_UNKNOWN, status_code, status_title, http_headers, out, 0, 0); 00501 return; 00502 }
const char* ast_http_ftype2mtype | ( | const char * | ftype | ) |
Return mime type based on extension.
ftype | filename extension |
Definition at line 137 of file http.c.
References ARRAY_LEN, ext, and mimetypes.
Referenced by static_callback().
00138 { 00139 int x; 00140 00141 if (ftype) { 00142 for (x = 0; x < ARRAY_LEN(mimetypes); x++) { 00143 if (!strcasecmp(ftype, mimetypes[x].ext)) { 00144 return mimetypes[x].mtype; 00145 } 00146 } 00147 } 00148 return NULL; 00149 }
struct ast_variable* ast_http_get_cookies | ( | struct ast_variable * | headers | ) |
Get cookie from Request headers.
Definition at line 811 of file http.c.
References ast_strdupa, ast_variables_destroy(), ast_variable::name, ast_variable::next, parse_cookies(), and ast_variable::value.
Referenced by ast_http_manid_from_vars(), generic_http_callback(), http_post_callback(), and httpstatus_callback().
00812 { 00813 struct ast_variable *v, *cookies=NULL; 00814 00815 for (v = headers; v; v = v->next) { 00816 if (!strncasecmp(v->name, "Cookie", 6)) { 00817 char *tmp = ast_strdupa(v->value); 00818 if (cookies) { 00819 ast_variables_destroy(cookies); 00820 } 00821 00822 cookies = parse_cookies(tmp); 00823 } 00824 } 00825 return cookies; 00826 }
struct ast_variable* ast_http_get_post_vars | ( | struct ast_tcptls_session_instance * | ser, | |
struct ast_variable * | headers | |||
) |
Get post variables from client Request Entity-Body, if content type is application/x-www-form-urlencoded.
ser | TCP/TLS session object | |
headers | List of HTTP headers |
Definition at line 591 of file http.c.
References ast_variable::name, ast_variable::next, ast_variable::value, and var.
00593 { 00594 int content_length = 0; 00595 struct ast_variable *v, *post_vars=NULL, *prev = NULL; 00596 char *buf, *var, *val; 00597 00598 for (v = headers; v; v = v->next) { 00599 if (!strcasecmp(v->name, "Content-Type")) { 00600 if (strcasecmp(v->value, "application/x-www-form-urlencoded")) { 00601 return NULL; 00602 } 00603 break; 00604 } 00605 } 00606 00607 for (v = headers; v; v = v->next) { 00608 if (!strcasecmp(v->name, "Content-Length")) { 00609 content_length = atoi(v->value) + 1; 00610 break; 00611 } 00612 } 00613 00614 if (!content_length) { 00615 return NULL; 00616 } 00617 00618 if (!(buf = alloca(content_length))) { 00619 return NULL; 00620 } 00621 if (!fgets(buf, content_length, ser->f)) { 00622 return NULL; 00623 } 00624 00625 while ((val = strsep(&buf, "&"))) { 00626 var = strsep(&val, "="); 00627 if (val) { 00628 http_decode(val); 00629 } else { 00630 val = ""; 00631 } 00632 http_decode(var); 00633 if ((v = ast_variable_new(var, val, ""))) { 00634 if (post_vars) { 00635 prev->next = v; 00636 } else { 00637 post_vars = v; 00638 } 00639 prev = v; 00640 } 00641 } 00642 return post_vars; 00643 }
int ast_http_init | ( | void | ) |
Provided by http.c
Definition at line 1163 of file http.c.
References __ast_http_load(), ARRAY_LEN, ast_cli_register_multiple(), ast_http_uri_link(), cli_http, staticuri, and statusuri.
Referenced by main().
01164 { 01165 ast_http_uri_link(&statusuri); 01166 ast_http_uri_link(&staticuri); 01167 ast_cli_register_multiple(cli_http, ARRAY_LEN(cli_http)); 01168 01169 return __ast_http_load(0); 01170 }
uint32_t ast_http_manid_from_vars | ( | struct ast_variable * | headers | ) |
Return manager id, if exist, from request headers.
headers | List of HTTP headers |
Definition at line 151 of file http.c.
References ast_http_get_cookies(), ast_variable::name, ast_variable::next, and ast_variable::value.
Referenced by http_post_callback(), and static_callback().
00152 { 00153 uint32_t mngid = 0; 00154 struct ast_variable *v, *cookies; 00155 00156 cookies = ast_http_get_cookies(headers); 00157 for (v = cookies; v; v = v->next) { 00158 if (!strcasecmp(v->name, "mansession_id")) { 00159 sscanf(v->value, "%30x", &mngid); 00160 break; 00161 } 00162 } 00163 if (cookies) { 00164 ast_variables_destroy(cookies); 00165 } 00166 return mngid; 00167 }
void ast_http_prefix | ( | char * | buf, | |
int | len | |||
) |
Return the current prefix.
[out] | buf | destination buffer for previous |
[in] | len | length of prefix to copy |
Definition at line 169 of file http.c.
References ast_copy_string().
00170 { 00171 if (buf) { 00172 ast_copy_string(buf, prefix, len); 00173 } 00174 }
int ast_http_reload | ( | void | ) |
Provided by http.c
Definition at line 1154 of file http.c.
References __ast_http_load().
01155 { 01156 return __ast_http_load(1); 01157 }
void ast_http_send | ( | struct ast_tcptls_session_instance * | ser, | |
enum ast_http_method | method, | |||
int | status_code, | |||
const char * | status_title, | |||
struct ast_str * | http_header, | |||
struct ast_str * | out, | |||
const int | fd, | |||
unsigned int | static_content | |||
) |
Generic function for sending http/1.1 response.
ser | TCP/TLS session object | |
method | GET/POST/HEAD | |
status_code | HTTP response code (200/401/403/404/500) | |
status_title | English equivalent to the status_code parameter | |
http_header | An ast_str object containing all headers | |
out | An ast_str object containing the body of the response | |
fd | If out is NULL, a file descriptor where the body of the response is held (otherwise -1) | |
static_content | Zero if the content is dynamically generated and should not be cached; nonzero otherwise |
HTTP content can be constructed from the argument "out", if it is not NULL; otherwise, the function will read content from FD.
This function calculates the content-length http header itself.
Both the http_header and out arguments will be freed by this function; however, if FD is open, it will remain open.
Definition at line 364 of file http.c.
References ast_free, ast_get_version(), AST_HTTP_HEAD, ast_localtime(), ast_log(), ast_str_buffer(), ast_strftime(), ast_tvnow(), errno, ast_tcptls_session_instance::f, fwrite, len(), and LOG_WARNING.
Referenced by ast_http_auth(), ast_http_error(), handle_uri(), httpstatus_callback(), and phoneprov_callback().
00368 { 00369 struct timeval now = ast_tvnow(); 00370 struct ast_tm tm; 00371 char timebuf[80]; 00372 int content_length = 0; 00373 00374 if (!ser || 0 == ser->f) { 00375 return; 00376 } 00377 00378 ast_strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S GMT", ast_localtime(&now, &tm, "GMT")); 00379 00380 /* calc conetnt length */ 00381 if (out) { 00382 content_length += strlen(ast_str_buffer(out)); 00383 } 00384 00385 if (fd) { 00386 content_length += lseek(fd, 0, SEEK_END); 00387 lseek(fd, 0, SEEK_SET); 00388 } 00389 00390 /* send http header */ 00391 fprintf(ser->f, "HTTP/1.1 %d %s\r\n" 00392 "Server: Asterisk/%s\r\n" 00393 "Date: %s\r\n" 00394 "Connection: close\r\n" 00395 "%s" 00396 "Content-Length: %d\r\n" 00397 "%s\r\n\r\n", 00398 status_code, status_title ? status_title : "OK", 00399 ast_get_version(), 00400 timebuf, 00401 static_content ? "" : "Cache-Control: no-cache, no-store\r\n", 00402 content_length, 00403 http_header ? ast_str_buffer(http_header) : "" 00404 ); 00405 00406 /* send content */ 00407 if (method != AST_HTTP_HEAD || status_code >= 400) { 00408 if (out) { 00409 fprintf(ser->f, "%s", ast_str_buffer(out)); 00410 } 00411 00412 if (fd) { 00413 char buf[256]; 00414 int len; 00415 while ((len = read(fd, buf, sizeof(buf))) > 0) { 00416 if (fwrite(buf, len, 1, ser->f) != 1) { 00417 ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno)); 00418 break; 00419 } 00420 } 00421 } 00422 } 00423 00424 if (http_header) { 00425 ast_free(http_header); 00426 } 00427 if (out) { 00428 ast_free(out); 00429 } 00430 00431 fclose(ser->f); 00432 ser->f = 0; 00433 return; 00434 }
int ast_http_uri_link | ( | struct ast_http_uri * | urih | ) |
Register a URI handler.
They are sorted by length of the string, not alphabetically. Duplicate entries are not replaced, but the insertion order (using <= and not just <) makes sure that more recent insertions hide older ones. On a lookup, we just scan the list and stop at the first matching entry.
Definition at line 513 of file http.c.
References AST_RWLIST_EMPTY, AST_RWLIST_FIRST, AST_RWLIST_INSERT_AFTER, AST_RWLIST_INSERT_HEAD, AST_RWLIST_INSERT_TAIL, AST_RWLIST_NEXT, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_http_uri::entry, len(), and ast_http_uri::uri.
Referenced by __ast_http_post_load(), ast_http_init(), and load_module().
00514 { 00515 struct ast_http_uri *uri; 00516 int len = strlen(urih->uri); 00517 00518 AST_RWLIST_WRLOCK(&uris); 00519 00520 if ( AST_RWLIST_EMPTY(&uris) || strlen(AST_RWLIST_FIRST(&uris)->uri) <= len ) { 00521 AST_RWLIST_INSERT_HEAD(&uris, urih, entry); 00522 AST_RWLIST_UNLOCK(&uris); 00523 return 0; 00524 } 00525 00526 AST_RWLIST_TRAVERSE(&uris, uri, entry) { 00527 if (AST_RWLIST_NEXT(uri, entry) && 00528 strlen(AST_RWLIST_NEXT(uri, entry)->uri) <= len) { 00529 AST_RWLIST_INSERT_AFTER(&uris, uri, urih, entry); 00530 AST_RWLIST_UNLOCK(&uris); 00531 00532 return 0; 00533 } 00534 } 00535 00536 AST_RWLIST_INSERT_TAIL(&uris, urih, entry); 00537 00538 AST_RWLIST_UNLOCK(&uris); 00539 00540 return 0; 00541 }
void ast_http_uri_unlink | ( | struct ast_http_uri * | urih | ) |
Unregister a URI handler.
Definition at line 543 of file http.c.
References AST_RWLIST_REMOVE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and ast_http_uri::entry.
Referenced by unload_module().
00544 { 00545 AST_RWLIST_WRLOCK(&uris); 00546 AST_RWLIST_REMOVE(&uris, urih, entry); 00547 AST_RWLIST_UNLOCK(&uris); 00548 }
void ast_http_uri_unlink_all_with_key | ( | const char * | key | ) |
Unregister all handlers with matching key.
Definition at line 550 of file http.c.
References ast_free, AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_http_uri::data, ast_http_uri::dmallocd, ast_http_uri::entry, ast_http_uri::key, and ast_http_uri::mallocd.
Referenced by __ast_http_post_load(), and unload_module().
00551 { 00552 struct ast_http_uri *urih; 00553 AST_RWLIST_WRLOCK(&uris); 00554 AST_RWLIST_TRAVERSE_SAFE_BEGIN(&uris, urih, entry) { 00555 if (!strcmp(urih->key, key)) { 00556 AST_RWLIST_REMOVE_CURRENT(entry); 00557 } 00558 if (urih->dmallocd) { 00559 ast_free(urih->data); 00560 } 00561 if (urih->mallocd) { 00562 ast_free(urih); 00563 } 00564 } 00565 AST_RWLIST_TRAVERSE_SAFE_END; 00566 AST_RWLIST_UNLOCK(&uris); 00567 }
static char* handle_show_http | ( | struct ast_cli_entry * | e, | |
int | cmd, | |||
struct ast_cli_args * | a | |||
) | [static] |
Definition at line 1096 of file http.c.
References ast_cli_args::argc, ast_cli(), ast_inet_ntoa(), AST_RWLIST_EMPTY, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_sockaddr_to_sin, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_http_uri::description, http_uri_redirect::dest, ast_tls_config::enabled, ast_cli_args::fd, ast_http_uri::has_subtree, http_desc, http_tls_cfg, https_desc, ast_tcptls_session_args::old_address, http_uri_redirect::target, ast_http_uri::uri, and ast_cli_entry::usage.
01097 { 01098 struct ast_http_uri *urih; 01099 struct http_uri_redirect *redirect; 01100 struct sockaddr_in tmp; 01101 01102 switch (cmd) { 01103 case CLI_INIT: 01104 e->command = "http show status"; 01105 e->usage = 01106 "Usage: http show status\n" 01107 " Lists status of internal HTTP engine\n"; 01108 return NULL; 01109 case CLI_GENERATE: 01110 return NULL; 01111 } 01112 01113 if (a->argc != 3) { 01114 return CLI_SHOWUSAGE; 01115 } 01116 ast_cli(a->fd, "HTTP Server Status:\n"); 01117 ast_cli(a->fd, "Prefix: %s\n", prefix); 01118 ast_sockaddr_to_sin(&http_desc.old_address, &tmp); 01119 if (!tmp.sin_family) { 01120 ast_cli(a->fd, "Server Disabled\n\n"); 01121 } else { 01122 ast_cli(a->fd, "Server Enabled and Bound to %s:%d\n\n", 01123 ast_inet_ntoa(tmp.sin_addr), ntohs(tmp.sin_port)); 01124 if (http_tls_cfg.enabled) { 01125 ast_sockaddr_to_sin(&https_desc.old_address, &tmp); 01126 ast_cli(a->fd, "HTTPS Server Enabled and Bound to %s:%d\n\n", 01127 ast_inet_ntoa(tmp.sin_addr), 01128 ntohs(tmp.sin_port)); 01129 } 01130 } 01131 01132 ast_cli(a->fd, "Enabled URI's:\n"); 01133 AST_RWLIST_RDLOCK(&uris); 01134 if (AST_RWLIST_EMPTY(&uris)) { 01135 ast_cli(a->fd, "None.\n"); 01136 } else { 01137 AST_RWLIST_TRAVERSE(&uris, urih, entry) 01138 ast_cli(a->fd, "%s/%s%s => %s\n", prefix, urih->uri, (urih->has_subtree ? "/..." : "" ), urih->description); 01139 } 01140 AST_RWLIST_UNLOCK(&uris); 01141 01142 ast_cli(a->fd, "\nEnabled Redirects:\n"); 01143 AST_RWLIST_RDLOCK(&uri_redirects); 01144 AST_RWLIST_TRAVERSE(&uri_redirects, redirect, entry) 01145 ast_cli(a->fd, " %s => %s\n", redirect->target, redirect->dest); 01146 if (AST_RWLIST_EMPTY(&uri_redirects)) { 01147 ast_cli(a->fd, " None.\n"); 01148 } 01149 AST_RWLIST_UNLOCK(&uri_redirects); 01150 01151 return CLI_SUCCESS; 01152 }
static int handle_uri | ( | struct ast_tcptls_session_instance * | ser, | |
char * | uri, | |||
enum ast_http_method | method, | |||
struct ast_variable * | headers | |||
) | [static] |
Definition at line 645 of file http.c.
References ast_debug, ast_http_error(), ast_http_send(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_str_create(), ast_str_set(), ast_variable_new(), ast_variables_destroy(), ast_http_uri::callback, cleanup(), http_uri_redirect::dest, http_uri_redirect::entry, ast_http_uri::has_subtree, http_decode(), strsep(), http_uri_redirect::target, ast_http_uri::uri, and var.
Referenced by httpd_helper_thread().
00647 { 00648 char *c; 00649 int res = -1; 00650 char *params = uri; 00651 struct ast_http_uri *urih = NULL; 00652 int l; 00653 struct ast_variable *get_vars = NULL, *v, *prev = NULL; 00654 struct http_uri_redirect *redirect; 00655 00656 strsep(¶ms, "?"); 00657 /* Extract arguments from the request and store them in variables. */ 00658 if (params) { 00659 char *var, *val; 00660 00661 while ((val = strsep(¶ms, "&"))) { 00662 var = strsep(&val, "="); 00663 if (val) { 00664 http_decode(val); 00665 } else { 00666 val = ""; 00667 } 00668 http_decode(var); 00669 if ((v = ast_variable_new(var, val, ""))) { 00670 if (get_vars) { 00671 prev->next = v; 00672 } else { 00673 get_vars = v; 00674 } 00675 prev = v; 00676 } 00677 } 00678 } 00679 http_decode(uri); 00680 00681 AST_RWLIST_RDLOCK(&uri_redirects); 00682 AST_RWLIST_TRAVERSE(&uri_redirects, redirect, entry) { 00683 if (!strcasecmp(uri, redirect->target)) { 00684 struct ast_str *http_header = ast_str_create(128); 00685 ast_str_set(&http_header, 0, "Location: %s\r\n", redirect->dest); 00686 ast_http_send(ser, method, 302, "Moved Temporarily", http_header, NULL, 0, 0); 00687 00688 break; 00689 } 00690 } 00691 AST_RWLIST_UNLOCK(&uri_redirects); 00692 if (redirect) { 00693 goto cleanup; 00694 } 00695 00696 /* We want requests to start with the (optional) prefix and '/' */ 00697 l = strlen(prefix); 00698 if (!strncasecmp(uri, prefix, l) && uri[l] == '/') { 00699 uri += l + 1; 00700 /* scan registered uris to see if we match one. */ 00701 AST_RWLIST_RDLOCK(&uris); 00702 AST_RWLIST_TRAVERSE(&uris, urih, entry) { 00703 ast_debug(2, "match request [%s] with handler [%s] len %d\n", uri, urih->uri, l); 00704 l = strlen(urih->uri); 00705 c = uri + l; /* candidate */ 00706 if (strncasecmp(urih->uri, uri, l) /* no match */ 00707 || (*c && *c != '/')) { /* substring */ 00708 continue; 00709 } 00710 if (*c == '/') { 00711 c++; 00712 } 00713 if (!*c || urih->has_subtree) { 00714 uri = c; 00715 break; 00716 } 00717 } 00718 AST_RWLIST_UNLOCK(&uris); 00719 } 00720 if (urih) { 00721 res = urih->callback(ser, urih, uri, method, get_vars, headers); 00722 } else { 00723 ast_http_error(ser, 404, "Not Found", "The requested URL was not found on this server."); 00724 } 00725 00726 cleanup: 00727 ast_variables_destroy(get_vars); 00728 return res; 00729 }
static void http_decode | ( | char * | s | ) | [static] |
Definition at line 574 of file http.c.
References ast_uri_decode().
Referenced by handle_uri().
00575 { 00576 char *t; 00577 00578 for (t = s; *t; t++) { 00579 if (*t == '+') { 00580 *t = ' '; 00581 } 00582 } 00583 00584 ast_uri_decode(s); 00585 }
static void * httpd_helper_thread | ( | void * | arg | ) | [static] |
Definition at line 829 of file http.c.
References ao2_ref, ast_http_error(), AST_HTTP_GET, AST_HTTP_HEAD, AST_HTTP_POST, AST_HTTP_PUT, AST_HTTP_UNKNOWN, ast_skip_blanks(), ast_skip_nonblanks(), ast_strlen_zero(), ast_trim_blanks(), ast_variable_new(), ast_variables_destroy(), ast_tcptls_session_instance::f, handle_uri(), name, ast_variable::next, strsep(), and value.
00830 { 00831 char buf[4096]; 00832 char header_line[4096]; 00833 struct ast_tcptls_session_instance *ser = data; 00834 struct ast_variable *headers = NULL; 00835 struct ast_variable *tail = headers; 00836 char *uri, *method; 00837 enum ast_http_method http_method = AST_HTTP_UNKNOWN; 00838 00839 if (!fgets(buf, sizeof(buf), ser->f)) { 00840 goto done; 00841 } 00842 00843 /* Get method */ 00844 method = ast_skip_blanks(buf); 00845 uri = ast_skip_nonblanks(method); 00846 if (*uri) { 00847 *uri++ = '\0'; 00848 } 00849 00850 if (!strcasecmp(method,"GET")) { 00851 http_method = AST_HTTP_GET; 00852 } else if (!strcasecmp(method,"POST")) { 00853 http_method = AST_HTTP_POST; 00854 } else if (!strcasecmp(method,"HEAD")) { 00855 http_method = AST_HTTP_HEAD; 00856 } else if (!strcasecmp(method,"PUT")) { 00857 http_method = AST_HTTP_PUT; 00858 } 00859 00860 uri = ast_skip_blanks(uri); /* Skip white space */ 00861 00862 if (*uri) { /* terminate at the first blank */ 00863 char *c = ast_skip_nonblanks(uri); 00864 00865 if (*c) { 00866 *c = '\0'; 00867 } 00868 } 00869 00870 /* process "Request Headers" lines */ 00871 while (fgets(header_line, sizeof(header_line), ser->f)) { 00872 char *name, *value; 00873 00874 /* Trim trailing characters */ 00875 ast_trim_blanks(header_line); 00876 if (ast_strlen_zero(header_line)) { 00877 break; 00878 } 00879 00880 value = header_line; 00881 name = strsep(&value, ":"); 00882 if (!value) { 00883 continue; 00884 } 00885 00886 value = ast_skip_blanks(value); 00887 if (ast_strlen_zero(value) || ast_strlen_zero(name)) { 00888 continue; 00889 } 00890 00891 ast_trim_blanks(name); 00892 00893 if (!headers) { 00894 headers = ast_variable_new(name, value, __FILE__); 00895 tail = headers; 00896 } else { 00897 tail->next = ast_variable_new(name, value, __FILE__); 00898 tail = tail->next; 00899 } 00900 } 00901 00902 if (!*uri) { 00903 ast_http_error(ser, 400, "Bad Request", "Invalid Request"); 00904 return NULL; 00905 } 00906 00907 handle_uri(ser, uri, http_method, headers); 00908 00909 /* Clean up all the header information pulled as well */ 00910 if (headers) { 00911 ast_variables_destroy(headers); 00912 } 00913 00914 done: 00915 if (ser->f) { 00916 fclose(ser->f); 00917 } 00918 ao2_ref(ser, -1); 00919 ser = NULL; 00920 return NULL; 00921 }
static int httpstatus_callback | ( | struct ast_tcptls_session_instance * | ser, | |
const struct ast_http_uri * | urih, | |||
const char * | uri, | |||
enum ast_http_method | method, | |||
struct ast_variable * | get_vars, | |||
struct ast_variable * | headers | |||
) | [static] |
Definition at line 294 of file http.c.
References ast_http_error(), AST_HTTP_GET, ast_http_get_cookies(), AST_HTTP_HEAD, ast_http_send(), ast_sockaddr_stringify_addr(), ast_sockaddr_stringify_port(), ast_str_append(), ast_str_create(), ast_variables_destroy(), ast_tls_config::enabled, http_desc, http_tls_cfg, https_desc, ast_variable::name, ast_variable::next, ast_tcptls_session_args::old_address, and ast_variable::value.
00298 { 00299 struct ast_str *out; 00300 struct ast_variable *v, *cookies = NULL; 00301 00302 if (method != AST_HTTP_GET && method != AST_HTTP_HEAD) { 00303 ast_http_error(ser, 501, "Not Implemented", "Attempt to use unimplemented / unsupported method"); 00304 return -1; 00305 } 00306 00307 if ( (out = ast_str_create(512)) == NULL) { 00308 return -1; 00309 } 00310 00311 ast_str_append(&out, 0, 00312 "<title>Asterisk HTTP Status</title>\r\n" 00313 "<body bgcolor=\"#ffffff\">\r\n" 00314 "<table bgcolor=\"#f1f1f1\" align=\"center\"><tr><td bgcolor=\"#e0e0ff\" colspan=\"2\" width=\"500\">\r\n" 00315 "<h2> Asterisk™ HTTP Status</h2></td></tr>\r\n"); 00316 00317 ast_str_append(&out, 0, "<tr><td><i>Prefix</i></td><td><b>%s</b></td></tr>\r\n", prefix); 00318 ast_str_append(&out, 0, "<tr><td><i>Bind Address</i></td><td><b>%s</b></td></tr>\r\n", 00319 ast_sockaddr_stringify_addr(&http_desc.old_address)); 00320 ast_str_append(&out, 0, "<tr><td><i>Bind Port</i></td><td><b>%s</b></td></tr>\r\n", 00321 ast_sockaddr_stringify_port(&http_desc.old_address)); 00322 if (http_tls_cfg.enabled) { 00323 ast_str_append(&out, 0, "<tr><td><i>SSL Bind Port</i></td><td><b>%s</b></td></tr>\r\n", 00324 ast_sockaddr_stringify_port(&https_desc.old_address)); 00325 } 00326 ast_str_append(&out, 0, "<tr><td colspan=\"2\"><hr></td></tr>\r\n"); 00327 for (v = get_vars; v; v = v->next) { 00328 ast_str_append(&out, 0, "<tr><td><i>Submitted GET Variable '%s'</i></td><td>%s</td></tr>\r\n", v->name, v->value); 00329 } 00330 ast_str_append(&out, 0, "<tr><td colspan=\"2\"><hr></td></tr>\r\n"); 00331 00332 cookies = ast_http_get_cookies(headers); 00333 for (v = cookies; v; v = v->next) { 00334 ast_str_append(&out, 0, "<tr><td><i>Cookie '%s'</i></td><td>%s</td></tr>\r\n", v->name, v->value); 00335 } 00336 ast_variables_destroy(cookies); 00337 00338 ast_str_append(&out, 0, "</table><center><font size=\"-1\"><i>Asterisk and Digium are registered trademarks of Digium, Inc.</i></font></center></body>\r\n"); 00339 ast_http_send(ser, method, 200, NULL, NULL, out, 0, 0); 00340 return 0; 00341 }
static struct ast_variable* parse_cookies | ( | char * | cookies | ) | [static] |
replacement read/write functions for SSL support. We use wrappers rather than SSL_read/SSL_write directly so we can put in some debugging.
Definition at line 776 of file http.c.
References ast_log(), ast_strip(), ast_strip_quoted(), ast_strlen_zero(), ast_variable_new(), LOG_DEBUG, name, option_debug, strsep(), and var.
Referenced by ast_http_get_cookies().
00777 { 00778 char *cur; 00779 struct ast_variable *vars = NULL, *var; 00780 00781 while ((cur = strsep(&cookies, ";"))) { 00782 char *name, *val; 00783 00784 name = val = cur; 00785 strsep(&val, "="); 00786 00787 if (ast_strlen_zero(name) || ast_strlen_zero(val)) { 00788 continue; 00789 } 00790 00791 name = ast_strip(name); 00792 val = ast_strip_quoted(val, "\"", "\""); 00793 00794 if (ast_strlen_zero(name) || ast_strlen_zero(val)) { 00795 continue; 00796 } 00797 00798 if (option_debug) { 00799 ast_log(LOG_DEBUG, "mmm ... cookie! Name: '%s' Value: '%s'\n", name, val); 00800 } 00801 00802 var = ast_variable_new(name, val, __FILE__); 00803 var->next = vars; 00804 vars = var; 00805 } 00806 00807 return vars; 00808 }
static int static_callback | ( | struct ast_tcptls_session_instance * | ser, | |
const struct ast_http_uri * | urih, | |||
const char * | uri, | |||
enum ast_http_method | method, | |||
struct ast_variable * | get_vars, | |||
struct ast_variable * | headers | |||
) | [static] |
Definition at line 176 of file http.c.
References ast_config_AST_DATA_DIR, ast_http_error(), ast_http_ftype2mtype(), AST_HTTP_GET, AST_HTTP_HEAD, ast_http_manid_from_vars(), ast_localtime(), ast_strftime(), ast_strlen_zero(), astman_is_authed(), len(), mtype, ast_variable::name, ast_variable::next, S_OR, and ast_variable::value.
00180 { 00181 char *path; 00182 const char *ftype; 00183 const char *mtype; 00184 char wkspace[80]; 00185 struct stat st; 00186 int len; 00187 int fd; 00188 struct ast_str *http_header; 00189 struct timeval tv; 00190 struct ast_tm tm; 00191 char timebuf[80], etag[23]; 00192 struct ast_variable *v; 00193 int not_modified = 0; 00194 00195 if (method != AST_HTTP_GET && method != AST_HTTP_HEAD) { 00196 ast_http_error(ser, 501, "Not Implemented", "Attempt to use unimplemented / unsupported method"); 00197 return -1; 00198 } 00199 00200 /* Yuck. I'm not really sold on this, but if you don't deliver static content it makes your configuration 00201 substantially more challenging, but this seems like a rather irritating feature creep on Asterisk. */ 00202 if (!enablestatic || ast_strlen_zero(uri)) { 00203 goto out403; 00204 } 00205 00206 /* Disallow any funny filenames at all */ 00207 if ((uri[0] < 33) || strchr("./|~@#$%^&*() \t", uri[0])) { 00208 goto out403; 00209 } 00210 00211 if (strstr(uri, "/..")) { 00212 goto out403; 00213 } 00214 00215 if ((ftype = strrchr(uri, '.'))) { 00216 ftype++; 00217 } 00218 00219 if (!(mtype = ast_http_ftype2mtype(ftype))) { 00220 snprintf(wkspace, sizeof(wkspace), "text/%s", S_OR(ftype, "plain")); 00221 } 00222 00223 /* Cap maximum length */ 00224 if ((len = strlen(uri) + strlen(ast_config_AST_DATA_DIR) + strlen("/static-http/") + 5) > 1024) { 00225 goto out403; 00226 } 00227 00228 path = alloca(len); 00229 sprintf(path, "%s/static-http/%s", ast_config_AST_DATA_DIR, uri); 00230 if (stat(path, &st)) { 00231 goto out404; 00232 } 00233 00234 if (S_ISDIR(st.st_mode)) { 00235 goto out404; 00236 } 00237 00238 fd = open(path, O_RDONLY); 00239 if (fd < 0) { 00240 goto out403; 00241 } 00242 00243 if (strstr(path, "/private/") && !astman_is_authed(ast_http_manid_from_vars(headers))) { 00244 goto out403; 00245 } 00246 00247 /* make "Etag:" http header value */ 00248 snprintf(etag, sizeof(etag), "\"%ld\"", (long)st.st_mtime); 00249 00250 /* make "Last-Modified:" http header value */ 00251 tv.tv_sec = st.st_mtime; 00252 tv.tv_usec = 0; 00253 ast_strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S GMT", ast_localtime(&tv, &tm, "GMT")); 00254 00255 /* check received "If-None-Match" request header and Etag value for file */ 00256 for (v = headers; v; v = v->next) { 00257 if (!strcasecmp(v->name, "If-None-Match")) { 00258 if (!strcasecmp(v->value, etag)) { 00259 not_modified = 1; 00260 } 00261 break; 00262 } 00263 } 00264 00265 if ( (http_header = ast_str_create(255)) == NULL) { 00266 return -1; 00267 } 00268 00269 ast_str_set(&http_header, 0, "Content-type: %s\r\n" 00270 "ETag: %s\r\n" 00271 "Last-Modified: %s", 00272 mtype, 00273 etag, 00274 timebuf); 00275 00276 /* ast_http_send() frees http_header, so we don't need to do it before returning */ 00277 if (not_modified) { 00278 ast_http_send(ser, method, 304, "Not Modified", http_header, NULL, 0, 1); 00279 } else { 00280 ast_http_send(ser, method, 200, NULL, http_header, NULL, fd, 1); /* static content flag is set */ 00281 } 00282 close(fd); 00283 return 0; 00284 00285 out404: 00286 ast_http_error(ser, 404, "Not Found", "The requested URL was not found on this server."); 00287 return -1; 00288 00289 out403: 00290 ast_http_error(ser, 403, "Access Denied", "You do not have permission to access the requested URL."); 00291 return -1; 00292 }
struct ast_cfhttp_methods_text ast_http_methods_text[] [static] |
Referenced by ast_get_http_method().
struct ast_cli_entry cli_http[] [static] |
Initial value:
{ { .handler = handle_show_http , .summary = "Display HTTP server status" ,__VA_ARGS__ }, }
Definition at line 1159 of file http.c.
Referenced by ast_http_init().
int enablestatic [static] |
const char* ext |
Definition at line 99 of file http.c.
Referenced by ast_filehelper(), ast_http_ftype2mtype(), ast_rtp_read(), cli_console_dial(), common_exec(), console_transfer(), do_directory(), exts_compare(), handle_cli_dialplan_save(), iax_park_thread(), misdn_call(), misdn_request(), mixmonitor_thread(), moh_scan_files(), oh323_request(), pbx_load_config(), pbx_load_users(), pvalGotoSetTarget(), record_exec(), register_exten(), register_peer_exten(), sig_pri_call(), sig_pri_extract_called_num_subaddr(), sip_park_thread(), sip_request_call(), and unregister_exten().
struct ast_tcptls_session_args http_desc [static] |
we have up to two accepting threads, one for http, one for https
Definition at line 71 of file http.c.
Referenced by __ast_http_load(), handle_show_http(), and httpstatus_callback().
struct ast_tls_config http_tls_cfg [static] |
Definition at line 64 of file http.c.
Referenced by __ast_http_load(), handle_show_http(), and httpstatus_callback().
struct ast_tcptls_session_args https_desc [static] |
Definition at line 81 of file http.c.
Referenced by __ast_http_load(), handle_show_http(), and httpstatus_callback().
struct { ... } mimetypes[] [static] |
const char* mtype |
char prefix[MAX_PREFIX] [static] |
Definition at line 94 of file http.c.
Referenced by _while_exec(), aoc_d_event(), aoc_e_event(), aoc_s_event(), ast_db_deltree(), ast_db_gettree(), ast_remotecontrol(), exec_clearhash(), handle_cli_database_show(), hashkeys_read(), hashkeys_read2(), shared_read(), shared_write(), sip_show_settings(), and while_continue_exec().
struct ast_http_uri staticuri [static] |
struct ast_http_uri statusuri [static] |