3
0
Fork 0

+ bug fix, first time the webserver really runs

small_fixes
kelson42 16 years ago
parent 75995a8b2d
commit 4528502269

@ -42,7 +42,7 @@ static int accessHandlerCallback(void *cls,
/* Prepare the variable */ /* Prepare the variable */
zim::Article article; zim::Article article;
struct MHD_Response * response; struct MHD_Response *response;
string content; string content;
string mimeType; string mimeType;
unsigned int contentLength = 0; unsigned int contentLength = 0;
@ -106,12 +106,6 @@ static int accessHandlerCallback(void *cls,
/* Get the content mime-type */ /* Get the content mime-type */
mimeType = article.getMimeType(); mimeType = article.getMimeType();
cout << "mimeType: " << mimeType << endl; cout << "mimeType: " << mimeType << endl;
/* Snapshot if text/html */
if (mimeType == "text/html") {
cout << "Snapshot: " << content.substr(0, 42) << endl;
mimeType = mimeType + "; charset=utf-8";
}
} else { } else {
/* The found article is not the good one */ /* The found article is not the good one */
content=""; content="";
@ -124,7 +118,7 @@ static int accessHandlerCallback(void *cls,
/* Mutext unlock */ /* Mutext unlock */
pthread_mutex_unlock(&lock); pthread_mutex_unlock(&lock);
/* clear context pointer */ /* clear context pointer */
*ptr = NULL; *ptr = NULL;
@ -132,7 +126,7 @@ static int accessHandlerCallback(void *cls,
response = MHD_create_response_from_data(contentLength, response = MHD_create_response_from_data(contentLength,
(void *)content.data(), (void *)content.data(),
MHD_NO, MHD_NO,
MHD_NO); MHD_YES);
/* Specify the mime type */ /* Specify the mime type */
MHD_add_response_header(response, "Content-Type", mimeType.c_str()); MHD_add_response_header(response, "Content-Type", mimeType.c_str());
@ -142,6 +136,7 @@ static int accessHandlerCallback(void *cls,
MHD_HTTP_OK, MHD_HTTP_OK,
response); response);
MHD_destroy_response(response); MHD_destroy_response(response);
return ret; return ret;
} }

Loading…
Cancel
Save