You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Robert S. Thau" <rs...@ai.mit.edu> on 1995/03/28 18:39:02 UTC

Another person with NCSA code hacks...

Saw this on USENET; note that the fellow has a lot of interesting
plans.  Perhaps we should invite him in?

rst

From: borud@itea.unit.no (Bjxrn Borud)
Newsgroups: no.www,comp.infosystems.www.providers,comp.infosystems.www
Subject: NCSA compliant cgi env. patch (Re: NCSA httpd 1.3 referer hack)
Message-ID: <BO...@istind.itea.unit.no>

[Carlos A. Pero]
 |
 |NCSA httpd 1.4 will be released in the next couple of weeks.  It is
 |currently under beta-testing.  It has provisions for HTTP_REFERER
 |(referring document) and HTTP_USER_AGENT (which browser), and allows
 |logging to a separate file so as not to break the COMMON log file
 |format.


Okay, I changed my patch a bit:

  o Changed REFERER to HTTP_REFERER for cgi environment.
  o Added HTTP_USER_AGENT for cgi environment.

Now you'll be able to do scripts that are compatible with 1.4 before
1.4 hits the sites. Whee.  Thought about adding logging to a separate
file so I can log user-agent too, but I don't have the time to do that
properly; se below...
Oh BTW. This patch still logs the "Referer:" field to the access_log. 


Stuff I'm CONSIDERING to do:

  o source file selection based on user-agent type, host
    address etc. (So people who have HTML 3.0 compliant clients
    get HTML 3.0 docs if available etc).

  o config file so users can assign mime types to speciffic files
    regardless of suffix. (yes, it'll be ugly and slow, but I would
    like to have the option to do so)

  o integration of the imagemap program into httpd.

  o Custom logging where you define the path of the logfile
    and what fields go where in the config files.

...and a few other things that didn't pop to mind as I wrote this.


This patch replaces the previous patch. Compile the server with
-DBORUD_HACKS.  Feel free to mail me if you actually use the patch...

WARNING: this patch might break something so you add it at your
         own risk.

------------------8<---------------------------------------------

*** 1.1	1995/03/27 11:01:32
--- http_mime.c	1995/03/28 10:18:49
***************
*** 28,33 ****
--- 28,37 ----
  int content_length;
  char content_type[MAX_STRING_LEN];
  char content_encoding[MAX_STRING_LEN];
+ #ifdef BORUD_HACKS
+ char the_referer[MAX_STRING_LEN];
+ char the_user_agent[MAX_STRING_LEN];
+ #endif
  
  char location[MAX_STRING_LEN];
  static char last_modified[MAX_STRING_LEN];
***************
*** 332,337 ****
--- 336,345 ----
      status_line = NULL;
      out_headers = NULL;
      in_headers_env = NULL;
+ #ifdef BORUD_HACKS
+     the_referer[0] = '\0';
+     the_user_agent[0] = '\0';
+ #endif
  }
  
  int merge_header(char *h, char *v, FILE *out) {
***************
*** 376,381 ****
--- 384,403 ----
          *t++ = '\0';
          while(isspace(*t)) ++t;
          strcpy(l,t);
+ 
+ #ifdef BORUD_HACKS
+ 
+         if(!strcasecmp(w,"Referer")) {
+           strcpy(the_referer,l);
+           continue;
+         }
+ 
+         if(!strcasecmp(w,"User-Agent")) {
+           strcpy(the_user_agent,l);
+           continue;
+         }
+ 
+ #endif
  
          if(!strcasecmp(w,"Content-type")) {
              strcpy(content_type,l);
*** 1.1	1995/03/27 11:00:45
--- http_log.c	1995/03/28 10:07:45
***************
*** 89,94 ****
--- 89,102 ----
          sprintf(str,"%s%d",str,bytes_sent);
      else
          strcat(str,"- ");
+ 
+ #ifdef BORUD_HACKS
+ 
+ /* Let's break dumb log-analyzers, huh? */
+ 
+     sprintf(str,"%s [%s]",str,(the_referer[0] ? the_referer : "none"));
+ #endif
+ 
      fprintf(xfer_log,"%s\n",str);
      fclose(xfer_log);
  }
*** 1.1	1995/03/27 12:00:24
--- http_script.c	1995/03/28 10:26:47
***************
*** 5,10 ****
--- 5,14 ----
   * 
   * Rob McCool
   *
+  * (Additional hacks by B. Borud)
+  * 
+  * $Id: http_script.c,v 1.2 1995/03/27 13:32:53 borud Exp borud $
+  *
   */
  
  #include "httpd.h"
***************
*** 109,114 ****
--- 113,128 ----
          env[x++] = make_env_str("PATH_TRANSLATED",t2,out);
      }
      env[x++] = make_env_str("QUERY_STRING",args,out);
+ 
+ #ifdef BORUD_HACKS
+ 
+ /* NCSA are adding these in the next version..*/
+ /* ..which is due Real Soon Now               */
+ 
+     env[x++] = make_env_str("HTTP_REFERER",the_referer,out);
+     env[x++] = make_env_str("HTTP_USER_AGENT",the_user_agent,out);
+ 
+ #endif
  
      if(content) {
          *content=0;
*** 1.1	1995/03/27 13:04:52
--- httpd.h	1995/03/28 10:06:06
***************
*** 458,463 ****
--- 458,467 ----
  extern char content_type[MAX_STRING_LEN];
  extern char content_encoding[MAX_STRING_LEN];
  extern char location[MAX_STRING_LEN];
+ #ifdef BORUD_HACKS
+ extern char the_referer[MAX_STRING_LEN];
+ extern char the_user_agent[MAX_STRING_LEN];
+ #endif
  extern char **in_headers_env;
  
  /* http_log */

------------------8<---------------------------------------------

-Bjorn

--
__________________________________________________________
## Bjorn Borud  ## mail: Bjorn.Borud@alkymi.unit.no     ##
## PVV/NVG/ITEA ## WWW : http://www.pvv.unit.no/~borud/ ##
##  Ozelot@IRC  ## PGP : finger ozelot@irc.nvg.unit.no  ##