Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add the COOP and COEP HTTP reply headers if the --enable-sab command-line option is used. "sab" stands for "SharedArrayBuffer". |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
85b7ee71fa19264317f7fa3e1bd5fb59 |
User & Date: | drh 2022-09-26 16:57:19.049 |
Context
2022-11-19
| ||
04:37 | Comment typo fix. No code changes. ... (check-in: 8cf27e63c8 user: stephan tags: trunk) | |
2022-10-22
| ||
23:21 | Add experimental support for a '-redirect' file. ... (check-in: 7a0cf0d59f user: mistachkin tags: redirFile) | |
02:26 | Add the '-subdir' command line option. ... (check-in: 72c2a01009 user: mistachkin tags: subDir) | |
2022-09-26
| ||
16:57 | Add the COOP and COEP HTTP reply headers if the --enable-sab command-line option is used. "sab" stands for "SharedArrayBuffer". ... (check-in: 85b7ee71fa user: drh tags: trunk) | |
16:55 | Disable COOP and COEP by default. Enable only when the --enable-sab option appears on the command-line. ... (Closed-Leaf check-in: 3496e47091 user: drh tags: enable-atomics) | |
2022-08-12
| ||
17:23 | Add documentation of the --page and --popup options to the main page. ... (check-in: 0310001ae1 user: drh tags: trunk) | |
Changes
Changes to Makefile.
1 2 3 4 5 6 7 8 9 | default: althttpd althttpsd VERSION_NUMBER = 2.0 manifest: @if which fossil > /dev/null; then \ fossil update --nosync current; \ else \ echo "fossil binary not found. Version hash/time might be incorrect." fi | > > | 1 2 3 4 5 6 7 8 9 10 11 | default: althttpd althttpsd VERSION_NUMBER = 2.0 CC=cc CFLAGS=-Os -Wall -Wextra manifest: @if which fossil > /dev/null; then \ fossil update --nosync current; \ else \ echo "fossil binary not found. Version hash/time might be incorrect." fi |
︙ | ︙ | |||
17 18 19 20 21 22 23 | time=`sed -n 2p manifest | cut -d' ' -f2`; \ { echo -n "ALTHTTPD_VERSION=\""; \ echo '$(VERSION_NUMBER)' "[$$hash] [$$time]\""; \ } > $@ althttpd: althttpd.c version @flags="`cat version`"; set -x; \ | | | | | < | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | time=`sed -n 2p manifest | cut -d' ' -f2`; \ { echo -n "ALTHTTPD_VERSION=\""; \ echo '$(VERSION_NUMBER)' "[$$hash] [$$time]\""; \ } > $@ althttpd: althttpd.c version @flags="`cat version`"; set -x; \ $(CC) $(CFLAGS) "-D$$flags" -o althttpd althttpd.c althttpsd: althttpd.c version @flags="`cat version`"; set -x; \ $(CC) $(CFLAGS) "-D$$flags" -fPIC -o althttpsd -DENABLE_TLS althttpd.c -lssl -lcrypto static-althttpd: althttpd.c version @flags="`cat version`"; set -x; \ $(CC) $(CFLAGS) "-D$$flags" -static -o althttpd althttpd.c static-althttpsd: althttpd.c version @flags="`cat version`"; set -x; \ $(CC) $(CFLAGS) "-D$$flags" -static -fPIC -o althttpsd -DENABLE_TLS althttpd.c -lssl -lcrypto -lpthread -ldl clean: rm -f althttpd althttpsd version |
Changes to althttpd.c.
︙ | ︙ | |||
168 169 170 171 172 173 174 175 176 177 178 179 180 181 | ** ** --max-cpu SEC Maximum number of seconds of CPU time allowed per ** HTTP connection. Default 30 (build option: ** -DMAX_CPU=integer). 0 means no limit. ** ** --debug BOOLEAN Disables input timeouts. This is useful for debugging ** when inputs are being typed in manually. ** ** Additional command-line options available when compiling with ENABLE_TLS: ** ** --cert FILE The TLS certificate, the "fullchain.pem" file ** ** --pkey FILE The TLS private key, the "privkey.pem" file. May be ** omitted if the --cert file is the concatenation of | > > > > > > | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | ** ** --max-cpu SEC Maximum number of seconds of CPU time allowed per ** HTTP connection. Default 30 (build option: ** -DMAX_CPU=integer). 0 means no limit. ** ** --debug BOOLEAN Disables input timeouts. This is useful for debugging ** when inputs are being typed in manually. ** ** --enable-sab Add new lines to the HTTP reply header that are ** prerequisites for SharedArrayBuffer. These are the lines: ** Cross-Origin-Embedder-Policy: require-corp ** Cross-Origin-Opener-Policy: same-origin ** ** ** Additional command-line options available when compiling with ENABLE_TLS: ** ** --cert FILE The TLS certificate, the "fullchain.pem" file ** ** --pkey FILE The TLS private key, the "privkey.pem" file. May be ** omitted if the --cert file is the concatenation of |
︙ | ︙ | |||
422 423 424 425 426 427 428 429 430 431 432 433 434 435 | static struct rusage priorChild; /* Previously report CHILD time */ static int mxAge = 120; /* Cache-control max-age */ static char *default_path = "/bin:/usr/bin"; /* Default PATH variable */ static char *zScgi = 0; /* Value of the SCGI env variable */ static int rangeStart = 0; /* Start of a Range: request */ static int rangeEnd = 0; /* End of a Range: request */ static int maxCpu = MAX_CPU; /* Maximum CPU time per process */ /* Forward reference */ static void Malfunction(int errNo, const char *zFormat, ...); #ifdef ENABLE_TLS | > > | 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | static struct rusage priorChild; /* Previously report CHILD time */ static int mxAge = 120; /* Cache-control max-age */ static char *default_path = "/bin:/usr/bin"; /* Default PATH variable */ static char *zScgi = 0; /* Value of the SCGI env variable */ static int rangeStart = 0; /* Start of a Range: request */ static int rangeEnd = 0; /* End of a Range: request */ static int maxCpu = MAX_CPU; /* Maximum CPU time per process */ static int enableSAB = 0; /* Add reply header to enable ** SharedArrayBuffer */ /* Forward reference */ static void Malfunction(int errNo, const char *zFormat, ...); #ifdef ENABLE_TLS |
︙ | ︙ | |||
695 696 697 698 699 700 701 702 703 704 705 706 707 708 | if( zScript==0 ) zScript = ""; if( zRealScript==0 ) zRealScript = ""; if( zRemoteAddr==0 ) zRemoteAddr = ""; if( zHttpHost==0 ) zHttpHost = ""; if( zReferer==0 ) zReferer = ""; if( zAgent==0 ) zAgent = ""; gettimeofday(&now, 0); pTm = localtime(&now.tv_sec); strftime(zDate, sizeof(zDate), "%Y-%m-%d %H:%M:%S", pTm); sz = strftime(zExpLogFile, sizeof(zExpLogFile), zLogFile, pTm); if( sz>0 && sz<sizeof(zExpLogFile)-2 ){ zFilename = zExpLogFile; }else{ | > | 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 | if( zScript==0 ) zScript = ""; if( zRealScript==0 ) zRealScript = ""; if( zRemoteAddr==0 ) zRemoteAddr = ""; if( zHttpHost==0 ) zHttpHost = ""; if( zReferer==0 ) zReferer = ""; if( zAgent==0 ) zAgent = ""; if( zQuerySuffix==0 ) zQuerySuffix = ""; gettimeofday(&now, 0); pTm = localtime(&now.tv_sec); strftime(zDate, sizeof(zDate), "%Y-%m-%d %H:%M:%S", pTm); sz = strftime(zExpLogFile, sizeof(zExpLogFile), zLogFile, pTm); if( sz>0 && sz<sizeof(zExpLogFile)-2 ){ zFilename = zExpLogFile; }else{ |
︙ | ︙ | |||
735 736 737 738 739 740 741 | ** (13) Request number for same TCP/IP connection ** (14) User agent ** (15) Remote user ** (16) Bytes of URL that correspond to the SCRIPT_NAME ** (17) Line number in source file */ fprintf(log, | | > | 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 | ** (13) Request number for same TCP/IP connection ** (14) User agent ** (15) Remote user ** (16) Bytes of URL that correspond to the SCRIPT_NAME ** (17) Line number in source file */ fprintf(log, "%s,%s,\"%s://%s%s%s\",\"%s\"," "%s,%d,%d,%lld,%lld,%lld,%lld,%lld,%d,\"%s\",\"%s\",%d,%d\n", zDate, zRemoteAddr, zHttpScheme, Escape(zHttpHost), Escape(zScript), Escape(zQuerySuffix), Escape(zReferer), zReplyStatus, nIn, nOut, tvms(&self.ru_utime) - tvms(&priorSelf.ru_utime), tvms(&self.ru_stime) - tvms(&priorSelf.ru_stime), tvms(&children.ru_utime) - tvms(&priorChild.ru_utime), tvms(&children.ru_stime) - tvms(&priorChild.ru_stime), tvms(&now) - tvms(&beginTime), nRequest, Escape(zAgent), Escape(zRM), |
︙ | ︙ | |||
2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 | rangeStart, rangeEnd, (int)pStat->st_size); pStat->st_size = rangeEnd + 1 - rangeStart; }else{ StartResponse("200 OK"); rangeStart = 0; } nOut += DateTag("Last-Modified", pStat->st_mtime); nOut += althttpd_printf("Cache-Control: max-age=%d\r\n", mxAge); nOut += althttpd_printf("ETag: \"%s\"\r\n", zETag); nOut += althttpd_printf("Content-type: %s%s\r\n",zContentType, bAddCharset ? "; charset=utf-8" : ""); if( zEncoding ){ nOut += althttpd_printf("Content-encoding: %s\r\n", zEncoding); } | > > > > > > | 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 | rangeStart, rangeEnd, (int)pStat->st_size); pStat->st_size = rangeEnd + 1 - rangeStart; }else{ StartResponse("200 OK"); rangeStart = 0; } nOut += DateTag("Last-Modified", pStat->st_mtime); if( enableSAB ){ /* The following two HTTP reply headers are required if javascript ** is to make use of SharedArrayBuffer */ nOut += althttpd_printf("Cross-Origin-Opener-Policy: same-origin\r\n"); nOut += althttpd_printf("Cross-Origin-Embedder-Policy: require-corp\r\n"); } nOut += althttpd_printf("Cache-Control: max-age=%d\r\n", mxAge); nOut += althttpd_printf("ETag: \"%s\"\r\n", zETag); nOut += althttpd_printf("Content-type: %s%s\r\n",zContentType, bAddCharset ? "; charset=utf-8" : ""); if( zEncoding ){ nOut += althttpd_printf("Content-encoding: %s\r\n", zEncoding); } |
︙ | ︙ | |||
3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 | }else if( strcmp(z,"-max-cpu")==0 ){ maxCpu = atoi(zArg); }else if( strcmp(z,"-loopback")==0 ){ bLocalhost = 1; nTerm = 1; }else if( strcmp(z,"-page")==0 ){ zPage = zArg; bLocalhost = 1; if( mnPort==0 ){ mnPort = 8080; mxPort = 8100; | > > > | 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 | }else if( strcmp(z,"-max-cpu")==0 ){ maxCpu = atoi(zArg); }else if( strcmp(z,"-loopback")==0 ){ bLocalhost = 1; nTerm = 1; }else if( strcmp(z,"-enable-sab")==0 ){ enableSAB = 1; }else if( strcmp(z,"-page")==0 ){ zPage = zArg; bLocalhost = 1; if( mnPort==0 ){ mnPort = 8080; mxPort = 8100; |
︙ | ︙ |