Changes from Version 1 of HttpGetExample
- Timestamp:
- 10/06/06 18:09:18 (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
HttpGetExample
v0 v1 1 This document has been placed into the public domain by Kris 2 {{{ 3 #!d 4 /******************************************************************************* 5 6 Directive to include the winsock library 7 8 *******************************************************************************/ 9 10 version (Win32) 11 pragma (lib, "wsock32"); 12 13 /******************************************************************************* 14 15 Read a page from a website, gathering the entire page before 16 returning any content. This illustrates a high-level approach 17 to retrieving web-content, whereas the homepage example shows 18 a somewhat lower-level approach. 19 20 Note that this expects a fully qualified URL (with scheme), 21 such as "http://www.digitalmars.com/d/intro.html" 22 23 *******************************************************************************/ 24 25 private import tango.io.Console; 26 27 private import tango.net.http.HttpGet; 28 29 void main (char[][] args) 30 { 31 char[] url = (args.length is 2) ? args[1] : "http://www.digitalmars.com/d/intro.html"; 32 33 // open a web-page for reading (see HttpPost for writing) 34 auto page = new HttpGet (url); 35 36 // retrieve and display content 37 Cout (cast(char[])page.read) (); 38 } 39 }}}