Two
Two

Reputation:

How to respond with a custom error response in Apache 2.2 (c++)?

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.

Upvotes: 0

Views: 521

Answers (1)

p00ya
p00ya

Reputation: 3709

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;

Upvotes: 1

Related Questions