Closed GoogleCodeExporter closed 9 years ago
Please use the current version, the API is quite similar to SHTTPD one.
Binary data must be sent using mg_write() function.
Note that your example has a bug: you are sending HTTP headers in every callback
invokation. This is incorrect. When the number of bytes to output is large, the
callback is invoked several times, and you need to send headers only in first
invokation. Use arg->state to figure out, do you need to send headers or not.
However, I highly recommend switching to Mongoose. In Mongoose, the callback is
invoked only once, and you do not need to track states, and your code can be
rewritten as:
static void send_image(struct mg_connection *conn,
const struct mg_request_info *ri,
void *user_data)
{
mg_printf(conn, "HTTP/1.1 200 OK\r\n"
"Server: SlingIt\r\n"
"Content-Type: image/jpeg\r\n"
"Content-Length: %d\r\n\r\n", iContentLength);
mg_write(conn, cImage, sImageInfo.iFileSize);
}
Original comment by valenok
on 10 Dec 2008 at 9:58
Ok.
Thanks for the quick responce.
I'll update my app to use the new version then.
Original comment by matthewj...@googlemail.com
on 10 Dec 2008 at 11:54
Original issue reported on code.google.com by
matthewj...@googlemail.com
on 10 Dec 2008 at 8:21