Ignore:
Timestamp:
Aug 25, 2008, 7:32:06 PM (13 years ago)
Author:
charles
Message:

upgrade to shttpd 1.42

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/third-party/shttpd/io_file.c

    r6349 r6644  
    2323        DBG(("put_file(%p, %d): %d bytes", (void *) stream, (int) len, n));
    2424
    25         if (n <= 0 || (rem->io.total >= (big_int_t) rem->headers_len)) {
     25        if (n <= 0 || (rem->io.total >= (big_int_t) rem->content_len)) {
    2626                (void) fstat(fd, &st);
    2727                stream->io.head = stream->headers_len =
    28                     my_snprintf(stream->io.buf,
     28                    _shttpd_snprintf(stream->io.buf,
    2929                    stream->io.size, "HTTP/1.1 %d OK\r\n"
    3030                    "Content-Length: %lu\r\nConnection: close\r\n\r\n",
    3131                    stream->conn->status, st.st_size);
    32                 stop_stream(stream);
     32                _shttpd_stop_stream(stream);
    3333        }
    3434
     
    9191
    9292void
    93 get_file(struct conn *c, struct stat *stp)
     93_shttpd_get_file(struct conn *c, struct stat *stp)
    9494{
    9595        char            date[64], lm[64], etag[64], range[64] = "";
     
    100100
    101101        if (c->mime_type.len == 0)
    102                 get_mime_type(c->ctx, c->uri, strlen(c->uri), &c->mime_type);
     102                _shttpd_get_mime_type(c->ctx, c->uri,
     103                    strlen(c->uri), &c->mime_type);
    103104        cl = (big_int_t) stp->st_size;
    104105
     
    109110                (void) lseek(c->loc.chan.fd, r1, SEEK_SET);
    110111                cl = n == 2 ? r2 - r1 + 1: cl - r1;
    111                 (void) my_snprintf(range, sizeof(range),
     112                (void) _shttpd_snprintf(range, sizeof(range),
    112113                    "Content-Range: bytes %lu-%lu/%lu\r\n",
    113114                    r1, r1 + cl - 1, (unsigned long) stp->st_size);
     
    116117
    117118        /* Prepare Etag, Date, Last-Modified headers */
    118         (void) strftime(date, sizeof(date), fmt, localtime(&current_time));
     119        (void) strftime(date, sizeof(date),
     120            fmt, localtime(&_shttpd_current_time));
    119121        (void) strftime(lm, sizeof(lm), fmt, localtime(&stp->st_mtime));
    120         (void) my_snprintf(etag, sizeof(etag), "%lx.%lx",
     122        (void) _shttpd_snprintf(etag, sizeof(etag), "%lx.%lx",
    121123            (unsigned long) stp->st_mtime, (unsigned long) stp->st_size);
    122124
     
    126128         * and exclude the headers length from it.
    127129         */
    128         c->loc.io.head = c->loc.headers_len = my_snprintf(c->loc.io.buf,
     130        c->loc.io.head = c->loc.headers_len = _shttpd_snprintf(c->loc.io.buf,
    129131            c->loc.io.size,
    130132            "HTTP/1.1 %d %s\r\n"
     
    141143        c->status = status;
    142144        c->loc.content_len = cl;
    143         c->loc.io_class = &io_file;
     145        c->loc.io_class = &_shttpd_io_file;
    144146        c->loc.flags |= FLAG_R | FLAG_ALWAYS_READY;
    145147
    146148        if (c->method == METHOD_HEAD)
    147                 stop_stream(&c->loc);
     149                _shttpd_stop_stream(&c->loc);
    148150}
    149151
    150 const struct io_class   io_file =  {
     152const struct io_class   _shttpd_io_file =  {
    151153        "file",
    152154        read_file,
Note: See TracChangeset for help on using the changeset viewer.