如何在 Apache 2.2 (c++) 中响应自定义错误响应?

发布于 2024-07-16 02:12:33 字数 255 浏览 2 评论 0原文

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

我在谷歌上找到了多个消息来源说这是可能的,但没有人能告诉我如何做到。 那么是否有一些功能可以让我做类似的事情:

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

提前致谢。

I am currently trying to have my Apache module respond with custom error messages, so that a 400 for example contains additional information like "The coordinates are out of bounds".

I found multiple sources on Google saying that it is possible, but none could tell me how. So is there some function that would allow me something like:

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

?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

◇流星雨 2024-07-23 02:12:33

您可以在 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;

You can set it on the status_line member of request_rec.

snprintf(buf, buf_size, "%d Coordinate %d is out of bounds", 400, coord.x);
req->status_line = buf;
req->status = 400;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文