gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 08:33:39 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com