Engines/FlatRedBallXNA/FlatRedBall/IO/HttpManager.cs
/// <summary>Simple HTTP Get, gives you the string result</summary>
Simple HTTP Get, gives you the string result
Simple HTTP Get gives you the string result
public static int PerformHttpGet(Uri uri, Action<string, int> action, Action<Exception, int> error)
        {
            int requestId = mNextRequestId;
            mNextRequestId++;
#if WINDOWS_PHONE
            var request = WebRequest.CreateHttp(uri);
#else
            var request = (HttpWebRequest)WebRequest.Create(uri);
#endif
            request.UserAgent = UserAgent;
            request.BeginGetResponse(i =>
            {
                try
                {
                    var response = request.EndGetResponse(i);
                    var sreader = new StreamReader(response.GetResponseStream());
                    var result = sreader.ReadToEnd();
                    action(result, requestId);
                }
                catch (Exception ex)
                {
                    if (error != null) error(ex, requestId);
                    else throw;
                }
            }, null);
            return requestId;
        }
public static int PerformHttpGet ( Uri uri , Action < string , int > action , Action < Exception , int > error ) { int requestId = mNextRequestId ; mNextRequestId ++ ; if WINDOWS_PHONE var request = WebRequest . CreateHttp ( uri ) ; else var request = ( HttpWebRequest ) WebRequest . Create ( uri ) ; endif request . UserAgent = UserAgent ; request . BeginGetResponse ( i => { try { var response = request . EndGetResponse ( i ) ; var sreader = new StreamReader ( response . GetResponseStream ( ) ) ; var result = sreader . ReadToEnd ( ) ; action ( result , requestId ) ; } catch ( Exception ex ) { if ( error != null ) error ( ex , requestId ) ; else throw ; } } , null ) ; return requestId ; }
Simple HTTP Get, gives you the string result
Simple HTTP Get gives you the string result
uri
Uri
action
Action<string, int>
error
Action<Exception, int>