This commit is contained in:
Christian Grothoff
2010-06-13 09:05:57 +00:00
parent a90ce65429
commit 0b23a93cb2
+10 -2
View File
@@ -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);
}