Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Added "charset=utf-8" marks to the content type in althttpd.c. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
de32cdc42a3b650c2934d7de6fbd562d |
User & Date: | drh 2012-10-23 13:29:07.317 |
Context
2012-10-26
| ||
14:21 | Update althttpd.c to use getrusage() for finding run-time information for the log. Always wait for children prior to reporting child runtimes. (check-in: 357e7b7813 user: drh tags: trunk) | |
2012-10-23
| ||
13:29 | Added "charset=utf-8" marks to the content type in althttpd.c. (check-in: de32cdc42a user: drh tags: trunk) | |
2012-10-19
| ||
22:24 | Add a script for pushing builds of the website out to all three servers. Take care that draft builds are pushed only in the draft directory. (check-in: ac603d6340 user: drh tags: trunk) | |
Changes
Changes to misc/althttpd.c.
︙ | ︙ | |||
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | exit(0); } /* ** This is called if we timeout. */ static void Timeout(int NotUsed){ if( !debugFlag ){ strcpy(zReplyStatus, "999"); MakeLogEntry(0); exit(0); } } /* ** Tell the client that there is an error in the script. */ static void CgiScriptWritable(void){ StartResponse("500 CGI Configuration Error"); nOut += printf( | > | < < | | | < < | < < < < | 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | exit(0); } /* ** This is called if we timeout. */ static void Timeout(int NotUsed){ (void)NotUsed; if( !debugFlag ){ strcpy(zReplyStatus, "999"); MakeLogEntry(0); exit(0); } } /* ** Tell the client that there is an error in the script. */ static void CgiScriptWritable(void){ StartResponse("500 CGI Configuration Error"); nOut += printf( "Content-type: text/plain\r\n" "\r\n" "The CGI program %s is writable by users other than its owner.\n", zRealScript); MakeLogEntry(0); exit(0); } /* ** Tell the client that the server malfunctioned. */ static void Malfunction(int linenum, const char *zFormat, ...){ va_list ap; va_start(ap, zFormat); StartResponse("500 Server Malfunction"); nOut += printf( "Content-type: text/plain\r\n" "\r\n" "Web server malfunctioned; error number %d\n\n", linenum); if( zFormat ){ nOut += vprintf(zFormat, ap); } MakeLogEntry(0); exit(0); } /* ** Do a server redirect to the document specified. The document ** name not contain scheme or network location or the query string. |
︙ | ︙ | |||
662 663 664 665 666 667 668 | { "gl", 2, "video/gl" }, { "gtar", 4, "application/x-gtar" }, { "gz", 2, "application/x-gzip" }, { "hdf", 3, "application/x-hdf" }, { "hh", 2, "text/plain" }, { "hqx", 3, "application/mac-binhex40" }, { "h", 1, "text/plain" }, | | | | 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 | { "gl", 2, "video/gl" }, { "gtar", 4, "application/x-gtar" }, { "gz", 2, "application/x-gzip" }, { "hdf", 3, "application/x-hdf" }, { "hh", 2, "text/plain" }, { "hqx", 3, "application/mac-binhex40" }, { "h", 1, "text/plain" }, { "htm", 3, "text/html; charset=utf-8" }, { "html", 4, "text/html; charset=utf-8" }, { "ice", 3, "x-conference/x-cooltalk" }, { "ief", 3, "image/ief" }, { "iges", 4, "model/iges" }, { "igs", 3, "model/iges" }, { "ips", 3, "application/x-ipscript" }, { "ipx", 3, "application/x-ipix" }, { "jad", 3, "text/vnd.sun.j2me.app-descriptor" }, |
︙ | ︙ | |||
805 806 807 808 809 810 811 | { "xyz", 3, "chemical/x-pdb" }, { "zip", 3, "application/zip" }, }; for(i=nName-1; i>0 && zName[i]!='.'; i--){} z = &zName[i+1]; len = nName - i; | | | 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 | { "xyz", 3, "chemical/x-pdb" }, { "zip", 3, "application/zip" }, }; for(i=nName-1; i>0 && zName[i]!='.'; i--){} z = &zName[i+1]; len = nName - i; if( len<(int)sizeof(zSuffix)-1 ){ strcpy(zSuffix, z); for(i=0; zSuffix[i]; i++) zSuffix[i] = tolower(zSuffix[i]); first = 0; last = sizeof(aMime)/sizeof(aMime[0]); while( first<=last ){ int c; i = (first+last)/2; |
︙ | ︙ | |||
894 895 896 897 898 899 900 | nIn += strlen(zLine); zMethod = StrDup(GetFirstElement(zLine,&z)); zRealScript = zScript = StrDup(GetFirstElement(z,&z)); zProtocol = StrDup(GetFirstElement(z,&z)); if( zProtocol==0 || strncmp(zProtocol,"HTTP/",5)!=0 || strlen(zProtocol)!=8 ){ StartResponse("400 Bad Request"); nOut += printf( | | < < | < < | < | 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 | nIn += strlen(zLine); zMethod = StrDup(GetFirstElement(zLine,&z)); zRealScript = zScript = StrDup(GetFirstElement(z,&z)); zProtocol = StrDup(GetFirstElement(z,&z)); if( zProtocol==0 || strncmp(zProtocol,"HTTP/",5)!=0 || strlen(zProtocol)!=8 ){ StartResponse("400 Bad Request"); nOut += printf( "Content-type: text/plain\r\n" "\r\n" "This server does not understand the requested protocol\n" ); MakeLogEntry(0); exit(0); } if( zScript[0]==0 ) NotFound(__LINE__); if( forceClose ){ closeConnection = 1; }else if( zProtocol[5]<'1' || zProtocol[7]<'1' ){ closeConnection = 1; } /* This very simple server only understands the GET, POST ** and HEAD methods */ if( strcmp(zMethod,"GET")!=0 && strcmp(zMethod,"POST")!=0 && strcmp(zMethod,"HEAD")!=0 ){ StartResponse("501 Not Implemented"); nOut += printf( "Content-type: text/plain\r\n" "\r\n" "The %s method is not implemented on this server.\n", zMethod); MakeLogEntry(0); exit(0); } /* Get all the optional fields that follow the first line. */ |
︙ | ︙ | |||
1037 1038 1039 1040 1041 1042 1043 | FILE *out; char *zBuf; int n; if( len>MAX_CONTENT_LENGTH ){ StartResponse("500 Request too large"); nOut += printf( | | < | | < | 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 | FILE *out; char *zBuf; int n; if( len>MAX_CONTENT_LENGTH ){ StartResponse("500 Request too large"); nOut += printf( "Content-type: text/plain\r\n" "\r\n" "Too much POST data\n" ); MakeLogEntry(0); exit(0); } sprintf(zTmpNamBuf, "/tmp/-post-data-XXXXXX"); zTmpNam = zTmpNamBuf; mkstemp(zTmpNam); out = fopen(zTmpNam,"w"); if( out==0 ){ StartResponse("500 Cannot create /tmp file"); nOut += printf( "Content-type: text/plain\r\n" "\r\n" "Could not open \"%s\" for writing\n", zTmpNam ); MakeLogEntry(0); exit(0); } zBuf = SafeMalloc( len ); if( useTimeout ) alarm(15 + len/2000); n = fread(zBuf,1,len,stdin); |
︙ | ︙ | |||
1267 1268 1269 1270 1271 1272 1273 | char zBuf[1000]; Malfunction(__LINE__, "cannot chdir to [%s] from [%s]", zDir, getcwd(zBuf,999)); } /* Setup the environment appropriately. */ | | | 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 | char zBuf[1000]; Malfunction(__LINE__, "cannot chdir to [%s] from [%s]", zDir, getcwd(zBuf,999)); } /* Setup the environment appropriately. */ for(i=0; i<(int)(sizeof(cgienv)/sizeof(cgienv[0])); i++){ if( *cgienv[i].pzEnvValue ){ SetEnv(cgienv[i].zEnvName,*cgienv[i].pzEnvValue); } } if( useHttps ){ putenv("HTTPS=on"); } |
︙ | ︙ | |||
1517 1518 1519 1520 1521 1522 1523 | sHints.ai_protocol = 0; rc = getaddrinfo(localOnly ? "localhost": 0, zPort, &sHints, &pAddrs); if( rc ){ fprintf(stderr, "could not get addr info: %s", rc!=EAI_SYSTEM ? gai_strerror(rc) : strerror(errno)); return 1; } | | | 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 | sHints.ai_protocol = 0; rc = getaddrinfo(localOnly ? "localhost": 0, zPort, &sHints, &pAddrs); if( rc ){ fprintf(stderr, "could not get addr info: %s", rc!=EAI_SYSTEM ? gai_strerror(rc) : strerror(errno)); return 1; } for(n=0, p=pAddrs; n<(int)(sizeof(listener)/sizeof(listener[0])) && p!=0; p=p->ai_next){ listener[n] = socket(p->ai_family, p->ai_socktype, p->ai_protocol); if( listener[n]>=0 ){ /* if we can't terminate nicely, at least allow the socket to be reused */ setsockopt(listener[n], SOL_SOCKET, SO_REUSEADDR,&opt, sizeof(opt)); #if defined(IPV6_V6ONLY) |
︙ | ︙ |