2002-07-14 13:48:46 +00:00
|
|
|
Only in thttpd-2.21b-cool/: Makefile
|
2002-07-14 13:10:34 +00:00
|
|
|
diff -ur thttpd-2.21b/Makefile.in thttpd-2.21b-cool/Makefile.in
|
|
|
|
--- thttpd-2.21b/Makefile.in Thu Mar 29 20:36:21 2001
|
|
|
|
+++ thttpd-2.21b-cool/Makefile.in Sun Jul 14 13:54:27 2002
|
1999-12-20 07:11:14 +00:00
|
|
|
@@ -46,13 +46,15 @@
|
|
|
|
|
|
|
|
# You shouldn't need to edit anything below here.
|
|
|
|
|
|
|
|
+include php_makefile
|
|
|
|
+
|
|
|
|
CC = @CC@
|
|
|
|
CCOPT = @V_CCOPT@
|
|
|
|
DEFS = @DEFS@
|
|
|
|
INCLS = -I.
|
|
|
|
CFLAGS = $(CCOPT) $(DEFS) $(INCLS)
|
|
|
|
-LDFLAGS = @LDFLAGS@
|
|
|
|
-LIBS = @LIBS@
|
|
|
|
+LDFLAGS = @LDFLAGS@ $(PHP_LDFLAGS)
|
|
|
|
+LIBS = @LIBS@ $(PHP_LIBS)
|
|
|
|
NETLIBS = @V_NETLIBS@
|
|
|
|
INSTALL = @INSTALL@
|
|
|
|
|
2000-08-07 13:54:35 +00:00
|
|
|
@@ -62,7 +64,7 @@
|
|
|
|
@rm -f $@
|
|
|
|
$(CC) $(CFLAGS) -c $*.c
|
|
|
|
|
|
|
|
-SRC = thttpd.c libhttpd.c fdwatch.c mmc.c timers.c match.c tdate_parse.c syslog.c
|
|
|
|
+SRC = thttpd.c libhttpd.c fdwatch.c mmc.c timers.c match.c tdate_parse.c syslog.c php_thttpd.c
|
|
|
|
|
|
|
|
OBJ = $(SRC:.c=.o) @LIBOBJS@
|
|
|
|
|
|
|
|
@@ -151,6 +153,9 @@
|
|
|
|
|
|
|
|
tags:
|
|
|
|
ctags -wtd *.c *.h
|
|
|
|
+
|
|
|
|
+php_thttpd.o: php_thttpd.c
|
|
|
|
+ $(CC) $(PHP_CFLAGS) $(CFLAGS) -c php_thttpd.c
|
|
|
|
|
|
|
|
tar:
|
|
|
|
@name=`sed -n -e '/SERVER_SOFTWARE/!d' -e 's,.*thttpd/,thttpd-,' -e 's, .*,,p' version.h` ; \
|
2002-07-14 13:10:34 +00:00
|
|
|
diff -ur thttpd-2.21b/config.h thttpd-2.21b-cool/config.h
|
|
|
|
--- thttpd-2.21b/config.h Mon Apr 9 23:57:36 2001
|
|
|
|
+++ thttpd-2.21b-cool/config.h Sun Jul 14 13:54:27 2002
|
2001-08-13 21:55:21 +00:00
|
|
|
@@ -316,7 +316,7 @@
|
|
|
|
/* CONFIGURE: A list of index filenames to check. The files are searched
|
|
|
|
** for in this order.
|
|
|
|
*/
|
|
|
|
-#define INDEX_NAMES "index.html", "index.htm", "Default.htm", "index.cgi"
|
|
|
|
+#define INDEX_NAMES "index.php", "index.html", "index.htm", "Default.htm", "index.cgi"
|
|
|
|
|
|
|
|
/* CONFIGURE: If this is defined then thttpd will automatically generate
|
|
|
|
** index pages for directories that don't have an explicit index file.
|
2002-07-14 13:10:34 +00:00
|
|
|
diff -ur thttpd-2.21b/fdwatch.c thttpd-2.21b-cool/fdwatch.c
|
|
|
|
--- thttpd-2.21b/fdwatch.c Fri Apr 13 07:36:08 2001
|
|
|
|
+++ thttpd-2.21b-cool/fdwatch.c Sun Jul 14 13:54:27 2002
|
2001-08-13 22:01:55 +00:00
|
|
|
@@ -460,7 +460,7 @@
|
|
|
|
|
|
|
|
ridx = 0;
|
|
|
|
for ( i = 0; i < npollfds; ++i )
|
|
|
|
- if ( pollfds[i].revents & ( POLLIN | POLLOUT ) )
|
|
|
|
+ if ( pollfds[i].revents & ( POLLIN | POLLOUT | POLLERR | POLLHUP | POLLNVAL ) )
|
|
|
|
poll_rfdidx[ridx++] = pollfds[i].fd;
|
|
|
|
|
|
|
|
return r;
|
|
|
|
@@ -472,8 +472,8 @@
|
|
|
|
{
|
|
|
|
switch ( fd_rw[fd] )
|
|
|
|
{
|
|
|
|
- case FDW_READ: return pollfds[poll_fdidx[fd]].revents & POLLIN;
|
|
|
|
- case FDW_WRITE: return pollfds[poll_fdidx[fd]].revents & POLLOUT;
|
|
|
|
+ case FDW_READ: return pollfds[poll_fdidx[fd]].revents & ( POLLIN | POLLERR | POLLHUP | POLLNVAL );
|
|
|
|
+ case FDW_WRITE: return pollfds[poll_fdidx[fd]].revents & ( POLLOUT | POLLERR | POLLHUP | POLLNVAL );
|
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
}
|
2002-07-14 13:10:34 +00:00
|
|
|
diff -ur thttpd-2.21b/libhttpd.c thttpd-2.21b-cool/libhttpd.c
|
|
|
|
--- thttpd-2.21b/libhttpd.c Tue Apr 24 00:42:40 2001
|
2002-07-14 13:48:46 +00:00
|
|
|
+++ thttpd-2.21b-cool/libhttpd.c Sun Jul 14 15:41:06 2002
|
2001-04-22 14:00:53 +00:00
|
|
|
@@ -85,6 +85,8 @@
|
1999-12-20 07:11:14 +00:00
|
|
|
#include "match.h"
|
|
|
|
#include "tdate_parse.h"
|
|
|
|
|
|
|
|
+#include "php_thttpd.h"
|
|
|
|
+
|
|
|
|
#ifndef STDIN_FILENO
|
|
|
|
#define STDIN_FILENO 0
|
|
|
|
#endif
|
2001-08-13 21:55:21 +00:00
|
|
|
@@ -242,6 +244,8 @@
|
1999-12-20 07:11:14 +00:00
|
|
|
free( (void*) hs->cwd );
|
|
|
|
if ( hs->cgi_pattern != (char*) 0 )
|
|
|
|
free( (void*) hs->cgi_pattern );
|
|
|
|
+ if ( hs->php_pattern != (char*) 0 )
|
2000-08-07 13:54:35 +00:00
|
|
|
+ free( (void*) hs->php_pattern );
|
|
|
|
if ( hs->charset != (char*) 0 )
|
|
|
|
free( (void*) hs->charset );
|
|
|
|
if ( hs->url_pattern != (char*) 0 )
|
2001-08-13 21:55:21 +00:00
|
|
|
@@ -249,6 +253,7 @@
|
2000-08-07 13:54:35 +00:00
|
|
|
if ( hs->local_pattern != (char*) 0 )
|
|
|
|
free( (void*) hs->local_pattern );
|
1999-12-20 07:11:14 +00:00
|
|
|
free( (void*) hs );
|
|
|
|
+ thttpd_php_shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-13 21:55:21 +00:00
|
|
|
@@ -312,6 +317,7 @@
|
2000-08-07 13:54:35 +00:00
|
|
|
}
|
|
|
|
|
1999-12-20 07:11:14 +00:00
|
|
|
hs->port = port;
|
2000-08-20 09:37:15 +00:00
|
|
|
+ hs->php_pattern = strdup("**.php");
|
1999-12-20 07:11:14 +00:00
|
|
|
if ( cgi_pattern == (char*) 0 )
|
|
|
|
hs->cgi_pattern = (char*) 0;
|
|
|
|
else
|
2001-08-13 21:55:21 +00:00
|
|
|
@@ -385,6 +391,8 @@
|
2000-08-21 03:04:35 +00:00
|
|
|
return (httpd_server*) 0;
|
|
|
|
}
|
1999-12-20 07:11:14 +00:00
|
|
|
|
|
|
|
+ thttpd_php_init();
|
|
|
|
+
|
2000-08-21 03:04:35 +00:00
|
|
|
/* Done initializing. */
|
|
|
|
if ( hs->binding_hostname == (char*) 0 )
|
2001-04-22 14:00:53 +00:00
|
|
|
syslog( LOG_INFO, "%.80s starting on port %d", SERVER_SOFTWARE, hs->port );
|
2002-07-14 13:48:46 +00:00
|
|
|
@@ -2353,7 +2361,10 @@
|
2000-11-13 13:33:12 +00:00
|
|
|
{
|
2001-04-22 14:00:53 +00:00
|
|
|
make_log_entry( hc, nowP );
|
|
|
|
|
2000-11-13 13:33:12 +00:00
|
|
|
- if ( hc->file_address != (char*) 0 )
|
2002-07-14 13:10:34 +00:00
|
|
|
+ if ( hc->file_address == (char*) 1 )
|
2001-04-22 14:00:53 +00:00
|
|
|
+ {
|
|
|
|
+ thttpd_closed_conn(hc->conn_fd);
|
|
|
|
+ } else if ( hc->file_address != (char*) 0 )
|
2000-11-13 13:33:12 +00:00
|
|
|
{
|
2001-04-22 14:00:53 +00:00
|
|
|
mmc_unmap( hc->file_address, &(hc->sb), nowP );
|
2000-11-13 13:33:12 +00:00
|
|
|
hc->file_address = (char*) 0;
|
2002-07-14 13:48:46 +00:00
|
|
|
@@ -3026,11 +3037,9 @@
|
2001-08-13 22:01:55 +00:00
|
|
|
post_post_garbage_hack( httpd_conn* hc )
|
|
|
|
{
|
|
|
|
char buf[2];
|
|
|
|
- int r;
|
|
|
|
|
|
|
|
- r = recv( hc->conn_fd, buf, sizeof(buf), MSG_PEEK );
|
|
|
|
- if ( r > 0 )
|
|
|
|
- (void) read( hc->conn_fd, buf, r );
|
|
|
|
+ fcntl(hc->conn_fd, F_SETFL, O_NONBLOCK);
|
|
|
|
+ (void) read( hc->conn_fd, buf, 2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-14 13:48:46 +00:00
|
|
|
@@ -3561,6 +3570,11 @@
|
1999-12-20 07:11:14 +00:00
|
|
|
match( hc->hs->cgi_pattern, hc->expnfilename ) )
|
|
|
|
return cgi( hc );
|
2002-07-14 13:10:34 +00:00
|
|
|
|
1999-12-20 07:11:14 +00:00
|
|
|
+ if ( hc->hs->php_pattern != (char*) 0 &&
|
|
|
|
+ match( hc->hs->php_pattern, hc->expnfilename)) {
|
|
|
|
+ return thttpd_php_request( hc );
|
|
|
|
+ }
|
2002-07-14 13:10:34 +00:00
|
|
|
+
|
1999-12-20 07:11:14 +00:00
|
|
|
/* It's not CGI. If it's executable or there's pathinfo, someone's
|
|
|
|
** trying to either serve or run a non-CGI file as CGI. Either case
|
2002-07-14 13:10:34 +00:00
|
|
|
** is prohibited.
|
2002-07-14 13:48:46 +00:00
|
|
|
@@ -3611,14 +3625,18 @@
|
2002-07-14 13:10:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
+ char *extraheads = "";
|
|
|
|
hc->file_address = mmc_map( hc->expnfilename, &(hc->sb), nowP );
|
|
|
|
if ( hc->file_address == (char*) 0 )
|
|
|
|
{
|
|
|
|
httpd_send_err( hc, 500, err500title, "", err500form, hc->encodedurl );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
+ if (strncmp(hc->decodedurl, "/nocache/", sizeof("/nocache/")-1) == 0)
|
|
|
|
+ extraheads = "Expires: Thu, 19 Nov 1981 08:52:00 GMT\r\nCache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\nPragma: no-cache\r\n";
|
|
|
|
+
|
|
|
|
send_mime(
|
|
|
|
- hc, 200, ok200title, hc->encodings, "", hc->type, hc->sb.st_size,
|
|
|
|
+ hc, 200, ok200title, hc->encodings, extraheads, hc->type, hc->sb.st_size,
|
|
|
|
hc->sb.st_mtime );
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2002-07-14 13:48:46 +00:00
|
|
|
+++ thttpd-2.21b-cool/libhttpd.h Sun Jul 14 15:41:32 2002
|
2000-08-07 13:54:35 +00:00
|
|
|
@@ -69,6 +69,7 @@
|
|
|
|
char* server_hostname;
|
1999-12-20 07:11:14 +00:00
|
|
|
int port;
|
|
|
|
char* cgi_pattern;
|
|
|
|
+ char* php_pattern;
|
2000-08-07 13:54:35 +00:00
|
|
|
char* charset;
|
1999-12-20 07:11:14 +00:00
|
|
|
char* cwd;
|
2000-08-07 13:54:35 +00:00
|
|
|
int listen4_fd, listen6_fd;
|
2002-07-14 13:10:34 +00:00
|
|
|
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 Sun Jul 14 13:54:27 2002
|
|
|
|
@@ -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-uuencode
|
|
|
|
diff -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 Sun Jul 14 14:05:09 2002
|
|
|
|
@@ -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-cooltalk
|
|
|
|
diff -ur thttpd-2.21b/thttpd.c thttpd-2.21b-cool/thttpd.c
|
|
|
|
--- thttpd-2.21b/thttpd.c Tue Apr 24 00:41:57 2001
|
2002-07-14 13:48:46 +00:00
|
|
|
+++ thttpd-2.21b-cool/thttpd.c Sun Jul 14 15:45:23 2002
|
2002-07-14 13:10:34 +00:00
|
|
|
@@ -111,12 +111,15 @@
|
|
|
|
static int httpd_conn_count;
|
|
|
|
|
|
|
|
/* The connection states. */
|
|
|
|
-#define CNST_FREE 0
|
|
|
|
-#define CNST_READING 1
|
|
|
|
-#define CNST_SENDING 2
|
|
|
|
-#define CNST_PAUSING 3
|
|
|
|
-#define CNST_LINGERING 4
|
|
|
|
-
|
|
|
|
+enum {
|
|
|
|
+ CNST_FREE = 0,
|
|
|
|
+ CNST_READING,
|
|
|
|
+ CNST_SENDING,
|
|
|
|
+ CNST_PAUSING,
|
|
|
|
+ CNST_LINGERING,
|
2002-07-14 13:48:46 +00:00
|
|
|
+ CNST_SENDING_RESP,
|
2002-07-14 13:10:34 +00:00
|
|
|
+ CNST_TOTAL_NR
|
|
|
|
+};
|
|
|
|
|
|
|
|
static httpd_server* hs = (httpd_server*) 0;
|
|
|
|
int terminate = 0;
|
|
|
|
@@ -140,6 +143,7 @@
|
|
|
|
static int handle_newconnect( struct timeval* tvP, int listen_fd );
|
|
|
|
static void handle_read( connecttab* c, struct timeval* tvP );
|
|
|
|
static void handle_send( connecttab* c, struct timeval* tvP );
|
2002-07-14 13:48:46 +00:00
|
|
|
+static void handle_send_resp( connecttab* c, struct timeval* tvP );
|
2002-07-14 13:10:34 +00:00
|
|
|
static void handle_linger( connecttab* c, struct timeval* tvP );
|
|
|
|
static int check_throttles( connecttab* c );
|
|
|
|
static void clear_throttles( connecttab* c, struct timeval* tvP );
|
|
|
|
@@ -157,6 +161,12 @@
|
|
|
|
static void logstats( struct timeval* nowP );
|
|
|
|
static void thttpd_logstats( long secs );
|
|
|
|
|
|
|
|
+typedef void (*handler_func)(connecttab*, struct timeval *);
|
|
|
|
+
|
|
|
|
+handler_func handler_array[CNST_TOTAL_NR] =
|
2002-07-14 13:48:46 +00:00
|
|
|
+{NULL, handle_read, handle_send, NULL, handle_linger, handle_send_resp};
|
2002-07-14 13:10:34 +00:00
|
|
|
+
|
|
|
|
+#define RUN_HANDLER(type, c) handler_array[type](c, &tv)
|
|
|
|
|
|
|
|
static void
|
|
|
|
handle_term( int sig )
|
|
|
|
@@ -566,15 +576,17 @@
|
|
|
|
if ( c == (connecttab*) 0 )
|
|
|
|
continue;
|
|
|
|
hc = c->hc;
|
|
|
|
- if ( c->conn_state == CNST_READING &&
|
|
|
|
- fdwatch_check_fd( hc->conn_fd ) )
|
|
|
|
- handle_read( c, &tv );
|
|
|
|
- else if ( c->conn_state == CNST_SENDING &&
|
|
|
|
- fdwatch_check_fd( hc->conn_fd ) )
|
|
|
|
- handle_send( c, &tv );
|
|
|
|
- else if ( c->conn_state == CNST_LINGERING &&
|
|
|
|
- fdwatch_check_fd( hc->conn_fd ) )
|
|
|
|
- handle_linger( c, &tv );
|
|
|
|
+ switch (c->conn_state) {
|
|
|
|
+ case CNST_READING:
|
|
|
|
+ case CNST_SENDING:
|
|
|
|
+ case CNST_LINGERING:
|
2002-07-14 13:48:46 +00:00
|
|
|
+ case CNST_SENDING_RESP:
|
2002-07-14 13:10:34 +00:00
|
|
|
+ fdwatch_check_fd(hc->conn_fd);
|
|
|
|
+ RUN_HANDLER(c->conn_state, c);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
}
|
|
|
|
tmr_run( &tv );
|
|
|
|
|
2002-07-14 13:48:46 +00:00
|
|
|
@@ -1297,12 +1309,36 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+static void
|
|
|
|
+setup_sending(connecttab *c, int state, struct timeval *tvP)
|
|
|
|
+{
|
|
|
|
+ httpd_conn *hc = c->hc;
|
|
|
|
+ ClientData client_data;
|
|
|
|
+
|
|
|
|
+ c->conn_state = state;
|
|
|
|
+ c->started_at = tvP->tv_sec;
|
|
|
|
+ c->wouldblock_delay = 0;
|
|
|
|
+ client_data.p = c;
|
|
|
|
+ tmr_cancel( c->idle_read_timer );
|
|
|
|
+ c->idle_read_timer = (Timer*) 0;
|
|
|
|
+ c->idle_send_timer = tmr_create(
|
|
|
|
+ tvP, idle_send_connection, client_data, IDLE_SEND_TIMELIMIT * 1000L,
|
|
|
|
+ 0 );
|
|
|
|
+ if ( c->idle_send_timer == (Timer*) 0 )
|
|
|
|
+ {
|
|
|
|
+ syslog( LOG_CRIT, "tmr_create(idle_send_connection) failed" );
|
|
|
|
+ exit( 1 );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fdwatch_del_fd( hc->conn_fd );
|
|
|
|
+ fdwatch_add_fd( hc->conn_fd, c, FDW_WRITE );
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
|
|
|
|
static void
|
|
|
|
handle_read( connecttab* c, struct timeval* tvP )
|
|
|
|
{
|
|
|
|
int sz;
|
|
|
|
- ClientData client_data;
|
|
|
|
httpd_conn* hc = c->hc;
|
|
|
|
|
|
|
|
/* Is there room in our buffer to read more bytes? */
|
|
|
|
@@ -1333,7 +1369,7 @@
|
2001-08-13 21:55:21 +00:00
|
|
|
clear_connection( c, tvP );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
- hc->read_idx += sz;
|
|
|
|
+ if (sz > 0) hc->read_idx += sz;
|
|
|
|
|
|
|
|
/* Do we have a complete request yet? */
|
|
|
|
switch ( httpd_got_request( hc ) )
|
2002-07-14 13:48:46 +00:00
|
|
|
@@ -1387,6 +1423,12 @@
|
2000-11-13 13:33:12 +00:00
|
|
|
clear_connection( c, tvP );
|
|
|
|
return;
|
2001-04-22 14:00:53 +00:00
|
|
|
}
|
2000-11-13 13:33:12 +00:00
|
|
|
+ if (hc->file_address == (char *) 1) {
|
|
|
|
+ tmr_cancel( c->idle_read_timer );
|
2000-11-15 23:37:50 +00:00
|
|
|
+ c->idle_read_timer = (Timer*) 0;
|
|
|
|
+ c->wouldblock_delay = 0;
|
2000-11-13 13:33:12 +00:00
|
|
|
+ return;
|
2001-04-22 14:00:53 +00:00
|
|
|
+ }
|
2000-11-13 13:33:12 +00:00
|
|
|
if ( c->bytes_sent >= c->bytes_to_send )
|
|
|
|
{
|
2001-04-22 14:00:53 +00:00
|
|
|
/* There's nothing to send. */
|
2002-07-14 13:48:46 +00:00
|
|
|
@@ -1395,26 +1437,9 @@
|
2002-07-14 13:10:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Cool, we have a valid connection and a file to send to it. */
|
|
|
|
- c->conn_state = CNST_SENDING;
|
2002-07-14 13:48:46 +00:00
|
|
|
- c->started_at = tvP->tv_sec;
|
|
|
|
- c->wouldblock_delay = 0;
|
|
|
|
- client_data.p = c;
|
|
|
|
- tmr_cancel( c->idle_read_timer );
|
|
|
|
- c->idle_read_timer = (Timer*) 0;
|
|
|
|
- c->idle_send_timer = tmr_create(
|
|
|
|
- tvP, idle_send_connection, client_data, IDLE_SEND_TIMELIMIT * 1000L,
|
|
|
|
- 0 );
|
|
|
|
- if ( c->idle_send_timer == (Timer*) 0 )
|
|
|
|
- {
|
|
|
|
- syslog( LOG_CRIT, "tmr_create(idle_send_connection) failed" );
|
|
|
|
- exit( 1 );
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- fdwatch_del_fd( hc->conn_fd );
|
|
|
|
- fdwatch_add_fd( hc->conn_fd, c, FDW_WRITE );
|
|
|
|
+ setup_sending(c, CNST_SENDING, tvP);
|
|
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
static void
|
|
|
|
handle_send( connecttab* c, struct timeval* tvP )
|
|
|
|
{
|
|
|
|
@@ -1500,7 +1525,7 @@
|
2001-08-13 21:55:21 +00:00
|
|
|
{
|
|
|
|
/* Yes; move the unwritten part to the front of the buffer. */
|
|
|
|
int newlen = hc->responselen - sz;
|
|
|
|
- (void) memcpy( hc->response, &(hc->response[sz]), newlen );
|
|
|
|
+ (void) memmove( hc->response, &(hc->response[sz]), newlen );
|
|
|
|
hc->responselen = newlen;
|
|
|
|
sz = 0;
|
|
|
|
}
|
2002-07-14 13:48:46 +00:00
|
|
|
@@ -1569,6 +1594,35 @@
|
2002-07-14 13:10:34 +00:00
|
|
|
}
|
2001-12-10 14:09:08 +00:00
|
|
|
|
2002-07-14 13:48:46 +00:00
|
|
|
|
2002-07-14 13:10:34 +00:00
|
|
|
+static void
|
2002-07-14 13:48:46 +00:00
|
|
|
+handle_send_resp(connecttab *c, struct timeval *tvP)
|
2002-07-14 13:10:34 +00:00
|
|
|
+{
|
|
|
|
+ httpd_conn* hc = c->hc;
|
2002-07-14 13:48:46 +00:00
|
|
|
+ int n = send(hc->conn_fd, hc->response, hc->responselen, 0);
|
2002-07-14 13:10:34 +00:00
|
|
|
+
|
|
|
|
+ if (n < 0) {
|
|
|
|
+ if (errno == EAGAIN)
|
|
|
|
+ return;
|
|
|
|
+
|
2002-07-14 13:48:46 +00:00
|
|
|
+ goto clear;
|
2002-07-14 13:10:34 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ tmr_reset( tvP, c->idle_send_timer );
|
|
|
|
+
|
2002-07-14 13:48:46 +00:00
|
|
|
+ if (n == hc->responselen) {
|
|
|
|
+clear:
|
|
|
|
+ hc->response = realloc(hc->response, hc->maxresponse + 1);
|
|
|
|
+ hc->responselen = 0;
|
2002-07-14 13:10:34 +00:00
|
|
|
+
|
|
|
|
+ clear_connection(c, tvP);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
2002-07-14 13:48:46 +00:00
|
|
|
+ hc->responselen -= n;
|
2002-07-14 13:10:34 +00:00
|
|
|
+
|
2002-07-14 13:48:46 +00:00
|
|
|
+ memmove(hc->response, hc->response + n, hc->responselen);
|
2002-07-14 13:10:34 +00:00
|
|
|
+}
|
2002-07-14 13:48:46 +00:00
|
|
|
+
|
2002-07-14 13:10:34 +00:00
|
|
|
static int
|
|
|
|
check_throttles( connecttab* c )
|
2002-07-14 13:48:46 +00:00
|
|
|
{
|
|
|
|
@@ -1640,7 +1694,11 @@
|
|
|
|
ClientData client_data;
|
|
|
|
|
|
|
|
/* If we haven't actually sent the buffered response yet, do so now. */
|
|
|
|
- httpd_write_response( c->hc );
|
|
|
|
+ if (c->hc->responselen && c->conn_state != CNST_SENDING_RESP) {
|
|
|
|
+ setup_sending(c, CNST_SENDING_RESP, tvP);
|
|
|
|
+
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if ( c->idle_read_timer != (Timer*) 0 )
|
|
|
|
{
|