我目前正在尝试让我的 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/