CXM_web_dump.anubis 1.86 KB
/*
 * Created by PyramIDE.
 * User: Jeremy
 * Date: 09/08/2012
 * Time: 16:14
 * 
 *
 */

read tools/basis.anubis
read system/string.anubis
read system/convert.anubis
read calexium_lib/web/CXM_common.anubis
read calexium_lib/web/CXM_multihost_http_server.anubis

/* Provides a dump of Web_arg List */
public define String
  dump_web_arg_values
  (
      List(Web_arg) l,
  )
  =
    if l is
    {
      [ ]     then "\n",
      [h . t] then if h is 
      {
        web_arg(n,v)    then "\n["+n+"] = '"+v+"'" + dump_web_arg_values(t),
        upload(n,v,tfn) then "\n["+n+"] = '"+v+"'" + dump_web_arg_values(t)
      }
    }
  .
  
/* Provides a dump of HTTP_Header List */
public define String
  dump_http_headers
  (
      List(HTTP_header) l,
      String            prefix
  )
  =
    if l is
    {
      [ ]     then "", // no need to add \n => previous call has made it
      [h . t] then prefix + h.name + " : " + h.value + "\n" + dump_http_headers(t, prefix)
    }
  .

/* Provides a dump of a HTTP_Info */
public define String
  dump_http_info
  (
    HTTP_Info http_info,
  )
  =
    /*
     *  Word32             ip_address,             // IP address of the client
       String             hostname,               // hostname requested by the client
       String             uri,                    // URI requested by the client
       List(HTTP_header)  http_headers,           // HTTP headers sent by the client
       Bool               is_https,
       One -> String      generate_trust_ticket   // may be used against denial of
    */
    "IP Address : " + ip_addr_to_string(http_info.ip_address) + "\n"
    + "Hostname : " + http_info.hostname + "\n"
    + "URI : " + http_info.uri + "\n"
    + "HTTP Headers : \n" + dump_http_headers(http_info.http_headers,"\t") // no need to add \n => dump_http_headers does it
    + "Is HTTPS : " + to_String(http_info.is_https) + "\n"
  .