[Gd-chatter] r11144 - trunk/libraries/network/koala/sources/koala

turbo24prg at gwydiondylan.org turbo24prg at gwydiondylan.org
Wed Jan 24 19:05:10 CET 2007


Author: turbo24prg
Date: Wed Jan 24 19:05:07 2007
New Revision: 11144

Modified:
   trunk/libraries/network/koala/sources/koala/config.dylan
   trunk/libraries/network/koala/sources/koala/library-unix.dylan
   trunk/libraries/network/koala/sources/koala/server.dylan
Log:
Job: koala
 * implemented <http-file>


Modified: trunk/libraries/network/koala/sources/koala/config.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/config.dylan	(original)
+++ trunk/libraries/network/koala/sources/koala/config.dylan	Wed Jan 24 19:05:07 2007
@@ -384,13 +384,17 @@
 
 define method process-config-element
     (node :: xml$<element>, name == #"mime-type-map")
+  log-info("configuring mime-type-map");
   let filename = get-attr(node, #"location");
+  log-info("mime-type-map: %s", filename);
+
+
   let mime-type-loc = as(<string>,
-                         merge-locators(as(<file-locator>,
-                                           format-to-string("%s/%s",
-                                                            $koala-config-dir,
-                                                            filename)),
-                                        *server-root*));
+    merge-locators(merge-locators(as(<file-locator>, filename),
+      as(<directory-locator>, $koala-config-dir)),
+    *server-root*));
+
+  log-info("mime-type-map-loc: %s", mime-type-loc);
     let mime-text = file-contents(mime-type-loc);
     if (mime-text)
       let mime-xml :: xml$<document> = xml$parse-document(mime-text);

Modified: trunk/libraries/network/koala/sources/koala/library-unix.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/library-unix.dylan	(original)
+++ trunk/libraries/network/koala/sources/koala/library-unix.dylan	Wed Jan 24 19:05:07 2007
@@ -272,6 +272,15 @@
   // files
   create
     static-file-responder;
+  
+  create <avalue>,
+    avalue-value,
+    avalue-alist;
+
+  create <http-file>,
+    http-file-filename,
+    http-file-content,
+    http-file-mime-type;
 
   // main() function
   create

Modified: trunk/libraries/network/koala/sources/koala/server.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/server.dylan	(original)
+++ trunk/libraries/network/koala/sources/koala/server.dylan	Wed Jan 24 19:05:07 2007
@@ -1022,6 +1022,15 @@
   end;
 end extract-request-version;
 
+define class <http-file> (<object>)
+  slot http-file-filename :: <string>,
+    required-init-keyword: filename:;
+  slot http-file-content :: <byte-string>,
+    required-init-keyword: content:;
+  slot http-file-mime-type :: <string>,
+    required-init-keyword: mime-type:;
+end;
+
 define method extract-form-data
  (buffer :: <string>, boundary :: <string>, request :: <request>)
   // strip everything after end-boundary
@@ -1029,8 +1038,7 @@
   let parts = split(buffer, separator: concatenate("--", boundary));
   for (part in parts) 
     let part = split(part, separator: "\r\n\r\n");
-    let header = first(part);
-    let header-entries = split(header, separator: "\r\n");
+    let header-entries = split(first(part), separator: "\r\n");
     let disposition = #f;
     let name = #f;
     let type = #f;
@@ -1054,7 +1062,16 @@
       end for;
     end for;
     if (part.size > 1)
-      request.request-query-values[name] := substring(second(part), 0, size(second(part)) - 1);
+      // TODO: handle disposition = "multipart/form-data" and parse that again
+      //disposition = "multipart/form-data" => ...
+      if (disposition = "form-data")
+        let content = substring(second(part), 0, size(second(part)) - 1);
+        request.request-query-values[name] := if (filename & type)
+            make(<http-file>, filename: filename, content: content, mime-type: type);
+          else
+            content;
+          end if;
+      end if;
     end if;
     log-debug("multipart/form-data for %=: %=, %=, %=", name, disposition, type, filename);
   end for;



More information about the chatter mailing list