| 274 | } |
| 275 | |
| 276 | static apr_status_t on_response(const md_http_response_t *res, void *data) |
| 277 | { |
| 278 | md_acme_req_t *req = data; |
| 279 | apr_status_t rv = APR_SUCCESS; |
| 280 | |
| 281 | req->resp_hdrs = apr_table_clone(req->p, res->headers); |
| 282 | req_update_nonce(req->acme, res->headers); |
| 283 | |
| 284 | md_log_perror(MD_LOG_MARK, MD_LOG_TRACE1, rv, req->p, "response: %d", res->status); |
| 285 | if (res->status >= 200 && res->status < 300) { |
| 286 | int processed = 0; |
| 287 | |
| 288 | if (req->on_json) { |
| 289 | processed = 1; |
| 290 | rv = md_json_read_http(&req->resp_json, req->p, res); |
| 291 | if (APR_SUCCESS == rv) { |
| 292 | if (md_log_is_level(req->p, MD_LOG_TRACE2)) { |
| 293 | const char *s; |
| 294 | s = md_json_writep(req->resp_json, req->p, MD_JSON_FMT_INDENT); |
| 295 | md_log_perror(MD_LOG_MARK, MD_LOG_TRACE2, rv, req->p, |
| 296 | "response: %s", |
| 297 | s ? s : "<failed to serialize!>"); |
| 298 | } |
| 299 | rv = req->on_json(req->acme, req->p, req->resp_hdrs, req->resp_json, req->baton); |
| 300 | } |
| 301 | else if (APR_STATUS_IS_ENOENT(rv)) { |
| 302 | /* not JSON content, fall through */ |
| 303 | processed = 0; |
| 304 | } |
| 305 | else { |
| 306 | md_log_perror(MD_LOG_MARK, MD_LOG_ERR, rv, req->p, "parsing JSON body"); |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | if (!processed && req->on_res) { |
| 311 | processed = 1; |
| 312 | rv = req->on_res(req->acme, res, req->baton); |
| 313 | } |
| 314 | |
| 315 | if (!processed) { |
| 316 | rv = APR_EINVAL; |
| 317 | md_result_printf(req->result, rv, "unable to process the response: " |
| 318 | "http-status=%d, content-type=%s", |
| 319 | res->status, apr_table_get(res->headers, "Content-Type")); |
| 320 | md_result_log(req->result, MD_LOG_ERR); |
| 321 | } |
| 322 | } |
| 323 | else if (APR_EAGAIN == (rv = inspect_problem(req, res))) { |
| 324 | /* leave req alive */ |
| 325 | return rv; |
| 326 | } |
| 327 | |
| 328 | md_acme_req_done(req, rv); |
| 329 | return rv; |
| 330 | } |
| 331 | |
| 332 | static apr_status_t acmev2_GET_as_POST_init(md_acme_req_t *req, void *baton) |
| 333 | { |
nothing calls this directly
no test coverage detected