]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/http-support.c
Remove svn:keywords since they cause svn_load_dirs.pl to complain about every file.
[thirdparty/cups.git] / cups / http-support.c
index 1ad095baed52435105e223e8e2600ec3ad354288..674e0db2c79cc62f3f8cc8e873a1b651a5feb0e8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$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.
  *
@@ -104,9 +104,10 @@ static char                *http_copy_encode(char *dst, const char *src,
  * '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@
  */
@@ -351,9 +352,10 @@ httpAssembleURI(
  *                        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@
  */
@@ -408,6 +410,11 @@ httpAssembleURIf(
 
 /*
  * '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 */
@@ -531,6 +538,11 @@ httpDecode64_2(char       *out,            /* I  - String to write to */
 
 /*
  * '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 */
@@ -733,6 +745,10 @@ httpGetDateTime(const char *s)             /* I - Date/time string */
 /*
  * 'httpSeparate()' - Separate a Universal Resource Identifier into its
  *                    components.
+ *
+ * This function is deprecated; use the httpSeparateURI() function instead.
+ *
+ * @deprecated@
  */
 
 void
@@ -753,7 +769,10 @@ httpSeparate(const char *uri,              /* I - Universal Resource Identifier */
  * '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
@@ -984,7 +1003,25 @@ httpSeparateURI(
     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, ":?/",
@@ -995,21 +1032,6 @@ httpSeparateURI(
         *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);
-       }
     }
 
    /*
@@ -1035,7 +1057,7 @@ httpSeparateURI(
 
       *port = strtol(uri + 1, (char **)&uri, 10);
 
-      if (*uri != '/')
+      if (*uri != '/' && *uri)
       {
         *port = 0;
         return (HTTP_URI_BAD_PORT);
@@ -1119,6 +1141,10 @@ httpStatus(http_status_t status) /* I - HTTP status code */
         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 :
@@ -1139,6 +1165,9 @@ httpStatus(http_status_t status)  /* I - HTTP status code */
         return ("Not Implemented");
     case HTTP_NOT_SUPPORTED :
         return ("Not Supported");
+    case HTTP_EXPECTATION_FAILED :
+        return ("Expectation Failed");
+
     default :
         return ("Unknown");
   }
@@ -1287,5 +1316,5 @@ http_copy_encode(char       *dst, /* O - Destination buffer */
 
 
 /*
- * 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 $".
  */