diff options
author | Guillaume Cottenceau <gc@mandriva.com> | 2001-02-20 15:49:20 +0000 |
---|---|---|
committer | Guillaume Cottenceau <gc@mandriva.com> | 2001-02-20 15:49:20 +0000 |
commit | 616e5e677e36cd6c3909a6e22fd130e467cf555c (patch) | |
tree | 774e9e7ec0c0ea2ab54da70c91c648c5d13f919d | |
parent | d71f1b5bcbf6552d3a7531e5f843db4dd5fd2d9f (diff) | |
download | drakx-616e5e677e36cd6c3909a6e22fd130e467cf555c.tar drakx-616e5e677e36cd6c3909a6e22fd130e467cf555c.tar.gz drakx-616e5e677e36cd6c3909a6e22fd130e467cf555c.tar.bz2 drakx-616e5e677e36cd6c3909a6e22fd130e467cf555c.tar.xz drakx-616e5e677e36cd6c3909a6e22fd130e467cf555c.zip |
for HTTP installs, make use of Content-Length when available, to display progressbar
-rw-r--r-- | mdk-stage1/network.c | 8 | ||||
-rw-r--r-- | mdk-stage1/url.c | 10 | ||||
-rw-r--r-- | mdk-stage1/url.h | 2 |
3 files changed, 14 insertions, 6 deletions
diff --git a/mdk-stage1/network.c b/mdk-stage1/network.c index 47436a940..9a07fa34a 100644 --- a/mdk-stage1/network.c +++ b/mdk-stage1/network.c @@ -761,7 +761,7 @@ enum return_type http_prepare(void) do { char location_full[500]; - int fd; + int fd, size; results = ask_from_entries_auto("Please enter the name or IP address of the HTTP server, " "and the directory containing the " DISTRIB_NAME " Distribution.", @@ -774,7 +774,7 @@ enum return_type http_prepare(void) log_message("HTTP: trying to retrieve %s", location_full); - fd = http_download_file(answers[0], location_full); + fd = http_download_file(answers[0], location_full, &size); if (fd < 0) { log_message("HTTP: error %d", fd); if (fd == FTPERR_FAILED_CONNECT) @@ -784,8 +784,10 @@ enum return_type http_prepare(void) results = RETURN_BACK; continue; } + + log_message("HTTP: size of download %d bytes", size); - results = load_ramdisk_fd(fd, 0); + results = load_ramdisk_fd(fd, size); method_name = strdup("http"); sprintf(location_full, "http://%s/%s", answers[0], answers[1]); diff --git a/mdk-stage1/url.c b/mdk-stage1/url.c index 9781d281d..0f919812b 100644 --- a/mdk-stage1/url.c +++ b/mdk-stage1/url.c @@ -408,7 +408,7 @@ int ftp_end_data_command(int sock) } -int http_download_file(char * hostname, char * remotename) +int http_download_file(char * hostname, char * remotename, int * size) { char * buf; struct timeval timeout; @@ -420,6 +420,7 @@ int http_download_file(char * hostname, char * remotename) int rc; struct sockaddr_in destPort; fd_set readSet; + char * header_content_length = "Content-Length: "; if ((rc = get_host_address(hostname, &serverAddress))) return rc; @@ -508,6 +509,11 @@ int http_download_file(char * hostname, char * remotename) *end = ' '; } } - + + if ((buf = strstr(headers, header_content_length))) + *size = charstar_to_int(buf + strlen(header_content_length)); + else + *size = 0; + return sock; } diff --git a/mdk-stage1/url.h b/mdk-stage1/url.h index 45d9bd6f6..5a59bd814 100644 --- a/mdk-stage1/url.h +++ b/mdk-stage1/url.h @@ -26,7 +26,7 @@ int ftp_open_connection(char * host, char * name, char * password, char * proxy) int ftp_start_download(int sock, char * remotename, int * size); int ftp_end_data_command(int sock); -int http_download_file(char * hostname, char * remotename); +int http_download_file(char * hostname, char * remotename, int * size); #define FTPERR_BAD_SERVER_RESPONSE -1 |