From 5915160c21b2fcb6674ef89baed161f280d49b1a Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Mon, 22 Sep 2014 17:48:13 -0400 Subject: [PATCH] set binary mode for binary files --- http.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/http.c b/http.c index b9f30b7..e37d560 100644 --- a/http.c +++ b/http.c @@ -406,6 +406,23 @@ int read_response(Word ipid, FILE *file, Handle dict) } + if (FileAttr & ATTR_FILETYPE) + { + switch (FileInfo.fileType) + { + case 0x04: + case 0xb0: + // text + fsettext(file); + break; + default: + fsetbinary(file); + break; + } + + } + + /* * convert the Last Modified header into a file mod date * @@ -644,8 +661,6 @@ int do_http(const char *url, URLComponents *components) { // path starts with /. - // todo -- also need to strip any ? parameters. - filename = strrchr(path + 1, '/'); if (filename) // *filename == '/' { @@ -660,7 +675,6 @@ int do_http(const char *url, URLComponents *components) if (!filename || !filename[0]) { // path/ ? - fprintf(stderr, "-O flag cannot be used with this URL.\n"); free(host); free(path); return -1;