conf_ret = http__conf_req(con, req);
req->conf_flags = HTTPD_CONF_REQ_FLAGS_PARSE_FILE_UERR; conf_ret = http__conf_req(con, req, CLEN(".html"));
static int http_fin_err_req(struct Con *con, Httpd_req_data *req){  Vstr_base *out = con->evnt->io_w;  int use_cust_err_msg = FALSE;  ASSERT(req->error_code);  ASSERT(!con->use_mpbr); /* done as part of close() */  ASSERT(con->fs && !con->fs_num);  req->content_encoding_gzip  = FALSE;  req->content_encoding_bzip2 = FALSE;    if ((req->error_code == 400) || (req->error_code == 405) ||      (req->error_code == 413) ||      (req->error_code == 500) || (req->error_code == 501))    con->keep_alive = HTTP_NON_KEEP_ALIVE;    vlg_info(vlg, "ERREQ from[$<sa:%p>] err[%03u %s]",           CON_CEVNT_SA(con), req->error_code, req->error_line);  if (req->sects->num >= 2)    http_vlg_def(con, req);  else    vlg_info(vlg, "%s", "\n");  if (req->malloc_bad)  { /* delete all input to give more room */    ASSERT(req->error_code == 500);    vstr_del(con->evnt->io_r, 1, con->evnt->io_r->len);  }  else if (((req->error_code == 400) ||            (req->error_code == 403) ||            (req->error_code == 404) ||            (req->error_code == 410) ||            (req->error_code == 500) ||            (req->error_code == 503)) && req->policy->req_err_dir->len)  { /* custom err message */    Vstr_base *fname = vstr_make_base(req->fname->conf);    size_t vhost_prefix_len = 0;    const char *fname_cstr = NULL;    struct stat64 f_stat[1];    if (!fname)      goto fail_custom_err;    /*  req->vary_star = con ? con->vary_star : FALSE;  req->vary_a    = FALSE;  req->vary_ac   = FALSE;  req->vary_ae   = FALSE;  req->vary_al   = FALSE;  req->vary_rf   = FALSE;  req->vary_ua   = FALSE;    */        if (!req->user_return_error_code)    {      req->cache_control_vs1 = NULL;      req->expires_vs1       = NULL;      req->p3p_vs1           = NULL;    }    if (req->user_return_error_code && req->direct_filename)    {      HTTPD_APP_REF_ALLVSTR(fname, req->fname);      if (!req->skip_document_root)        http_prepend_doc_root(fname, req);    }    else if (!req->policy->req_conf_dir)    {      http_app_err_file(con, req, fname, &vhost_prefix_len);      http_prepend_doc_root(fname, req);    }    else    {      int conf_ret = FALSE;      unsigned int code = req->error_code;      unsigned int ncode = 0;            http_app_err_file(con, req, fname, &vhost_prefix_len);      req->content_type_vs1 = NULL;      req->error_code = 0;      req->skip_document_root = FALSE;            SWAP_TYPE(fname, req->fname, Vstr_base *);      SWAP_TYPE(vhost_prefix_len, req->vhost_prefix_len, size_t);      conf_ret = http__conf_req(con, req);      SWAP_TYPE(fname, req->fname, Vstr_base *);      SWAP_TYPE(vhost_prefix_len, req->vhost_prefix_len, size_t);      ncode = req->error_code;      switch (code)      {        case 400: HTTPD_ERR(req, 400); break;        case 403: HTTPD_ERR(req, 403); break;        case 404: HTTPD_ERR(req, 404); break;        case 410: HTTPD_ERR(req, 410); break;        case 500: HTTPD_ERR(req, 500); break;        case 503: HTTPD_ERR(req, 503);          ASSERT_NO_SWITCH_DEF();      }      if (!conf_ret)        goto fail_custom_err;      if (ncode)        goto fail_custom_err; /* don't allow remapping errors -- loops */            if (!req->skip_document_root)        http_prepend_doc_root(fname, req);    }    fname_cstr = vstr_export_cstr_ptr(fname, 1, fname->len);        if (fname->conf->malloc_bad)      goto fail_custom_err;    ASSERT(con->fs && (con->fs->fd == -1));    if ((con->fs->fd = io_open_nonblock(fname_cstr)) == -1)      goto fail_custom_err;    if (fstat64(con->fs->fd, f_stat) == -1)    {      httpd_fin_fd_close(con);      goto fail_custom_err;    }    if (req->policy->use_public_only && !(f_stat->st_mode & S_IROTH))    {      httpd_fin_fd_close(con);      goto fail_custom_err;    }    if (!S_ISREG(f_stat->st_mode))    {      httpd_fin_fd_close(con);      goto fail_custom_err;    }    con->fs_off = 0;    con->fs_num = 1;    con->fs->off = 0;    con->fs->len = f_stat->st_size;        if (!req->ver_0_9)      httpd__try_fd_encoding(con, req, f_stat, fname);        con->use_mmap = FALSE;    if (!req->head_op)      httpd_serv_call_mmap(con, req, con->fs);    req->error_len   = con->fs->len;    use_cust_err_msg = TRUE;       fail_custom_err:    fname->conf->malloc_bad = FALSE;    vstr_free_base(fname);  }  if (!use_cust_err_msg)    req->content_type_vs1 = NULL;  if (!req->ver_0_9)  { /* use_range is dealt with inside */    http_app_def_hdrs(con, req, req->error_code, req->error_line,                      httpd_opts->beg_time, "text/html", TRUE, req->error_len);        if (req->error_code == 416)      http_app_hdr_fmt(out, "Content-Range", "%s */%ju", "bytes",                          (VSTR_AUTOCONF_uintmax_t)req->f_stat->st_size);    if (req->error_code == 401)      http_app_hdr_fmt(out, "WWW-Authenticate",                       "Basic realm=\"$<vstr.all:%p>\"",                       req->policy->auth_realm);        if ((req->error_code == 405) || (req->error_code == 501))      HTTP_APP_HDR_CONST_CSTR(out, "Allow", "GET, HEAD, OPTIONS, TRACE");        if ((req->error_code == 301) || (req->error_code == 302) ||        (req->error_code == 303) || (req->error_code == 307))    { /* make sure we haven't screwed up and allowed response splitting */      Vstr_base *tmp = req->fname;            ASSERT(!vstr_srch_cstr_chrs_fwd(tmp, 1, tmp->len, HTTP_EOL));      http_app_hdr_vstr(out, "Location",                           tmp, 1, tmp->len, VSTR_TYPE_ADD_ALL_BUF);    }        if (req->user_return_error_code || use_cust_err_msg)      http_app_hdrs_url(con, req);    if (use_cust_err_msg)      http_app_hdrs_file(con, req);        http_app_end_hdrs(out);  }  if (!req->head_op)  {    Vstr_base *loc = req->fname;    switch (req->error_code)    {      case 301: vstr_add_fmt(out, out->len, CONF_MSG_FMT_301,                             CONF_MSG__FMT_301_BEG,                             loc, (size_t)1, loc->len, VSTR_TYPE_ADD_ALL_BUF,                             CONF_MSG__FMT_30x_END); break;      case 302: vstr_add_fmt(out, out->len, CONF_MSG_FMT_302,                             CONF_MSG__FMT_302_BEG,                             loc, (size_t)1, loc->len, VSTR_TYPE_ADD_ALL_BUF,                             CONF_MSG__FMT_30x_END); break;      case 303: vstr_add_fmt(out, out->len, CONF_MSG_FMT_303,                             CONF_MSG__FMT_303_BEG,                             loc, (size_t)1, loc->len, VSTR_TYPE_ADD_ALL_BUF,                             CONF_MSG__FMT_30x_END); break;      case 307: vstr_add_fmt(out, out->len, CONF_MSG_FMT_307,                             CONF_MSG__FMT_307_BEG,                             loc, (size_t)1, loc->len, VSTR_TYPE_ADD_ALL_BUF,                             CONF_MSG__FMT_30x_END); break;      default:        if (use_cust_err_msg)        {          if (con->use_mmap && !vstr_mov(con->evnt->io_w, con->evnt->io_w->len,                                         req->f_mmap, 1, req->f_mmap->len))            return (http_con_close_cleanup(con, req));          vlg_dbg3(vlg, "ERROR CUSTOM-404 REPLY:\n$<vstr.all:%p>\n", out);                    if (out->conf->malloc_bad)            return (http_con_close_cleanup(con, req));            return (http_fin_fd_req(con, req));        }        /* default internal error message */        assert(req->error_len < SIZE_MAX);        vstr_add_ptr(out, out->len, req->error_msg, req->error_len);    }  }    vlg_dbg3(vlg, "ERROR REPLY:\n$<vstr.all:%p>\n", out);  if (out->conf->malloc_bad)    return (http_con_cleanup(con, req));    return (http_fin_req(con, req));}