[chatter] r11815 - trunk/libraries/network/koala/sources/koala

cgay at mccarthy.opendylan.org cgay at mccarthy.opendylan.org
Sun May 18 14:37:19 CEST 2008


Author: cgay
Date: Sun May 18 14:37:17 2008
New Revision: 11815

Modified:
   trunk/libraries/network/koala/sources/koala/dsp.dylan
   trunk/libraries/network/koala/sources/koala/errors.dylan
   trunk/libraries/network/koala/sources/koala/library-unix.dylan
   trunk/libraries/network/koala/sources/koala/library.dylan
   trunk/libraries/network/koala/sources/koala/server.dylan
   trunk/libraries/network/koala/sources/koala/urls.dylan
Log:
job: koala
Some minor cleanups.
* Removed current-url and *request* from module exports.
  Use request-url and current-request instead.
* Removed *virtual-host* from module exports.
  Use virtual-host and current-request instead.
* Improved grouping of module exports.

Modified: trunk/libraries/network/koala/sources/koala/dsp.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/dsp.dylan	(original)
+++ trunk/libraries/network/koala/sources/koala/dsp.dylan	Sun May 18 14:37:17 2008
@@ -192,13 +192,13 @@
 define method root-directory
     (page :: <file-page-mixin>)
  => (root :: <directory-locator>)
-  *virtual-host*.document-root;
+  document-root(virtual-host(current-request()))
 end;
 
 define method root-directory
     (page :: <dylan-server-page>)
  => (root :: <directory-locator>)
-  *virtual-host*.dsp-root;
+  dsp-root(virtual-host(current-request()))
 end;
 
 

Modified: trunk/libraries/network/koala/sources/koala/errors.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/errors.dylan	(original)
+++ trunk/libraries/network/koala/sources/koala/errors.dylan	Sun May 18 14:37:17 2008
@@ -29,7 +29,8 @@
 
 define class <http-error> (<koala-error>)
   constant slot http-error-code :: <integer>, required-init-keyword: code:;
-  constant slot http-error-headers :: false-or(<header-table>) = #f, init-keyword: headers:;
+  constant slot http-error-headers :: false-or(<header-table>) = #f,
+    init-keyword: headers:;
 end;
 
 define constant $application-error-code = 599;
