Diff
Not logged in

Differences From:

File src/cgi.c part of check-in [c3a30a6b80] - Add cache-control: no-cache to the server reply header. Ticket b465b3bc2ceef4446b2ae770242ed0968e4dbc68 by drh on 2009-03-31 17:33:05. [view]

To:

File src/cgi.c part of check-in [7a2c37063a] - merge trunk into creole branch by bob on 2009-09-22 07:49:39. Also file src/cgi.c part of check-in [fac950a173] - Update to the latest version of SQLite. Make use of the new sqlite3_strnicmp() interface. by drh on 2009-09-09 16:14:08. [view]

@@ -41,8 +41,11 @@
 #  include <sys/time.h>
 #  include <sys/wait.h>
 #  include <sys/select.h>
 #endif
+#ifdef __EMX__
+   typedef int socklen_t;
+#endif
 #include <time.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -66,15 +69,8 @@
 #define CGI_HEADER   0
 #define CGI_BODY     1
 
 #endif /* INTERFACE */
-
-/*
-** Provide a reliable implementation of a caseless string comparison
-** function.
-*/
-#define stricmp sqlite3StrICmp
-extern int sqlite3StrICmp(const char*, const char*);
 
 /*
 ** The HTTP reply is generated in two pieces: the header and the body.
 ** These pieces are generated separately because they are not necessary
@@ -642,19 +638,20 @@
     }else{
       nArg = tokenize_line(zLine, sizeof(azArg)/sizeof(azArg[0]), azArg);
       for(i=0; i<nArg; i++){
         int c = tolower(azArg[i][0]);
-        if( c=='c' && stricmp(azArg[i],"content-disposition:")==0 ){
+        int n = strlen(azArg[i]);
+        if( c=='c' && sqlite3_strnicmp(azArg[i],"content-disposition:",n)==0 ){
           i++;
-        }else if( c=='n' && stricmp(azArg[i],"name=")==0 ){
+        }else if( c=='n' && sqlite3_strnicmp(azArg[i],"name=",n)==0 ){
           zName = azArg[++i];
-        }else if( c=='f' && stricmp(azArg[i],"filename=")==0 ){
+        }else if( c=='f' && sqlite3_strnicmp(azArg[i],"filename=",n)==0 ){
           char *z = azArg[++i];
           if( zName && z && islower(zName[0]) ){
             cgi_set_parameter_nocopy(mprintf("%s:filename",zName), z);
           }
           showBytes = 1;
-        }else if( c=='c' && stricmp(azArg[i],"content-type:")==0 ){
+        }else if( c=='c' && sqlite3_strnicmp(azArg[i],"content-type:",n)==0 ){
           char *z = azArg[++i];
           if( zName && z && islower(zName[0]) ){
             cgi_set_parameter_nocopy(mprintf("%s:mimetype",zName), z);
           }
@@ -678,8 +675,11 @@
   if( z ){
     z = mprintf("%s",z);
     add_param_list(z, '&');
   }
+
+  z = (char*)P("REMOTE_ADDR");
+  if( z ) g.zIpAddr = mprintf("%s", z);
 
   len = atoi(PD("CONTENT_LENGTH", "0"));
   g.zContentType = zType = P("CONTENT_TYPE");
   if( len>0 && zType ){