| 1183 | /* http get */ |
| 1184 | |
| 1185 | apr_status_t md_json_read_http(md_json_t **pjson, apr_pool_t *pool, const md_http_response_t *res) |
| 1186 | { |
| 1187 | apr_status_t rv = APR_ENOENT; |
| 1188 | const char *ctype, *p; |
| 1189 | apr_size_t ctype_len; |
| 1190 | |
| 1191 | *pjson = NULL; |
| 1192 | if (!res->body) goto cleanup; |
| 1193 | ctype = md_util_parse_ct(res->req->pool, apr_table_get(res->headers, "content-type")); |
| 1194 | if (!ctype) goto cleanup; |
| 1195 | ctype_len = strlen(ctype); |
| 1196 | if (ctype_len < sizeof("/json")) goto cleanup; |
| 1197 | p = ctype + ctype_len + 1; /* point to the terminating 0 */ |
| 1198 | if (!strcmp(p - sizeof("/json"), "/json") || |
| 1199 | !strcmp(p - sizeof("+json"), "+json") || |
| 1200 | !strcmp(ctype, "text/plain")) { |
| 1201 | rv = md_json_readb(pjson, pool, res->body); |
| 1202 | } |
| 1203 | cleanup: |
| 1204 | return rv; |
| 1205 | } |
| 1206 | |
| 1207 | typedef struct { |
| 1208 | apr_status_t rv; |
no test coverage detected