Althttpd

Check-in [186fc574ab]
Login

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

Overview
Comment:Do a better job of figuring out the correct SERVER_PORT. Forum post 462a113f0a.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 186fc574abf4df34405be753c04ab305b9c2a77ef2841d4cd2787f06821d47b7
User & Date: drh 2025-01-09 21:18:21
References
2025-01-09
21:19 Reply: SERVER_PORT cgi env value is dubious ... (artifact: 7f548b1fa3 user: drh)
Context
2025-01-12
11:44
Improvements, including better instructions in the header comment, to the static-ssl.mk makefile. ... (Leaf check-in: f14e96c1b5 user: drh tags: trunk)
2025-01-09
21:18
Do a better job of figuring out the correct SERVER_PORT. Forum post 462a113f0a. ... (check-in: 186fc574ab user: drh tags: trunk)
20:25
Comment out the TLS security enhancements, because we have received one report of it breaking the SQLite website. ... (check-in: 0c01b99d0a user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to althttpd.c.
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
  ** ourselves.
  */
  if( zServerName==0 ){
    zServerName = SafeMalloc( 100 );
    gethostname(zServerName,100);
  }
  if( zServerPort==0 || *zServerPort==0 ){
    zServerPort = DEFAULT_PORT;
  }

  /* Remove the query string from the end of the requested file.
  */
  for(z=zScript; *z && *z!='?'; z++){}
  if( *z=='?' ){
    zQuerySuffix = StrDup(z);







|







3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
  ** ourselves.
  */
  if( zServerName==0 ){
    zServerName = SafeMalloc( 100 );
    gethostname(zServerName,100);
  }
  if( zServerPort==0 || *zServerPort==0 ){
    zServerPort = zRealPort ? zRealPort : DEFAULT_PORT;
  }

  /* Remove the query string from the end of the requested file.
  */
  for(z=zScript; *z && *z!='?'; z++){}
  if( *z=='?' ){
    zQuerySuffix = StrDup(z);
3749
3750
3751
3752
3753
3754
3755


3756
3757
3758
3759
3760
3761
3762
    }else{
      fprintf(stderr,"unable to open listening socket on any"
                     " port in the range %d..%d\n", mnPort, mxPort);
    }
    althttpd_exit(1);
  }
  if( iPort>mxPort ) return 1;


  listen(listener,10);
  printf("Listening for %s requests on TCP port %d\n",
         useHttps?"TLS-encrypted HTTPS":"HTTP",  iPort);
  fflush(stdout);
  if( zPage ){
    child = fork();
    if( child!=0 ){







>
>







3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
    }else{
      fprintf(stderr,"unable to open listening socket on any"
                     " port in the range %d..%d\n", mnPort, mxPort);
    }
    althttpd_exit(1);
  }
  if( iPort>mxPort ) return 1;
  zRealPort = StrDup("            ");
  snprintf(zRealPort, 10, "%d", iPort);
  listen(listener,10);
  printf("Listening for %s requests on TCP port %d\n",
         useHttps?"TLS-encrypted HTTPS":"HTTP",  iPort);
  fflush(stdout);
  if( zPage ){
    child = fork();
    if( child!=0 ){
3898
3899
3900
3901
3902
3903
3904

3905
3906
3907
3908
3909
3910
3911
        useHttps = 0;
        zHttpScheme = "http";
        zHttps = 0;
      }else{
        zHttpScheme = "https";
        zHttps = "on";
        zRemoteAddr = getenv("REMOTE_HOST");

        useHttps = 1;
      }
    }else
    if( strcmp(z, "-port")==0 ){
      int ii;
      mnPort = mxPort = 0;
      for(ii=0; zArg[ii]>='0' && zArg[ii]<='9'; ii++){







>







3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
        useHttps = 0;
        zHttpScheme = "http";
        zHttps = 0;
      }else{
        zHttpScheme = "https";
        zHttps = "on";
        zRemoteAddr = getenv("REMOTE_HOST");
        if( zRealPort==0 ) zRealPort = "443";
        useHttps = 1;
      }
    }else
    if( strcmp(z, "-port")==0 ){
      int ii;
      mnPort = mxPort = 0;
      for(ii=0; zArg[ii]>='0' && zArg[ii]<='9'; ii++){