Documentation Source Text

Check-in [8ad926dff3]
Login

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

Overview
Comment:Althttpd changes: Make Redirect() much faster by avoiding timeouts. When a document it not found, search the either path for a not-found.html file to display and redirect to that file.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8ad926dff34cbcfc0494936e2dfdcf458932624f
User & Date: drh 2012-06-19 15:00:06
Context
2012-06-20
08:42
Add "Flame" as a notorious user of SQLite. check-in: 8c4c1ef51e user: drh tags: trunk
2012-06-19
15:00
Althttpd changes: Make Redirect() much faster by avoiding timeouts. When a document it not found, search the either path for a not-found.html file to display and redirect to that file. check-in: 8ad926dff3 user: drh tags: trunk
14:08
In althttpd, if the requested file is not found, look for the "not-found.html" file in the same directory and use it instead. check-in: e4391f7f58 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to misc/althttpd.c.

468
469
470
471
472
473
474

475
476
477

478
479
480
481
482
483
484
....
1147
1148
1149
1150
1151
1152
1153


1154
1155
1156
1157
1158
1159




1160

1161

1162
1163
1164
1165
1166
1167
1168
    nOut += printf("Location: %s://%s%s%s\r\n",
                   zHttp, zServerName, zPath, zQuerySuffix);
  }else{
    nOut += printf("Location: %s://%s:%s%s%s\r\n",
                   zHttp, zServerName, zServerPort, zPath, zQuerySuffix);
  }
  if( finish ){

    nOut += printf("\r\n");
    MakeLogEntry(0);
  }

}

/*
** This function treats its input as a base-64 string and returns the
** decoded value of that string.  Characters of input that are not
** valid base-64 characters (such as spaces and newlines) are ignored.
*/
................................................................................
  while( zScript[i] ){
    while( zScript[i] && zScript[i]!='/' ){
      zLine[i+1] = zScript[i];
      i++;
    }
    zLine[i+1] = 0;
    if( stat(zLine,&statbuf)!=0 ){


      while( i>0 && zLine[i]!='/' ){ i--; }
      strcpy(&zLine[i], "/not-found.html");
      if( stat(zLine,&statbuf)==0 && S_ISREG(statbuf.st_mode)
          && access(zLine,R_OK)==0 ){
        zRealScript = StrDup(&zLine[1]);
        break;




      }

      NotFound(__LINE__);

    }
    if( S_ISREG(statbuf.st_mode) ){
      if( access(zLine,R_OK) ){
        NotFound(__LINE__);
      }
      zRealScript = StrDup(&zLine[1]);
      break;







>



>







 







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







468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
....
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162

1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
    nOut += printf("Location: %s://%s%s%s\r\n",
                   zHttp, zServerName, zPath, zQuerySuffix);
  }else{
    nOut += printf("Location: %s://%s:%s%s%s\r\n",
                   zHttp, zServerName, zServerPort, zPath, zQuerySuffix);
  }
  if( finish ){
    printf("Content-length: 0\r\n");
    nOut += printf("\r\n");
    MakeLogEntry(0);
  }
  fflush(stdout);
}

/*
** This function treats its input as a base-64 string and returns the
** decoded value of that string.  Characters of input that are not
** valid base-64 characters (such as spaces and newlines) are ignored.
*/
................................................................................
  while( zScript[i] ){
    while( zScript[i] && zScript[i]!='/' ){
      zLine[i+1] = zScript[i];
      i++;
    }
    zLine[i+1] = 0;
    if( stat(zLine,&statbuf)!=0 ){
      int stillSearching = 1;
      while( stillSearching && i>0 ){
        while( i>0 && zLine[i]!='/' ){ i--; }
        strcpy(&zLine[i], "/not-found.html");
        if( stat(zLine,&statbuf)==0 && S_ISREG(statbuf.st_mode)
            && access(zLine,R_OK)==0 ){
          zRealScript = StrDup(&zLine[1]);

          Redirect(zRealScript, 1);
          return;
        }else{
          i--;
        }
      }
      if( stillSearching ) NotFound(__LINE__);
      break;
    }
    if( S_ISREG(statbuf.st_mode) ){
      if( access(zLine,R_OK) ){
        NotFound(__LINE__);
      }
      zRealScript = StrDup(&zLine[1]);
      break;