IJB now changes HTTP/1.1 to HTTP/1.0 in requests and answers.
authorjoergs <joergs@users.sourceforge.net>
Sat, 29 Sep 2001 12:56:03 +0000 (12:56 +0000)
committerjoergs <joergs@users.sourceforge.net>
Sat, 29 Sep 2001 12:56:03 +0000 (12:56 +0000)
parsers.c
parsers.h

index f9a8841..f2364d4 100644 (file)
--- a/parsers.c
+++ b/parsers.c
@@ -1,4 +1,4 @@
-const char parsers_rcs[] = "$Id: parsers.c,v 1.28 2001/09/22 16:32:28 jongfoster Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.29 2001/09/24 21:09:24 jongfoster Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.c,v $
@@ -41,6 +41,10 @@ const char parsers_rcs[] = "$Id: parsers.c,v 1.28 2001/09/22 16:32:28 jongfoster
  *
  * Revisions   :
  *    $Log: parsers.c,v $
  *
  * Revisions   :
  *    $Log: parsers.c,v $
+ *    Revision 1.29  2001/09/24 21:09:24  jongfoster
+ *    Fixing 2 memory leaks that Guy spotted, where the paramater to
+ *    enlist() was not being free()d.
+ *
  *    Revision 1.28  2001/09/22 16:32:28  jongfoster
  *    Removing unused #includes.
  *
  *    Revision 1.28  2001/09/22 16:32:28  jongfoster
  *    Removing unused #includes.
  *
@@ -302,6 +306,7 @@ const struct parsers client_patterns[] = {
 
 
 const struct parsers server_patterns[] = {
 
 
 const struct parsers server_patterns[] = {
+   { "HTTP/1.1 ",           9, server_http11 },
    { "set-cookie:",        11, server_set_cookie },
    { "connection:",        11, crumble },
    { "Content-Type:",      13, content_type },
    { "set-cookie:",        11, server_set_cookie },
    { "connection:",        11, crumble },
    { "Content-Type:",      13, content_type },
@@ -618,10 +623,25 @@ void parse_http_request(char *req, struct http_request *http, struct client_stat
        || (0 == strcmpic(v[0], "unlock"))
        )
       {
        || (0 == strcmpic(v[0], "unlock"))
        )
       {
-         http->ssl      = 0;
-         http->gpc      = strdup(v[0]);
-         url            = v[1];
-         http->ver      = strdup(v[2]);
+         http->ssl    = 0;
+         http->gpc    = strdup(v[0]);
+         url          = v[1];
+         /* since we don't support HTTP/1.1 we must not send it */
+         if (!strcmpic(v[2], "HTTP/1.1"))
+         {
+            http->ver = strdup("HTTP/1.0");
+            /* change cmd too (forwaring) */
+            freez(http->cmd);
+            http->cmd = strsav(http->cmd, http->gpc);
+            http->cmd = strsav(http->cmd, " ");
+            http->cmd = strsav(http->cmd, url);
+            http->cmd = strsav(http->cmd, " ");
+            http->cmd = strsav(http->cmd, http->ver);
+         }
+         else
+         {
+            http->ver = strdup(v[2]);
+         }
 
         save_url = url;
          if (strncmpic(url, "http://",  7) == 0)
 
         save_url = url;
          if (strncmpic(url, "http://",  7) == 0)
@@ -1294,6 +1314,32 @@ void connection_close_adder(struct client_state *csp)
 }
 
 
 }
 
 
+/*********************************************************************
+ *
+ * Function    :  server_http11
+ *
+ * Description :  Rewrite HTTP/1.1 answers to HTTP/1.0 until we add
+ *                HTTP/1.1 support. Called from `sed'.
+ *
+ * Parameters  :
+ *          1  :  v = parser pattern that matched this header
+ *          2  :  s = header that matched this pattern
+ *          3  :  csp = Current client state (buffers, headers, etc...)
+ *
+ * Returns     :  "HTTP/1.0" answer.
+ *
+ *********************************************************************/
+char *server_http11(const struct parsers *v, const char *s, struct client_state *csp)
+{
+   char *ret;
+
+   ret = strdup(s);
+   ret[7] = '0'; /* "HTTP/1.1 ..." -> "HTTP/1.0 ..." */
+
+   return ret;
+}
+
+
 /*********************************************************************
  *
  * Function    :  server_set_cookie
 /*********************************************************************
  *
  * Function    :  server_set_cookie
index 843c2b5..0887c47 100644 (file)
--- a/parsers.h
+++ b/parsers.h
@@ -1,6 +1,6 @@
 #ifndef PARSERS_H_INCLUDED
 #define PARSERS_H_INCLUDED
 #ifndef PARSERS_H_INCLUDED
 #define PARSERS_H_INCLUDED
-#define PARSERS_H_VERSION "$Id: parsers.h,v 1.11 2001/07/31 14:46:53 oes Exp $"
+#define PARSERS_H_VERSION "$Id: parsers.h,v 1.12 2001/09/13 23:05:50 jongfoster Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.h,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.h,v $
@@ -43,6 +43,9 @@
  *
  * Revisions   :
  *    $Log: parsers.h,v $
  *
  * Revisions   :
  *    $Log: parsers.h,v $
+ *    Revision 1.12  2001/09/13 23:05:50  jongfoster
+ *    Changing the string paramater to the header parsers a "const".
+ *
  *    Revision 1.11  2001/07/31 14:46:53  oes
  *    Added prototype for connection_close_adder
  *
  *    Revision 1.11  2001/07/31 14:46:53  oes
  *    Added prototype for connection_close_adder
  *
@@ -133,6 +136,7 @@ extern void connection_close_adder(struct client_state *csp);
 extern void client_x_forwarded_adder(struct client_state *csp);
 
 extern char *server_set_cookie(const struct parsers *v, const char *s, struct client_state *csp);
 extern void client_x_forwarded_adder(struct client_state *csp);
 
 extern char *server_set_cookie(const struct parsers *v, const char *s, struct client_state *csp);
+extern char *server_http11(const struct parsers *v, const char *s, struct client_state *csp);
 
 extern char *content_type(const struct parsers *v, const char *s, struct client_state *csp);
 extern char *content_length(const struct parsers *v, const char *s, struct client_state *csp);
 
 extern char *content_type(const struct parsers *v, const char *s, struct client_state *csp);
 extern char *content_length(const struct parsers *v, const char *s, struct client_state *csp);