1 using System;
2 using System.Net.Http;
3 using System.IO;
4 using System.Xml;
5
6 int main()
7 {
8 try
9 {
10 HttpClient httpClient(UriReference("http://www.w3.org/"), &Console.Out());
11 HttpHeaderCollection responseHeaders;
12 SharedPtr<ByteStream> body;
13 UriReference uri = "/2001/xml.xsd";
14 HttpStatus status = httpClient.Get(uri, responseHeaders, body);
15 if (status.StatusCode() == statusSuccessOK)
16 {
17 StreamReader reader(body);
18 string xmlContent = reader.ReadToEnd();
19 Console.Out() << xmlContent << endl();
20 }
21 else
22 {
23 throw HttpException(status);
24 }
25 }
26 catch (const Exception& ex)
27 {
28 Console.Error() << ex.ToString() << endl();
29 return 1;
30 }
31 return 0;
32 }