clean up/bugfix deflate logic and log messages

svn:r2359
This commit is contained in:
Nick Mathewson 2004-09-21 18:09:38 +00:00
parent d977677aa8
commit c20b24c952
2 changed files with 7 additions and 5 deletions

View File

@ -581,7 +581,8 @@ directory_handle_command_get(connection_t *conn, char *headers,
} }
if(!strcmp(url,"/") || !strcmp(url,"/dir.z")) { /* directory fetch */ if(!strcmp(url,"/") || !strcmp(url,"/dir.z")) { /* directory fetch */
dlen = dirserv_get_directory(&cp, !strcmp(url,"/dir.z")); int deflated = !strcmp(url,"/dir.z");
dlen = dirserv_get_directory(&cp, deflated);
if(dlen == 0) { if(dlen == 0) {
log_fn(LOG_WARN,"My directory is empty. Closing."); log_fn(LOG_WARN,"My directory is empty. Closing.");
@ -589,12 +590,13 @@ directory_handle_command_get(connection_t *conn, char *headers,
return 0; return 0;
} }
log_fn(LOG_DEBUG,"Dumping directory to client."); log_fn(LOG_DEBUG,"Dumping %sdirectory to client.",
deflated?"deflated ":"");
format_rfc1123_time(date, time(NULL)); format_rfc1123_time(date, time(NULL));
snprintf(tmp, sizeof(tmp), "HTTP/1.0 200 OK\r\nDate: %s\r\nContent-Length: %d\r\nContent-Type: text/plain\r\nContent-Encoding: %s\r\n\r\n", snprintf(tmp, sizeof(tmp), "HTTP/1.0 200 OK\r\nDate: %s\r\nContent-Length: %d\r\nContent-Type: text/plain\r\nContent-Encoding: %s\r\n\r\n",
date, date,
(int)dlen, (int)dlen,
strcmp(url,"/dir.z")?"identity":"deflate"); deflated?"deflate":"identity");
connection_write_to_buf(tmp, strlen(tmp), conn); connection_write_to_buf(tmp, strlen(tmp), conn);
connection_write_to_buf(cp, strlen(cp), conn); connection_write_to_buf(cp, strlen(cp), conn);
return 0; return 0;

View File

@ -678,8 +678,8 @@ size_t dirserv_get_directory(const char **directory, int deflate)
} else { } else {
log(LOG_INFO,"Directory still clean, reusing."); log(LOG_INFO,"Directory still clean, reusing.");
} }
*directory = deflate ? the_directory : the_directory_z; *directory = deflate ? the_directory_z : the_directory;
return deflate ? the_directory_len : the_directory_z_len; return deflate ? the_directory_z_len : the_directory_len;
} }
/** /**