LOCKING: must be called with lock taken
| 374 | |
| 375 | // LOCKING: must be called with lock taken |
| 376 | char * |
| 377 | HttpBodyFactory::fabricate(StrList *acpt_language_list, StrList *acpt_charset_list, const char *type, HttpTransact::State *context, |
| 378 | int64_t *buffer_length_return, const char **content_language_return, const char **content_charset_return, |
| 379 | const char **set_return) |
| 380 | { |
| 381 | char *buffer; |
| 382 | const char *pType = context->txn_conf->body_factory_template_base; |
| 383 | const char *set; |
| 384 | char template_base[PATH_NAME_MAX]; |
| 385 | |
| 386 | if (set_return) { |
| 387 | *set_return = "???"; |
| 388 | } |
| 389 | *content_language_return = nullptr; |
| 390 | *content_charset_return = nullptr; |
| 391 | |
| 392 | Dbg(dbg_ctl_body_factory, "calling fabricate(type '%s')", type); |
| 393 | *buffer_length_return = 0; |
| 394 | |
| 395 | // if error body suppressed, return NULL |
| 396 | if (is_response_suppressed(context)) { |
| 397 | Dbg(dbg_ctl_body_factory, " error suppression enabled, returning NULL template"); |
| 398 | return nullptr; |
| 399 | } |
| 400 | // if custom error pages are disabled, return NULL |
| 401 | if (!enable_customizations) { |
| 402 | Dbg(dbg_ctl_body_factory, " customization disabled, returning NULL template"); |
| 403 | return nullptr; |
| 404 | } |
| 405 | |
| 406 | // what set should we use (language target if enable_customizations == 2) |
| 407 | if (enable_customizations == 2) { |
| 408 | set = determine_set_by_language(acpt_language_list, acpt_charset_list); |
| 409 | } else if (enable_customizations == 3) { |
| 410 | set = determine_set_by_host(context); |
| 411 | } else if (is_response_body_precluded(context->http_return_code)) { |
| 412 | return nullptr; |
| 413 | } else { |
| 414 | set = "default"; |
| 415 | } |
| 416 | if (set_return) { |
| 417 | *set_return = set; |
| 418 | } |
| 419 | |
| 420 | HttpBodyTemplate *t = nullptr; |
| 421 | HttpBodySet *body_set = nullptr; |
| 422 | if (pType != nullptr && 0 != *pType && 0 != strncmp(pType, "NONE", 4)) { |
| 423 | snprintf(template_base, sizeof(template_base), "%s_%s", pType, type); |
| 424 | t = find_template(set, template_base, &body_set); |
| 425 | // Check for default alternate. |
| 426 | if (t == nullptr) { |
| 427 | snprintf(template_base, sizeof(template_base), "%s_default", pType); |
| 428 | t = find_template(set, template_base, &body_set); |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | // Check for base customizations if specializations didn't work. |
| 433 | if (t == nullptr) { |
nothing calls this directly
no test coverage detected