📄 thttpd_patch
字号:
+ }+ }+ } @@ -3840,7 +3983,24 @@ { #ifdef HAVE_GETNAMEINFO static char str[200];+ static smart_str httpd_ntoa_buf;++ if (saP->sa_in.sin_family == AF_INET) {+ unsigned long n = ntohl(saP->sa_in.sin_addr.s_addr); + httpd_ntoa_buf.len = 0;+ smart_str_append_long(&httpd_ntoa_buf, (n >> 24));+ smart_str_appendc(&httpd_ntoa_buf, '.');+ smart_str_append_long(&httpd_ntoa_buf, (n >> 16) & 255);+ smart_str_appendc(&httpd_ntoa_buf, '.');+ smart_str_append_long(&httpd_ntoa_buf, (n >> 8) & 255);+ smart_str_appendc(&httpd_ntoa_buf, '.');+ smart_str_append_long(&httpd_ntoa_buf, (n >> 0) & 255);+ smart_str_0(&httpd_ntoa_buf);++ return httpd_ntoa_buf.c;+ }+ if ( getnameinfo( &saP->sa, sockaddr_len( saP ), str, sizeof(str), 0, 0, NI_NUMERICHOST ) != 0 ) { str[0] = '?';diff -ur thttpd-2.21b/libhttpd.h thttpd-2.21b-cool/libhttpd.h--- thttpd-2.21b/libhttpd.h Tue Apr 24 00:36:50 2001+++ thttpd-2.21b-cool/libhttpd.h Sat Sep 20 14:43:20 2003@@ -69,6 +69,8 @@ char* server_hostname; int port; char* cgi_pattern;+ char* php_pattern;+ char* phps_pattern; char* charset; char* cwd; int listen4_fd, listen6_fd;@@ -80,6 +82,8 @@ char* url_pattern; char* local_pattern; int no_empty_referers;+ size_t log_date_len;+ char log_date[100]; } httpd_server; /* A connection. */@@ -88,6 +92,7 @@ httpd_server* hs; httpd_sockaddr client_addr; char* read_buf;+ char read_buf_is_mmap; int read_size, read_idx, checked_idx; int checked_state; int method;@@ -132,11 +137,12 @@ int got_range; int tildemapped; /* this connection got tilde-mapped */ off_t init_byte_loc, end_byte_loc;- int keep_alive;+ int keep_alive, do_keep_alive; int should_linger; struct stat sb; int conn_fd; char* file_address;+ char read_body_into_mem; } httpd_conn; /* Methods. */@@ -168,7 +174,8 @@ char* hostname, httpd_sockaddr* sa4P, httpd_sockaddr* sa6P, int port, char* cgi_pattern, char* charset, char* cwd, int no_log, FILE* logfp, int no_symlink, int vhost, int global_passwd, char* url_pattern,- char* local_pattern, int no_empty_referers );+ char* local_pattern, int no_empty_referers, char* php_pattern,+ char* phps_pattern ); /* Change the log file. */ extern void httpd_set_logfp( httpd_server* hs, FILE* logfp );@@ -229,6 +236,8 @@ ** If you don't have a current timeval handy just pass in 0. */ extern void httpd_close_conn( httpd_conn* hc, struct timeval* nowP );+void httpd_complete_request( httpd_conn* hc, struct timeval* nowP);+int httpd_request_reset(httpd_conn* hc,int ); /* Call this to de-initialize a connection struct and *really* free the ** mallocced strings.diff -ur thttpd-2.21b/mime_encodings.txt thttpd-2.21b-cool/mime_encodings.txt--- thttpd-2.21b/mime_encodings.txt Wed May 10 03:22:28 2000+++ thttpd-2.21b-cool/mime_encodings.txt Sat Sep 20 14:43:20 2003@@ -3,6 +3,6 @@ # A list of file extensions followed by the corresponding MIME encoding. # Extensions not found in the table proceed to the mime_types table. -Z x-compress-gz x-gzip+Z compress+gz gzip uu x-uuencodediff -ur thttpd-2.21b/mime_types.txt thttpd-2.21b-cool/mime_types.txt--- thttpd-2.21b/mime_types.txt Sat Apr 14 04:53:30 2001+++ thttpd-2.21b-cool/mime_types.txt Sat Sep 20 14:43:20 2003@@ -1,135 +1,138 @@-# mime_types.txt-#-# A list of file extensions followed by the corresponding MIME type.-# Extensions not found in the table are returned as text/plain.--html text/html; charset=%s-htm text/html; charset=%s-txt text/plain; charset=%s-rtx text/richtext-etx text/x-setext-tsv text/tab-separated-values-css text/css-xml text/xml-dtd text/xml--gif image/gif-jpg image/jpeg-jpeg image/jpeg-jpe image/jpeg-jfif image/jpeg-tif image/tiff-tiff image/tiff-pbm image/x-portable-bitmap-pgm image/x-portable-graymap-ppm image/x-portable-pixmap-pnm image/x-portable-anymap-xbm image/x-xbitmap-xpm image/x-xpixmap-xwd image/x-xwindowdump-ief image/ief-png image/png--au audio/basic-snd audio/basic-aif audio/x-aiff-aiff audio/x-aiff-aifc audio/x-aiff-ra audio/x-pn-realaudio-ram audio/x-pn-realaudio-rm audio/x-pn-realaudio-rpm audio/x-pn-realaudio-plugin-wav audio/wav-mid audio/midi-midi audio/midi-kar audio/midi-mpga audio/mpeg-mp2 audio/mpeg-mp3 audio/mpeg--mpeg video/mpeg-mpg video/mpeg-mpe video/mpeg-qt video/quicktime-mov video/quicktime-avi video/x-msvideo-movie video/x-sgi-movie-mv video/x-sgi-movie-vx video/x-rad-screenplay--a application/octet-stream+ez application/andrew-inset+hqx application/mac-binhex40+cpt application/mac-compactpro+doc application/msword bin application/octet-stream+dms application/octet-stream+lha application/octet-stream+lzh application/octet-stream exe application/octet-stream-dump application/octet-stream-o application/octet-stream-class application/java-js application/x-javascript+class application/octet-stream+so application/octet-stream+dll application/octet-stream+oda application/oda+pdf application/pdf ai application/postscript eps application/postscript ps application/postscript-dir application/x-director+smi application/smil+smil application/smil+mif application/vnd.mif+xls application/vnd.ms-excel+ppt application/vnd.ms-powerpoint+wbxml application/vnd.wap.wbxml+wmlc application/vnd.wap.wmlc+wmlsc application/vnd.wap.wmlscriptc+bcpio application/x-bcpio+vcd application/x-cdlink+pgn application/x-chess-pgn+cpio application/x-cpio+csh application/x-csh dcr application/x-director+dir application/x-director dxr application/x-director-fgd application/x-director-aam application/x-authorware-map-aas application/x-authorware-seg-aab application/x-authorware-bin-fh4 image/x-freehand-fh7 image/x-freehand-fh5 image/x-freehand-fhc image/x-freehand-fh image/x-freehand-spl application/futuresplash-swf application/x-shockwave-flash dvi application/x-dvi+spl application/x-futuresplash gtar application/x-gtar hdf application/x-hdf-hqx application/mac-binhex40-iv application/x-inventor+js application/x-javascript+skp application/x-koan+skd application/x-koan+skt application/x-koan+skm application/x-koan latex application/x-latex-man application/x-troff-man-me application/x-troff-me-mif application/x-mif-ms application/x-troff-ms-oda application/oda-pdf application/pdf-rtf application/rtf-bcpio application/x-bcpio-cpio application/x-cpio-sv4cpio application/x-sv4cpio-sv4crc application/x-sv4crc-sh application/x-shar+nc application/x-netcdf+cdf application/x-netcdf+sh application/x-sh shar application/x-shar+swf application/x-shockwave-flash sit application/x-stuffit+sv4cpio application/x-sv4cpio+sv4crc application/x-sv4crc tar application/x-tar+tcl application/x-tcl tex application/x-tex-texi application/x-texinfo texinfo application/x-texinfo+texi application/x-texinfo+t application/x-troff tr application/x-troff roff application/x-troff man application/x-troff-man me application/x-troff-me ms application/x-troff-ms-zip application/x-zip-compressed-tsp application/dsptype-wsrc application/x-wais-source ustar application/x-ustar-cdf application/x-netcdf-nc application/x-netcdf-doc application/msword-ppt application/powerpoint--crt application/x-x509-ca-cert-crl application/x-pkcs7-crl-+src application/x-wais-source+xhtml application/xhtml+xml+xht application/xhtml+xml+zip application/zip+au audio/basic+snd audio/basic+mid audio/midi+midi audio/midi+kar audio/midi+mpga audio/mpeg+mp2 audio/mpeg+mp3 audio/mpeg+aif audio/x-aiff+aiff audio/x-aiff+aifc audio/x-aiff+m3u audio/x-mpegurl+ram audio/x-pn-realaudio+rm audio/x-pn-realaudio+rpm audio/x-pn-realaudio-plugin+ra audio/x-realaudio+wav audio/x-wav+pdb chemical/x-pdb+xyz chemical/x-xyz+bmp image/bmp+gif image/gif+ief image/ief+jpeg image/jpeg+jpg image/jpeg+jpe image/jpeg+png image/png+tiff image/tiff+tif image/tiff+djvu image/vnd.djvu+djv image/vnd.djvu+wbmp image/vnd.wap.wbmp+ras image/x-cmu-raster+pnm image/x-portable-anymap+pbm image/x-portable-bitmap+pgm image/x-portable-graymap+ppm image/x-portable-pixmap+rgb image/x-rgb+xbm image/x-xbitmap+xpm image/x-xpixmap+xwd image/x-xwindowdump+igs model/iges+iges model/iges+msh model/mesh+mesh model/mesh+silo model/mesh wrl model/vrml vrml model/vrml-mime message/rfc822--pac application/x-ns-proxy-autoconfig-+css text/css+html text/html; charset=%s+htm text/html; charset=%s+asc text/plain; charset=%s+txt text/plain; charset=%s+rtx text/richtext+rtf text/rtf+sgml text/sgml+sgm text/sgml+tsv text/tab-separated-values wml text/vnd.wap.wml-wmlc application/vnd.wap.wmlc wmls text/vnd.wap.wmlscript-wmlsc application/vnd.wap.wmlscriptc-wbmp image/vnd.wap.wbmp+etx text/x-setext+xml text/xml+xsl text/xml+mpeg video/mpeg+mpg video/mpeg+mpe video/mpeg+qt video/quicktime+mov video/quicktime+mxu video/vnd.mpegurl+avi video/x-msvideo+movie video/x-sgi-movie+ice x-conference/x-cooltalkdiff -ur thttpd-2.21b/mmc.c thttpd-2.21b-cool/mmc.c--- thttpd-2.21b/mmc.c Fri Apr 13 23:02:15 2001+++ thttpd-2.21b-cool/mmc.c Sat Sep 20 14:43:20 2003@@ -70,6 +70,9 @@ unsigned int hash; int hash_idx; struct MapStruct* next;+ char nocache;+ size_t last_modified_len;+ char last_modified[100]; } Map; @@ -93,12 +96,13 @@ void*-mmc_map( char* filename, struct stat* sbP, struct timeval* nowP )+mmc_map( char* filename, struct stat* sbP, struct timeval* nowP, int nocache, char **last_modified, size_t *last_modified_len ) { time_t now; struct stat sb; Map* m; int fd;+ const char* rfc1123fmt = "%a, %d %b %Y %H:%M:%S GMT"; /* Stat the file, if necessary. */ if ( sbP != (struct stat*) 0 )@@ -130,7 +134,7 @@ /* Yep. Just return the existing map */ ++m->refcount; m->reftime = now;- return m->addr;+ goto done; } /* Open the file. */@@ -167,12 +171,13 @@ m->ctime = sb.st_ctime; m->refcount = 1; m->reftime = now;+ m->nocache = (char) nocache; /* Avoid doing anything for zero-length files; some systems don't like ** to mmap them, other systems dislike mallocing zero bytes. */ if ( m->size == 0 )- m->addr = (void*) 1; /* arbitrary non-NULL address */+ m->addr = (void*) 5; /* arbitrary non-NULL address */ else { #ifdef HAVE_MMAP@@ -223,6 +228,13 @@ maps = m; ++map_count; + strftime( m->last_modified, sizeof(m->last_modified), rfc1123fmt, gmtime( &sb.st_mtime ) );+ m->last_modified_len = strlen(m->last_modified);+ +done:+ *last_modified = m->last_modified;+ *last_modified_len = m->last_modified_len;+ /* And return the address. */ return m->addr; }@@ -231,27 +243,32 @@ void mmc_unmap( void* addr, struct stat* sbP, struct timeval* nowP ) {- Map* m = (Map*) 0;+ Map* m = (Map*) 0, **mm = &maps; /* Find the Map entry for this address. First try a hash. */ if ( sbP != (struct stat*) 0 ) { m = find_hash( sbP->st_ino, sbP->st_dev, sbP->st_size, sbP->st_ctime );- if ( m != (Map*) 0 && m->addr != addr )+ if ( m != (Map*) 0 && ( m->addr != addr || m->nocache == 1 ) ) m = (Map*) 0; } /* If that didn't work, try a full search. */ if ( m == (Map*) 0 )- for ( m = maps; m != (Map*) 0; m = m->next )+ for ( m = maps; m != (Map*) 0; m = m->next ) { if ( m->addr == addr ) break;+ mm = &m->next;+ } if ( m == (Map*) 0 ) syslog( LOG_ERR, "mmc_unmap failed to find entry!" ); else if ( m->refcount <= 0 ) syslog( LOG_ERR, "mmc_unmap found zero or negative refcount!" ); else {- --m->refcount;+ if ( --m->refcount == 0 && m->nocache == 1 ) {+ really_unmap( mm );+ return;+ } if ( nowP != (struct timeval*) 0 ) m->reftime = nowP->tv_sec; elsediff -ur thttpd-2.21b/mmc.h thttpd-2.21b-cool/mmc.h--- thttpd-2.21b/mmc.h Fri Apr 13 07:36:54 2001+++ thttpd-2.21b-cool/mmc.h Sat Sep 20 14:43:20 2003@@ -31,8 +31,9 @@ /* Returns an mmap()ed area for the given file, or (void*) 0 on errors. ** If you have a stat buffer on the file, pass it in, otherwise pass 0. ** Same for the current time.+** Set nocache to 1, if this entry is supposed to be removed quickly. */-extern void* mmc_map( char* filename, struct stat* sbP, struct timeval* nowP );+extern void* mmc_map( char* filename, struct stat* sbP, struct timeval* nowP, int nocache, char **last_modified, size_t *last_modified_len );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -