c++ - 如何在 Apache 2.2 (c++) 中使用自定义错误响应进行响应?

标签 c++ apache custom-error-pages

我目前正在尝试让我的 Apache 模块响应自定义错误消息,例如 400 包含附加信息,例如“坐标超出范围”。

我在 Google 上发现多个来源都说这是可能的,但没有人能告诉我如何做到。那么有没有一些功能可以让我做这样的事情:

return apache_error( 400, "Coordinate %d is out of bounds.", coord.x );

?

提前致谢。

最佳答案

可以在request_rec的status_line成员上设置。

snprintf(buf, buf_size, "%d Coordinate %d is out of bounds", 400, coord.x);
req->status_line = buf;
req->status = 400;

关于c++ - 如何在 Apache 2.2 (c++) 中使用自定义错误响应进行响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/709550/

相关文章:

asp.net - 在 ASP.Net 网站上实现自定义错误页面

asp.net - ResponseMode ="File"不工作

c++ - 在 C++ 程序中包含 C 头文件

c++ - 如何编写一个程序,可以像 Ubuntu 中的命令一样添加信息(例如 : program -u "Hello World")

apache - PERL Dancer2、cgi 调度程序和 uri_for 助手

java - 压缩后不保留文件权限

c++ - 运算符重载器没有影响

c++ - 将类实例和方法作为参数传递给 C++ 中的另一个函数

java - 使用 Java Apache HttpClient 的 HTTP SSL 代理

tomcat - 如何将 servlet 响应发送到 web.xml 配置的错误页面