ancruna / mongoose

Automatically exported from code.google.com/p/mongoose
MIT License
0 stars 0 forks source link

Feature Request: add a public mg_send_file function #256

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am using Mongoose from within my application. I am composing my HTTP reply 
messages for most requests, but I also have to do file transfer. I would like 
to use the function handle_file_request to send a file to the client (to avoid 
code duplication), but this function is static. Would it be possible to add a 
public mg_send_file function, that sends a file to the client?

I tried the following code, which does the job:

void mg_send_file(struct mg_connection *conn, const char *path)
{
    struct mgstat st;
    if (mg_stat(path, &st) != 0)
    {
        send_http_error(conn, 404, "Not Found", "%s", "File not found");

    }
    handle_file_request(conn, path, &st);
}

Could this be added to Mongoose?

Original issue reported on code.google.com by borkh...@gmail.com on 1 Jun 2011 at 7:43

GoogleCodeExporter commented 9 years ago
Submitted 
https://code.google.com/p/mongoose/source/detail?r=4fd448b976dd518476cd5458f7a08
38d224f4bde#, thank you.

Original comment by valenok on 19 Jun 2011 at 4:47