set binary mode for binary files

This commit is contained in:
Kelvin Sherlock 2014-09-22 17:48:13 -04:00
parent a83502fa20
commit 5915160c21
1 changed files with 17 additions and 3 deletions

20
http.c
View File

@ -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;