Patch for HTTP.c (version 2.09a)

joe@athena.mit.edu
Tue, 31 Aug 93 02:54:15 -0400


Here is a patch to HTTP.c that uses the suffix database to figure out the
type of the incoming file if it is not HTTP/1.0.

*** ../../Library/Implementation/HTTP.c Fri Jun 18 10:30:01 1993
--- HTTP.c Sat Aug 28 20:21:04 1993
***************
*** 40,45 ****
--- 40,46 ----
#include "HTMIME.h"
#include "HTML.h" /* SCW */
#include "HTInit.h" /* SCW */
+ #include "HTFile.h"

struct _HTStream {
HTStreamClass * isa; /* all we need to know */
***************
*** 89,94 ****
--- 90,97 ----
BOOL had_header = NO; /* Have we had at least one header? */
char * line_buffer = NULL;
BOOL extensions = YES; /* Assume good HTTP server */
+ HTAtom * encoding = HTAtom_for("7bit");
+ int length;
if (!arg) return -3; /* Bad if no name sepcified */
if (!*arg) return -2; /* Bad if name had zero length */

***************
*** 225,236 ****
{

/* Get numeric status etc */
-
- int length = 0;
BOOL end_of_file = NO;
! HTAtom * encoding = HTAtom_for("7bit");
int buffer_length = INIT_LINE_SIZE; /* Why not? */
!
line_buffer = (char *) malloc(buffer_length * sizeof(char));
if (!line_buffer) outofmem(__FILE__, "HTLoadHTTP");

--- 228,238 ----
{

/* Get numeric status etc */
BOOL end_of_file = NO;
!
int buffer_length = INIT_LINE_SIZE; /* Why not? */
!
! length = 0;
line_buffer = (char *) malloc(buffer_length * sizeof(char));
if (!line_buffer) outofmem(__FILE__, "HTLoadHTTP");

***************
*** 312,320 ****
&server_status);

if (fields < 2) { /* HTTP0 reply */
! format_in = WWW_HTML;
start_of_data = line_buffer; /* reread whole reply */
if (eol) *eol = '\n'; /* Reconstitute buffer */

} else { /* Ful HTTP reply */

--- 314,324 ----
&server_status);

if (fields < 2) { /* HTTP0 reply */
! format_in = HTFileFormat(arg, &encoding);
start_of_data = line_buffer; /* reread whole reply */
if (eol) *eol = '\n'; /* Reconstitute buffer */
+ if (format_in == WWW_BINARY)
+ format_in = WWW_HTML;

} else { /* Ful HTTP reply */

***************
*** 381,389 ****
** We have to remember the end of the first buffer we just read
*/
if (format_in != WWW_HTML) {
! (*target->isa->put_string)(target, start_of_data);
HTCopy(s, target);
-
} else { /* ascii text with CRLFs :-( */
{
char * p;
--- 385,395 ----
** We have to remember the end of the first buffer we just read
*/
if (format_in != WWW_HTML) {
! if (encoding == HTAtom_for("7bit"))
! (*target->isa->put_string)(target, start_of_data);
! else
! (*target->isa->put_block)(target, start_of_data, length);
HTCopy(s, target);
} else { /* ascii text with CRLFs :-( */
{
char * p;