forked from anaisbetts/ModernHttpClient
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDotNet.cs
More file actions
53 lines (47 loc) · 1.08 KB
/
DotNet.cs
File metadata and controls
53 lines (47 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//
// This file contains the sample code to use System.Net.WebRequest
// on the iPhone to communicate with HTTP and HTTPS servers
//
// Author:
// Miguel de Icaza
//
using System;
using System.Net;
using MonoTouch.Foundation;
using System.Security.Cryptography.X509Certificates;
using System.Diagnostics;
namespace HttpClient
{
public class DotNet {
AppDelegate ad;
public DotNet (AppDelegate ad)
{
this.ad = ad;
}
//
// Asynchronous HTTP request
//
public void HttpSample ()
{
Application.Busy ();
var request = WebRequest.Create (Application.WisdomUrl);
request.BeginGetResponse (FeedDownloaded, request);
}
//
// Invoked when we get the stream back from the twitter feed
// We parse the RSS feed and push the data into a
// table.
//
void FeedDownloaded (IAsyncResult result)
{
Application.Done ();
var request = result.AsyncState as HttpWebRequest;
try {
var response = request.EndGetResponse (result);
ad.RenderStream (response.GetResponseStream ());
} catch (Exception e) {
Debug.WriteLine (e);
}
}
}
}