]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Support URIs in HTTP requests, per HTTP/1.1 spec.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Fri, 24 Jan 2003 15:06:03 +0000 (15:06 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Fri, 24 Jan 2003 15:06:03 +0000 (15:06 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@3136 7a7537e8-13f0-0310-91df-b6672ffda945

CHANGES.txt
scheduler/client.c

index 30e0af53b5c7d97479ab56a482c2360c2df5fbb2..8757b87016a86154c7271e3f5f9d6515a352edc7 100644 (file)
@@ -1,8 +1,10 @@
-CHANGES.txt - 01/23/2003
+CHANGES.txt - 01/24/2003
 ------------------------
 
 CHANGES IN CUPS V1.1.19
 
+       - The scheduler now supports URIs in HTTP request lines
+         to conform to the HTTP/1.1 specification.
        - The time-at-xyz attributes were not recognized in
          banner files if prefixed by a question mark, e.g.
          "{?time-at-creation}".
index ca128c5e7e27bcb4bd95bbfd11b4fd13752215be..51198d76644015537890acba600e58f558cc5c43 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: client.c,v 1.137 2003/01/17 14:42:27 mike Exp $"
+ * "$Id: client.c,v 1.138 2003/01/24 15:06:03 mike Exp $"
  *
  *   Client routines for the Common UNIX Printing System (CUPS) scheduler.
  *
@@ -685,6 +685,52 @@ ReadClient(client_t *con)  /* I - Client to read from */
              break;
        }
 
+       /*
+        * Handle full URLs in the request line...
+       */
+
+        if (con->uri[0] != '/')
+       {
+         char  method[HTTP_MAX_URI],           /* Method/scheme */
+               userpass[HTTP_MAX_URI],         /* Username:password */
+               hostname[HTTP_MAX_URI],         /* Hostname */
+               resource[HTTP_MAX_URI];         /* Resource path */
+          int  port;                           /* Port number */
+
+
+         /*
+         * Separate the URI into its components...
+         */
+
+          httpSeparate(con->uri, method, userpass, hostname, &port, resource);
+
+         /*
+         * Only allow URIs with the servername, localhost, or an IP
+         * address...
+         */
+
+         if (strcasecmp(hostname, ServerName) &&
+             strcasecmp(hostname, "localhost") &&
+             !isdigit(hostname[0]))
+         {
+          /*
+           * Nope, we don't do proxies...
+           */
+
+           LogMessage(L_ERROR, "Bad URI \"%s\" in request!", con->uri);
+           SendError(con, HTTP_METHOD_NOT_ALLOWED);
+           ShutdownClient(con);
+           return (1);
+         }
+
+         /*
+         * Copy the resource portion back into the URI; both resource and
+         * con->uri are HTTP_MAX_URI bytes in size...
+         */
+
+          strcpy(con->uri, resource);
+       }
+
        /*
         * Process the request...
        */
@@ -839,18 +885,6 @@ ReadClient(client_t *con)  /* I - Client to read from */
         return (0);
       }
     }
-    else if (con->uri[0] != '/')
-    {
-     /*
-      * Don't allow proxying (yet)...
-      */
-
-      if (!SendError(con, HTTP_METHOD_NOT_ALLOWED))
-      {
-       CloseClient(con);
-        return (0);
-      }
-    }
     else
     {
       if (strcasecmp(con->http.fields[HTTP_FIELD_CONNECTION], "Upgrade") == 0 &&
@@ -2755,5 +2789,5 @@ pipe_command(client_t *con,               /* I - Client connection */
 
 
 /*
- * End of "$Id: client.c,v 1.137 2003/01/17 14:42:27 mike Exp $".
+ * End of "$Id: client.c,v 1.138 2003/01/24 15:06:03 mike Exp $".
  */