mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-25 04:09:31 +03:00
better
This commit is contained in:
@@ -131,7 +131,11 @@ http_ahc (void *cls,
|
||||
}
|
||||
*ptr = NULL; /* reset when done */
|
||||
|
||||
file = fopen (&url[1], "rb");
|
||||
if ( (0 == stat (url, &buf)) &&
|
||||
(S_ISREG (buf.st_mode)) )
|
||||
file = fopen (&url[1], "rb");
|
||||
else
|
||||
file = NULL;
|
||||
if (file == NULL)
|
||||
{
|
||||
response = MHD_create_response_from_data (strlen (EMPTY_PAGE),
|
||||
@@ -142,11 +146,15 @@ http_ahc (void *cls,
|
||||
}
|
||||
else
|
||||
{
|
||||
stat (url, &buf);
|
||||
response = MHD_create_response_from_callback (buf.st_size, 32 * 1024, /* 32k PAGE_NOT_FOUND size */
|
||||
&file_reader, file,
|
||||
(MHD_ContentReaderFreeCallback)
|
||||
& fclose);
|
||||
if (response == NULL)
|
||||
{
|
||||
fclose (file);
|
||||
return MHD_NO;
|
||||
}
|
||||
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
|
||||
MHD_destroy_response (response);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user