/*
- * "$Id: client.c,v 1.91.2.37 2003/01/24 14:47:56 mike Exp $"
+ * "$Id: client.c,v 1.91.2.38 2003/01/24 15:28:06 mike Exp $"
*
* Client routines for the Common UNIX Printing System (CUPS) scheduler.
*
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...
*/
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 &&
/*
- * End of "$Id: client.c,v 1.91.2.37 2003/01/24 14:47:56 mike Exp $".
+ * End of "$Id: client.c,v 1.91.2.38 2003/01/24 15:28:06 mike Exp $".
*/