Changeset 34

Show
Ignore:
Timestamp:
01/04/09 08:20:43 (3 years ago)
Author:
xammy
Message:

Fixed some bugs due to changes in Tango API

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/SimpleApp.d

    r24 r34  
    33import  fcgi.Request; 
    44 
     5import tango.io.stream.Format; 
    56import tango.text.convert.Layout; 
    6 import tango.io.Print; 
    7 import tango.io.Buffer; 
    87 
    98class MyApp : FastCGIApplication 
    109{ 
    11     private Print!(char) stdout; 
    12     private Print!(char) stderr; 
     10     
     11    private FormatOutput!(char) stdout; 
     12    private FormatOutput!(char) stderr; 
    1313 
    1414    this (int id, FastCGIRequest request) 
    1515    { 
    1616        auto layout = new Layout!(char) (); 
    17         stdout = new Print!(char) (layout, request.stdout); 
    18         stderr = new Print!(char) (layout, request.stderr); 
     17         
     18        stdout = new FormatOutput!(char) (layout, request.stdout); 
     19        stderr = new FormatOutput!(char) (layout, request.stderr); 
    1920    } 
    2021 
  • trunk/SimpleLoop.d

    r27 r34  
    11import fcgi.Request; 
    2 import fcgi.Connection; 
     2//import fcgi.Connection; 
    33 
    44int main (char[][] args) 
  • trunk/VerboseApp.d

    r24 r34  
    33import  fcgi.Request; 
    44 
     5import tango.io.stream.Format; 
    56import tango.text.convert.Layout; 
    6 import tango.io.Print; 
    7 import tango.io.Buffer; 
    87 
    98class MyApp : FastCGIApplication 
    109{ 
    11     private Print!(char) stdout; 
    12     private Print!(char) stderr; 
     10    private FormatOutput!(char) stdout; 
     11    private FormatOutput!(char) stderr; 
    1312    private static int counter = 0; 
    1413 
     
    1615    { 
    1716        auto layout = new Layout!(char) (); 
    18         stdout = new Print!(char) (layout, request.stdout); 
    19         stderr = new Print!(char) (layout, request.stderr); 
     17         
     18        stdout = new FormatOutput!(char) (layout, request.stdout); 
     19        stderr = new FormatOutput!(char) (layout, request.stderr); 
     20 
    2021    } 
    2122     
  • trunk/VerboseLoop.d

    r24 r34  
    22import  fcgi.Connection; 
    33 
    4 import  tango.text.convert.Layout; 
    5 import  tango.io.Buffer; 
    6 import  tango.io.Print; 
    7 import  tango.io.Stdout; 
     4import tango.io.stream.Format; 
    85 
    96int main (char[][] args) 
     
    1310    int counter = 0; 
    1411 
    15     Stdout = new Print!(char) (new Layout!(char) (), request.stdout); 
     12    auto Stdout = new FormatOutput!(char) (request.stdout); 
    1613    while ( request.accept () ) 
    1714    { 
  • trunk/VerboseThread.d

    r24 r34  
    1 import fcgi.Thread; 
    2 import fcgi.Connection; 
    3 import fcgi.Request; 
     1import fcgi.Thread; 
     2import fcgi.Connection; 
     3import fcgi.Request; 
    44 
    5 import  tango.text.convert.Layout; 
    6 import  tango.io.Buffer; 
    7 import  tango.io.Print; 
    8 import  tango.io.Stdout; 
     5import tango.io.stream.Format; 
    96 
    107public int run (FastCGIRequest request) 
    118{ 
    12     static int counter = 0; 
     9        static int counter = 0; 
    1310 
    14     auto stdout = new Print!(char) (new Layout!(char) (), request.stdout); 
     11        auto stdout = new FormatOutput !(char) (request.stdout); 
    1512 
    16     stdout ("Content-type: text/html\r\n\r\n") ("<head><title>My first page</title></head>"); 
    17     stdout ("<body>"); 
     13        stdout ("Content-type: text/html\r\n\r\n") ("<head><title>My first page</title></head>"); 
     14        stdout ("<body>"); 
    1815 
    19     // some counters 
    20     synchronized 
    21         counter++; 
    22     stdout ("<h1> Hello world </h1><br>") ("Request #") (counter) ("<br><br>\n"); 
     16        // some counters 
     17        synchronized 
     18                counter++; 
     19        stdout ("<h1> Hello world </h1><br>") ("Request #") (counter) ("<br><br>\n"); 
    2320 
    24     // Write IP 
    25     auto ip = ("REMOTE_ADDR" in request.args); 
    26     if (ip) 
    27    
    28         stdout ("Your IP is ") (*ip) ("<br><br>\n"); 
    29    
    30     else 
    31    
    32         stdout ("Cannot extract IP :(<br><br>\n"); 
    33    
     21        // Write IP 
     22        auto ip = ("REMOTE_ADDR" in request.args); 
     23        if (ip) 
     24       
     25                stdout ("Your IP is ") (*ip) ("<br><br>\n"); 
     26       
     27        else 
     28       
     29                stdout ("Cannot extract IP :(<br><br>\n"); 
     30       
    3431 
    35     // Write stdin 
    36     stdout ("Data: \"") (); 
    37     while (1) 
    38     { 
    39         char[10] string; 
    40         int rd = request.stdin.read(string); 
    41         if (rd > 0) 
    42             stdout(string[0 .. rd]); 
    43         if (rd != string.length) 
     32        // Write stdin 
     33        stdout ("Data: \"") (); 
     34        while (1) 
    4435        { 
    45             stdout ("\"<br><br>"); 
    46             break; 
     36                char[10] string; 
     37                int rd = request.stdin.read (string); 
     38                if (rd > 0) 
     39                        stdout (string [0 .. rd]); 
     40                if (rd != string.length) 
     41                { 
     42                        stdout ("\"<br><br>"); 
     43                        break; 
     44                } 
    4745        } 
    48     } 
    4946 
    50     // Write all arguments 
    51     stdout ("\nYour environment:<br>\n"); 
    52     foreach (key, value; request.args) 
    53    
    54         stdout ("request.args[\"")(key) ("\"] = \"") (value) ("\"<br>\n"); 
    55    
    56     stdout ("</body>\n") (); 
     47        // Write all arguments 
     48        stdout ("\nYour environment:<br>\n"); 
     49        foreach (key, value; request.args) 
     50       
     51                stdout ("request.args[\"") (key) ("\"] = \"") (value) ("\"<br>\n"); 
     52       
     53        stdout ("</body>\n") (); 
    5754 
    58     return 0; 
     55        return 0; 
    5956} 
    6057 
    61 int main(char[][] args) 
     58int main (char[][] args) 
    6259{ 
    63     FastCGIConnection connection = new FastCGIConnection (); 
     60        FastCGIConnection connection = new FastCGIConnection (); 
    6461 
    65     return FastCGIThread.loop (connection, &run, true, 10); 
     62        return FastCGIThread.loop (connection, &run, true, 10); 
    6663} 
  • trunk/fcgi/Protocol.d

    r14 r34  
    1313module fcgi.Protocol; 
    1414 
    15 import tango.io.Buffer; 
    1615import tango.io.protocol.Reader; 
    1716import tango.io.protocol.Writer; 
  • trunk/fcgi/Request.d

    r32 r34  
    2020private import  fcgi.Exception; 
    2121 
    22 private import  tango.io.Buffer; 
    2322private import  tango.io.Console; 
    2423private import  tango.math.Math;