/*
- * "$Id: http-support.c 5035 2006-02-01 14:58:46Z mike $"
+ * "$Id: http-support.c 177 2006-06-21 00:20:03Z jlovell $"
*
* HTTP support routines for the Common UNIX Printing System (CUPS) scheduler.
*
* 'httpAssembleURI()' - Assemble a uniform resource identifier from its
* components.
*
- * This function properly escapes all reserved characters in a URI. You
- * should use this function in place of traditional string functions
- * whenever you need to create a URI string.
+ * This function escapes reserved characters in the URI depending on the
+ * value of the "encoding" argument. You should use this function in
+ * place of traditional string functions whenever you need to create a
+ * URI string.
*
* @since CUPS 1.2@
*/
* components with a formatted resource.
*
* This function creates a formatted version of the resource string
- * argument "resourcef" and properly escapes all reserved characters
- * in a URI. You should use this function in place of traditional
- * string functions whenever you need to create a URI string.
+ * argument "resourcef" and escapes reserved characters in the URI
+ * depending on the value of the "encoding" argument. You should use
+ * this function in place of traditional string functions whenever
+ * you need to create a URI string.
*
* @since CUPS 1.2@
*/
/*
* 'httpDecode64()' - Base64-decode a string.
+ *
+ * This function is deprecated. Use the httpDecode64_2() function instead
+ * which provides buffer length arguments.
+ *
+ * @deprecated@
*/
char * /* O - Decoded string */
/*
* 'httpEncode64()' - Base64-encode a string.
+ *
+ * This function is deprecated. Use the httpEncode64_2() function instead
+ * which provides buffer length arguments.
+ *
+ * @deprecated@
*/
char * /* O - Encoded string */
/*
* 'httpSeparate()' - Separate a Universal Resource Identifier into its
* components.
+ *
+ * This function is deprecated; use the httpSeparateURI() function instead.
+ *
+ * @deprecated@
*/
void
* 'httpSeparate2()' - Separate a Universal Resource Identifier into its
* components.
*
+ * This function is deprecated; use the httpSeparateURI() function instead.
+ *
* @since CUPS 1.1.21@
+ * @deprecated@
*/
void
else
{
/*
- * Grab hostname or IPv4 address...
+ * Validate the hostname or IPv4 address first...
+ */
+
+ for (ptr = (char *)uri; *ptr; ptr ++)
+ if (strchr(":?/", *ptr))
+ break;
+ else if (!strchr("abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789"
+ "-._~"
+ "%"
+ "!$&'()*+,;=", *ptr))
+ {
+ *host = '\0';
+ return (HTTP_URI_BAD_HOSTNAME);
+ }
+
+ /*
+ * Then copy the hostname or IPv4 address to the buffer...
*/
uri = http_copy_decode(host, uri, hostlen, ":?/",
*host = '\0';
return (HTTP_URI_BAD_HOSTNAME);
}
-
- /*
- * Validate value...
- */
-
- for (ptr = host; *ptr; ptr ++)
- if (!strchr("abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789"
- "-._~"
- "!$&'()*+,;=", *ptr))
- {
- *host = '\0';
- return (HTTP_URI_BAD_HOSTNAME);
- }
}
/*
*port = strtol(uri + 1, (char **)&uri, 10);
- if (*uri != '/')
+ if (*uri != '/' && *uri)
{
*port = 0;
return (HTTP_URI_BAD_PORT);
return ("Accepted");
case HTTP_NO_CONTENT :
return ("No Content");
+ case HTTP_MOVED_PERMANENTLY :
+ return ("Moved Permanently");
+ case HTTP_SEE_OTHER :
+ return ("See Other");
case HTTP_NOT_MODIFIED :
return ("Not Modified");
case HTTP_BAD_REQUEST :
return ("Not Implemented");
case HTTP_NOT_SUPPORTED :
return ("Not Supported");
+ case HTTP_EXPECTATION_FAILED :
+ return ("Expectation Failed");
+
default :
return ("Unknown");
}
/*
- * End of "$Id: http-support.c 5035 2006-02-01 14:58:46Z mike $".
+ * End of "$Id: http-support.c 177 2006-06-21 00:20:03Z jlovell $".
*/