Question

I have written an Apache module that handles receiving a file from a client. I now want to send a response back to the client. I want the response to contain a string representing the file path to the file sent to the module. Since I am new to writing Apache modules I am unsure as to whether there is a response struct of some sort I need to use or if everything I need is in the request_rec passed into my handler. I noticed that ap_rprintf sends data to the client. Should I just use that? And if so, how is it sent back to the client (i.e. how can my client extract the string from things sent back to it)?

Thanks!

Edit: I just stumbled across apr_socket_send() but I don't know if that works in this case. request_rec stores the connection, so could I create a socket to the client and send the data back that way?

Was it helpful?

Solution

Have you checked out the source code for mod_example?

Basically:

r->content_type = "text/html";
ap_send_http_header(r);
ap_rputs(DOCTYPE_HTML_3_2, r);
ap_rputs("<HTML>\n", r);
...
ap_rprintf(r, "Stuff that you want to send in the body");
...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top