Documentation Source Text

Check-in [efdc1b8e66]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Change althttpd.c to search for /home after /index.html if not filename is given.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: efdc1b8e6676e7fa9dd9cf933b50b1378e8cfbf940e74ef25a8915d2207db4c2
User & Date: drh 2019-04-18 16:34:39
Context
2019-04-18
16:39
Althttpd now prefers /home over /index.html if it exists. check-in: 87856f6c54 user: drh tags: trunk
16:34
Change althttpd.c to search for /home after /index.html if not filename is given. check-in: efdc1b8e66 user: drh tags: trunk
2019-04-17
19:17
Remove unmatched close parenthesis from fileformat.html. check-in: 41027bf4a9 user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to misc/althttpd.c.

1916
1917
1918
1919
1920
1921
1922

1923


1924
1925
1926
1927
1928
1929
1930

1931


1932
1933
1934
1935
1936
1937
1938
      if( access(zLine,R_OK) ){
        NotFound(390);  /* LOG: File not readable */
      }
      zRealScript = StrDup(&zLine[j0]);
      break;
    }
    if( zScript[i]==0 || zScript[i+1]==0 ){

      int k = j>0 && zLine[j-1]=='/' ? j-1 : j;


      strcpy(&zLine[k],"/index.html");
      if( stat(zLine,&statbuf)!=0 || !S_ISREG(statbuf.st_mode) 
      || access(zLine,R_OK) ){
        strcpy(&zLine[k],"/index.cgi");
        if( stat(zLine,&statbuf)!=0 || !S_ISREG(statbuf.st_mode) 
        || access(zLine,R_OK) ){
          NotFound(400); /* LOG: URI is a directory w/o index.html */

        }


      }
      zRealScript = StrDup(&zLine[j0]);
      if( zScript[i]==0 ){
        /* If the requested URL does not end with "/" but we had to
        ** append "index.html", then a redirect is necessary.  Otherwise
        ** none of the relative URLs in the delivered document will be
        ** correct. */







>

>
>
|
|
<
<
|
|
<
>
|
>
>







1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928


1929
1930

1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
      if( access(zLine,R_OK) ){
        NotFound(390);  /* LOG: File not readable */
      }
      zRealScript = StrDup(&zLine[j0]);
      break;
    }
    if( zScript[i]==0 || zScript[i+1]==0 ){
      static const char *azIndex[] = { "/index.html", "/home", "index.cgi" };
      int k = j>0 && zLine[j-1]=='/' ? j-1 : j;
      int jj;
      for(jj=0; jj<sizeof(azIndex)/sizeof(azIndex[0]); jj++){
        strcpy(&zLine[k],azIndex[jj]);
        if( stat(zLine,&statbuf)!=0 ) continue;


        if( !S_ISREG(statbuf.st_mode) ) continue;
        if( access(zLine,R_OK) ) continue;

        break;
      }
      if( jj>=sizeof(azIndex)/sizeof(azIndex[0]) ){
        NotFound(400); /* LOG: URI is a directory w/o index.html */
      }
      zRealScript = StrDup(&zLine[j0]);
      if( zScript[i]==0 ){
        /* If the requested URL does not end with "/" but we had to
        ** append "index.html", then a redirect is necessary.  Otherwise
        ** none of the relative URLs in the delivered document will be
        ** correct. */