cache memory ID

This commit is contained in:
Kelvin Sherlock 2012-08-26 17:54:18 -04:00
parent 1d8bed53a7
commit ab26d38790

17
http.c
View File

@ -429,6 +429,7 @@ static int do_http_1_1(
Handle dict; Handle dict;
DictionaryEnumerator e; DictionaryEnumerator e;
Word cookie; Word cookie;
Word MyID = MMStartUp();
int ok; int ok;
char *cp; char *cp;
@ -437,7 +438,7 @@ static int do_http_1_1(
// html headers. // html headers.
// (not really needed until 1.1) // (not really needed until 1.1)
dict = DictionaryCreate(MMStartUp(), 2048); dict = DictionaryCreate(MyID, 2048);
length = components->host.length; length = components->host.length;
cp = url + components->host.location; cp = url + components->host.location;
@ -497,19 +498,22 @@ static int do_http_1_1(
DisposeHandle(dict); DisposeHandle(dict);
dict = NULL; dict = NULL;
dict = DictionaryCreate(MMStartUp(), 2048); dict = DictionaryCreate(MyID, 2048);
ok = parseHeaders(ipid, file, dict); ok = parseHeaders(ipid, file, dict);
// todo -- check the headers for content length, transfer-encoding. // todo -- check the headers for content length, transfer-encoding.
// //
#if 0
cookie = 0; cookie = 0;
while ((cookie = DictionaryEnumerate(dict, &e, cookie))) while ((cookie = DictionaryEnumerate(dict, &e, cookie)))
{ {
s16_debug_printf("%.*s -> %.*s", s16_debug_printf("%.*s -> %.*s",
e.keySize, e.key, e.valueSize, e.value); e.keySize, e.key, e.valueSize, e.value);
} }
#endif
if (ok == 200) if (ok == 200)
{ {
if (!flags._I) if (!flags._I)
@ -591,6 +595,13 @@ int do_http(const char *url, URLComponents *components)
} }
// todo -- write to a tmp file rather than the named file.
// this will allow things like If-Modified-Since or If-None-Match
// so it only updates if changed.
// or -C continue to append
// -N -- if-modified-since header.
if (filename) if (filename)
{ {
file = fopen(filename, "w"); file = fopen(filename, "w");