Documentation Source Text

Check-in [155df5701c]
Login

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

Overview
Comment:When the request URI for static content contains extra path elements, report the error as 404 instead of 301.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 155df5701cde6d4af8682812366a5b8ea52c93b2
User & Date: drh 2013-12-16 21:42:57.296
Context
2013-12-17
16:33
Documentation for the printf() SQL function. (check-in: 9cbe2e4d08 user: drh tags: trunk)
2013-12-16
21:42
When the request URI for static content contains extra path elements, report the error as 404 instead of 301. (check-in: 155df5701c user: drh tags: trunk)
21:30
In althttpd, keep track of wall-clock time in milliseconds, not seconds. And for the user and system times, be sure to subtract out the user and system times for prior requests on the same connection. (check-in: 333c090d36 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to misc/althttpd.c.
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
    if( useTimeout ) alarm(60*5);
    while( (c = getc(in))!=EOF ){
      putc(c,stdout);
      nOut++;
    }
    fclose(in);
  }else if( countSlashes(zRealScript)!=countSlashes(zScript) ){
    /* The URI refers to a non-executable file so it is static content.  But
    ** there are extra terms in the URI past the end of the content.  We need
    ** to redirected to that relative URLs in the content will be right.
    */
    StartResponse("301 Moved Permanently");
    if( zServerPort==0 || zServerPort[0]==0 || strcmp(zServerPort,"80")==0 ){
      nOut += printf("Location: %s://%s%s\r\n",
                     zHttp, zServerName, zRealScript);
    }else{
      nOut += printf("Location: %s://%s:%s%s\r\n",
                     zHttp, zServerName, zServerPort, zRealScript);
    }
    nOut += printf("Content-length: 0\r\n");
    nOut += printf("\r\n");
    MakeLogEntry(0);
    fflush(stdout);
  }else{
    /* If it isn't executable then it
    ** must a simple file that needs to be copied to output.
    */
    const char *zContentType = GetMimeType(zFile, lenFile);

    if( zTmpNam ) unlink(zTmpNam);







|
<
<
<
<
<
<
<
<
<
<
<
|
<
<
|







1471
1472
1473
1474
1475
1476
1477
1478











1479


1480
1481
1482
1483
1484
1485
1486
1487
    if( useTimeout ) alarm(60*5);
    while( (c = getc(in))!=EOF ){
      putc(c,stdout);
      nOut++;
    }
    fclose(in);
  }else if( countSlashes(zRealScript)!=countSlashes(zScript) ){
    /* If the request URI for static content contains material past the











    ** actual content file name, report that as a 404 error. */


    NotFound(__LINE__);
  }else{
    /* If it isn't executable then it
    ** must a simple file that needs to be copied to output.
    */
    const char *zContentType = GetMimeType(zFile, lenFile);

    if( zTmpNam ) unlink(zTmpNam);