From 13550e9e3e09273278950435abb392781a98bb06 Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Thu, 11 May 2017 17:14:01 +0200 Subject: Tidy up some things. --- content/fetchers/httplib_kolibri.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'content') diff --git a/content/fetchers/httplib_kolibri.c b/content/fetchers/httplib_kolibri.c index 0f9bcb7c4..6800cab13 100644 --- a/content/fetchers/httplib_kolibri.c +++ b/content/fetchers/httplib_kolibri.c @@ -85,16 +85,16 @@ void remove_from_poll(struct http_msg *donehttp) { bool init_fetcher(lwc_string *scheme) { bool supported_scheme; assert(lwc_string_isequal(scheme, corestring_lwc_http, &supported_scheme) == lwc_error_ok); - kolibri_http_init(); - /* if(supported_scheme) { */ - /* if(kolibri_http_init() == 0) */ - /* debug_board_printf("[INFO] Loaded http.obj library successfully.\n"); */ - /* else { */ - /* debug_board_printf("[ERROR] Could not load http.obj library.\n"); */ - /* return false; */ - /* } */ - /* } */ + LOG("Initializing http library!"); + debug_board_printf("fetcher_init: Initializing http library!\n"); + if(kolibri_http_init() == 0) + LOG("[INFO] Loaded http.obj library successfully.\n"); + else { + LOG("[ERROR] Could not load http.obj library.\n"); + assert(0 && 1); + return false; + } return supported_scheme; } @@ -138,14 +138,17 @@ void *setup_fetch(struct fetch *parent_fetch, struct nsurl *url, request = http_get_asm(nsurl_access(url), NULL, 0, *headers); } - LOG("Address of request : 0x%x", request); - assert(request != NULL); - if(request == NULL) { - LOG("[ERROR] Cannot allocate more memory for http library handle creation."); + LOG("Failed to allocate http buffer. Could be multiple reasons for failure (like DNS resolution)", request); return NULL; } + /* This assert is tricky beacause the http library may fail when it fails to resolve the hostname. + There is no sane way to understand that the hostname is wrong or needs to be fixed. + assert leads to a crash for no reason. Disabling it, and the code should handle this from now. + Returning NuLL from here should just force a BadURL to the user. + */ + struct httpfetcher *newfetcher = (struct httpfetcher *) malloc(sizeof(struct httpfetcher)); assert(newfetcher); -- cgit v1.2.3