Merge pull request #123 from kiwix/fix_crash

Fix crash
This commit is contained in:
Matthieu Gautier 2017-12-04 16:04:08 +00:00 committed by GitHub
commit c91285fc29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 9 deletions

View File

@ -724,17 +724,23 @@ static int accessHandlerCallback(void* cls,
size_t* upload_data_size,
void** ptr)
{
if (isVerbose.load() ) {
printf("======================\n");
printf("Requesting : \n");
printf("full_url : %s\n", url);
}
RequestContext request(connection, rootLocation, url, method, version);
if (isVerbose.load() ) {
request.print_debug_info();
}
/* Unexpected method */
if (request.get_method() != RequestMethod::GET && request.get_method() != RequestMethod::POST) {
printf("Reject request because of unhandled request method.\n");
printf("----------------------\n");
return MHD_NO;
}
if (isVerbose.load()) {
printf("======================\n");
request.print_debug_info();
}
/* Prepare the variables */
struct MHD_Response* response;
request.httpResponseCode = request.has_range() ? MHD_HTTP_PARTIAL_CONTENT : MHD_HTTP_OK;

View File

@ -122,16 +122,14 @@ int RequestContext::fill_argument(void *__this, enum MHD_ValueKind kind,
const char *key, const char* value)
{
RequestContext *_this = static_cast<RequestContext*>(__this);
_this->arguments[key] = value;
_this->arguments[key] = value == nullptr ? "" : value;
return MHD_YES;
}
void RequestContext::print_debug_info() {
printf("Requesting : \n");
printf("full_url : %s\n", full_url.c_str());
printf("method : %s (%d)\n", method==RequestMethod::GET ? "GET" :
method==RequestMethod::POST ? "POST" :
"OTHER", method);
"OTHER", (int)method);
printf("version : %s\n", version.c_str());
printf("headers :\n");
for (auto it=headers.begin(); it!=headers.end(); it++) {