Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changes between Version 4 and Version 5 of HomepageExample

Show
Ignore:
Author:
larsivi (IP: 84.48.201.101)
Timestamp:
08/13/07 18:40:51 (17 years ago)
Comment:

Updated

Legend:

Unmodified
Added
Removed
Modified
  • HomepageExample

    v4 v5  
    2323 
    2424void main() 
    25 { 
     25{         
    2626        auto client = new HttpClient (HttpClient.Get, "http://www.digitalmars.com/d/intro.html"); 
    27         client.open (); 
    2827 
     28        // open the client and get the input stream 
     29        auto input = client.open; 
     30        scope (exit) 
     31               client.close; 
     32 
     33        // display returned content on console 
    2934        if (client.isResponseOK) 
    30            { 
    31            // extract content length 
    32            int length = client.getResponseHeaders.getInt (HttpHeader.ContentLength, int.max); 
     35            Cout.stream.copy (input); 
     36        else 
     37           Cout ("failed to return the D home page"); 
    3338 
    34            // display response 
    35            client.read (&Cout.consume, length); 
    36            Cout.newline; 
    37            } 
    38         else 
    39            Cout ("failed to return the D home page").newline; 
    40  
    41         client.close(); 
     39        // flush the console 
     40        Cout.newline; 
    4241} 
    4342}}}