@@ -43,7 +44,8 @@
   signal(make(<http-server-error>,
               code: $application-error-code,
               format-string: iff(format-string,
-                                 concatenate($application-error-message, " -- ", format-string),
+                                 concatenate($application-error-message,
+                                             " -- ", format-string),
                                  $application-error-message),
               format-arguments: format-arguments | #[]));
 end;

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	Sun May 18 14:37:17 2008
@@ -138,50 +138,46 @@
   //needed for last-modified stuff
   create get-header, request-method-setter, not-modified;
 
-  // Headers
-  // Do these really need to be exported?
-  create
-    <header-table>,
-    *max-single-header-size*,
-    *header-buffer-growth-amount*,
-    // read-message-headers(stream) => header-table
-    read-message-headers,
-    header-value;
-
-  // Basic server stuff
+  // Server startup/shutdown
   create
     <http-server>,
     start-server,
     stop-server,
+    koala-main,
+    *argument-list-parser*;
+
+  // Requests
+  create
+    <request>,
+    current-request,             // Returns the active request of the thread.
+    request-method,              // Returns #"get", #"post", etc
+    request-host,
+    request-url,
+    request-tail-url,
+    request-query-values,        // get the keys/vals from the current GET or POST request
+      get-query-value,           // Get a query value that was passed in a URL or a form
+      do-query-values,           // Call f(key, val) for each query in the URL or form
+      count-query-values,
+    request-content,
+    request-content-type,
+    request-content-setter,
+    process-request-content;
+
+  // Responders
+  create
     <responder>,
+    responder-definer,
     responder-map,
     add-responder,
     remove-responder,
     find-responder,
     invoke-responder,
-    <request>,
-    *request*,                   // Holds the active request, per thread.
-    current-request,             // Returns the active request of the thread.
-    current-response,            // Returns the active response of the thread.
-    request-query-values,        // get the keys/vals from the current GET or POST request
-    request-method,              // Returns #"get", #"post", etc
-    request-host,
-    responder-definer,
-    url-map-definer,
-
-    // Form/query values.  (Is there a good name that covers both of these?)
-    get-query-value,             // Get a query value that was passed in a URL or a form
-    do-query-values,             // Call f(key, val) for each query in the URL or form
-    count-query-values,
-    application-error,
-    current-url,
-    redirect-to,
-    redirect-temporarily-to;
+    url-map-definer;
 
   // Virtual hosts
   create
     <virtual-host>,
-    *virtual-host*,
+    virtual-host,                // Return virtual host of current request.
     document-root,
     dsp-root,
     vhost-name,
@@ -192,9 +188,10 @@
   // Responses
   create
     <response>,
+    current-response,            // Returns the active response of the thread.
+    output,
     output-stream,
     clear-output,
-    output,
     set-content-type,
     add-header,
     add-cookie,
@@ -240,9 +237,6 @@
   create
     process-config-element,
     get-attr;
-  use xml-parser,
-    rename: { <element> => <xml-element> },
-    export: { <xml-element> };
 
   // XML-RPC
   create
@@ -253,26 +247,27 @@
     maybe-serve-static-file,
     document-location;
 
-  // Errors
-  create
-    access-forbidden-error,
-    <koala-api-error>;
-
+  // Redirection
   create
+    redirect-to,
+    redirect-temporarily-to,
     moved-permanently-redirect,
     moved-temporarily-redirect,
     see-other-redirect,
     unauthorized-error;
 
+  // Errors
   create
+    <koala-api-error>,
     http-error-code,
+    http-error-headers,
+    access-forbidden-error,
+    application-error,
     unsupported-request-method-error,
     resource-not-found-error,
     unimplemented-error,
     internal-server-error,
-    bad-request,
-    request-url,
-    request-tail-url;
+    bad-request;
 
   // Files
   create
@@ -289,16 +284,15 @@
     http-file-content,
     http-file-mime-type;
 
-  // main() function
-  create
-    koala-main,
-    *argument-list-parser*;
-
+  // Headers
+  // Do these really need to be exported?
   create
-    request-content,
-    request-content-type,
-    request-content-setter,
-    process-request-content;
+    <header-table>,
+    *max-single-header-size*,
+    *header-buffer-growth-amount*,
+    // read-message-headers(stream) => header-table
+    read-message-headers,
+    header-value;
 
 end module koala;
 

Modified: trunk/libraries/network/koala/sources/koala/library.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/library.dylan	(original)
+++ trunk/libraries/network/koala/sources/koala/library.dylan	Sun May 18 14:37:17 2008
@@ -138,50 +138,46 @@
   //needed for last-modified stuff
   create get-header, request-method-setter, not-modified;
 
-  // Headers
-  // Do these really need to be exported?
-  create
-    <header-table>,
-    *max-single-header-size*,
-    *header-buffer-growth-amount*,
-    // read-message-headers(stream) => header-table
-    read-message-headers,
-    header-value;
-
-  // Basic server stuff
+  // Server startup/shutdown
   create
     <http-server>,
     start-server,
     stop-server,
+    koala-main,
+    *argument-list-parser*;
+
+  // Requests
+  create
+    <request>,
+    current-request,             // Returns the active request of the thread.
+    request-method,              // Returns #"get", #"post", etc
+    request-host,
+    request-url,
+    request-tail-url,
+    request-query-values,        // get the keys/vals from the current GET or POST request
+      get-query-value,           // Get a query value that was passed in a URL or a form
+      do-query-values,           // Call f(key, val) for each query in the URL or form
+      count-query-values,
+    request-content,
+    request-content-type,
+    request-content-setter,
+    process-request-content;
+
+  // Responders
+  create
     <responder>,
+    responder-definer,
     responder-map,
     add-responder,
     remove-responder,
     find-responder,
     invoke-responder,
-    <request>,
-    *request*,                   // Holds the active request, per thread.
-    current-request,             // Returns the active request of the thread.
-    current-response,            // Returns the active response of the thread.
-    request-query-values,        // get the keys/vals from the current GET or POST request
-    request-method,              // Returns #"get", #"post", etc
-    request-host,
-    responder-definer,
-    url-map-definer,
-
-    // Form/query values.  (Is there a good name that covers both of these?)
-    get-query-value,             // Get a query value that was passed in a URL or a form
-    do-query-values,             // Call f(key, val) for each query in the URL or form
-    count-query-values,
-    application-error,
-    current-url,
-    redirect-to,
-    redirect-temporarily-to;
+    url-map-definer;
 
   // Virtual hosts
   create
     <virtual-host>,
-    *virtual-host*,
+    virtual-host,                // Return virtual host of current request.
     document-root,
     dsp-root,
     vhost-name,
@@ -192,9 +188,10 @@
   // Responses
   create
     <response>,
+    current-response,            // Returns the active response of the thread.
+    output,
     output-stream,
     clear-output,
-    output,
     set-content-type,
     add-header,
     add-cookie,
@@ -240,9 +237,6 @@
   create
     process-config-element,
     get-attr;
-  use xml-parser,
-    rename: { <element> => <xml-element> },
-    export: { <xml-element> };
 
   // XML-RPC
   create
@@ -253,26 +247,27 @@
     maybe-serve-static-file,
     document-location;
 
-  // Errors
-  create
-    access-forbidden-error,
-    <koala-api-error>;
-
+  // Redirection
   create
+    redirect-to,
+    redirect-temporarily-to,
     moved-permanently-redirect,
     moved-temporarily-redirect,
     see-other-redirect,
     unauthorized-error;
 
+  // Errors
   create
+    <koala-api-error>,
     http-error-code,
+    http-error-headers,
+    access-forbidden-error,
+    application-error,
     unsupported-request-method-error,
     resource-not-found-error,
     unimplemented-error,
     internal-server-error,
-    bad-request,
-    request-url,
-    request-tail-url;
+    bad-request;
 
   // Files
   create
@@ -289,16 +284,15 @@
     http-file-content,
     http-file-mime-type;
 
-  // main() function
-  create
-    koala-main,
-    *argument-list-parser*;
-
+  // Headers
+  // Do these really need to be exported?
   create
-    request-content,
-    request-content-type,
-    request-content-setter,
-    process-request-content;
+    <header-table>,
+    *max-single-header-size*,
+    *header-buffer-growth-amount*,
+    // read-message-headers(stream) => header-table
+    read-message-headers,
+    header-value;
 
 end module koala;
 

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	Sun May 18 14:37:17 2008
@@ -593,6 +593,8 @@
   // The body content of the request.  Only present for POST?
   slot request-content :: <string> = "";
 
+  // todo -- This is only stored in the request for internal modularity
+  //         reasons.  It should be removed.
   slot request-responder :: false-or(<responder>) = #f;
 
   // contains the relative URL after the matched responder
@@ -607,8 +609,6 @@
 
 define variable *default-request-class* :: subclass(<basic-request>) = <request>;
 
-define thread variable *request* :: false-or(<request>) = #f;
-
 // Making a virtual hosts requires an instantiated server to do some
 // initialization, so use this instead of calling make(<virtual-host>).
 //
@@ -650,10 +650,19 @@
   end
 end;
 
+define thread variable *request* :: false-or(<request>) = #f;
+
+define inline function current-request
+    () => (request :: <request>)
+  *request*
+end;
+
 define thread variable *response* :: false-or(<response>) = #f;
 
-define inline function current-request  () => (request :: <request>) *request* end;
-define inline function current-response () => (response :: <response>) *response* end;
+define inline function current-response
+    () => (response :: <response>)
+  *response*
+end;
 
 // Called (in a new thread) each time an HTTP request is received.
 define function handler-top-level

Modified: trunk/libraries/network/koala/sources/koala/urls.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/urls.dylan	(original)
+++ trunk/libraries/network/koala/sources/koala/urls.dylan	Sun May 18 14:37:17 2008
@@ -6,10 +6,6 @@
 Warranty:  Distributed WITHOUT WARRANTY OF ANY KIND
 
 
-define inline function current-url () => (url :: <url>)
-  *request*.request-url
-end;
-
 define open generic redirect-to (object :: <object>);
 
 define method redirect-to (url :: <string>)


More information about the chatter mailing list