httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Sutton <p...@ukweb.com>
Subject set_content_length() wrong
Date Wed, 03 Jul 1996 07:29:57 GMT
Gallotta Cristiano <crigal@pantelleria.dia.unisa.it> sent a report of
the following problem to me at Apache Week:
> Don't you think you should assign clength instead of finfo.st_size in
> the following ....
>
>  int set_content_length (request_rec *r, long clength)
> {
>    char ts[MAX_STRING_LEN];
>
>    sprintf (ts, "%ld", (long)r->finfo.st_size);
>    table_set (r->headers_out, "Content-length", pstrdup (r->pool, ts));
>    return 0;
> }

It looks wrong to me! set_content_length is called only once in Apache,
as:

     if ((errstatus = set_content_length (r, r->finfo.st_size))

in http_core.c (thus clength is set to the same value that is finally
assigned to the Content-length). But since set_content_length is available
to modules, this could be a problem if module authors start using it.

The fix patch is:

*** http_protocol.c.dist	Wed Jul  3 09:02:03 1996
--- http_protocol.c	Wed Jul  3 09:01:51 1996
***************
*** 151,157 ****
  {
      char ts[MAX_STRING_LEN];

!     sprintf (ts, "%ld", (long)r->finfo.st_size);
      table_set (r->headers_out, "Content-length", pstrdup (r->pool, ts));
      return 0;
  }
--- 151,157 ----
  {
      char ts[MAX_STRING_LEN];

!     sprintf (ts, "%ld", clength);
      table_set (r->headers_out, "Content-length", pstrdup (r->pool, ts));
      return 0;
  }

--
Paul Sutton
UK Web Ltd





Mime
View raw message