MCPcopy Create free account
hub / github.com/apache/httpd / md_status_handler

Function md_status_handler

modules/md/mod_md_status.c:933–984  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

931/* Status handlers */
932
933int md_status_handler(request_rec *r)
934{
935 const md_srv_conf_t *sc;
936 const md_mod_conf_t *mc;
937 apr_array_header_t *mds;
938 md_json_t *jstatus;
939 apr_bucket_brigade *bb;
940 const md_t *md;
941 const char *name;
942
943 if (strcmp(r->handler, "md-status")) {
944 return DECLINED;
945 }
946
947 sc = ap_get_module_config(r->server->module_config, &md_module);
948 if (!sc) return DECLINED;
949 mc = sc->mc;
950 if (!mc) return DECLINED;
951
952 if (r->method_number != M_GET) {
953 ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r, "md-status supports only GET");
954 return HTTP_NOT_IMPLEMENTED;
955 }
956
957 jstatus = NULL;
958 md = NULL;
959 if (r->path_info && r->path_info[0] == '/' && r->path_info[1] != '\0') {
960 name = strrchr(r->path_info, '/') + 1;
961 md = md_get_by_name(mc->mds, name);
962 if (!md) md = md_get_by_domain(mc->mds, name);
963 }
964
965 if (md) {
966 md_status_get_md_json(&jstatus, md, mc->reg, mc->ocsp, r->pool);
967 }
968 else {
969 mds = apr_array_copy(r->pool, mc->mds);
970 qsort(mds->elts, (size_t)mds->nelts, sizeof(md_t *), md_name_cmp);
971 md_status_get_json(&jstatus, mds, mc->reg, mc->ocsp, r->pool);
972 }
973
974 if (jstatus) {
975 apr_table_set(r->headers_out, "Content-Type", "application/json");
976 bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
977 md_json_writeb(jstatus, MD_JSON_FMT_INDENT, bb);
978 ap_pass_brigade(r->output_filters, bb);
979 apr_brigade_cleanup(bb);
980
981 return DONE;
982 }
983 return DECLINED;
984}
985

Callers

nothing calls this directly

Calls 7

ap_get_module_configFunction · 0.85
md_get_by_nameFunction · 0.85
md_get_by_domainFunction · 0.85
md_status_get_md_jsonFunction · 0.85
md_status_get_jsonFunction · 0.85
md_json_writebFunction · 0.85
ap_pass_brigadeFunction · 0.85

Tested by

no test coverage detected