Exemplo n.º 1
0
        public UserDataService()
        {
            userDataUrl = ConfigurationManager.AppSettings["user-data-url"];
            if (string.IsNullOrEmpty(userDataUrl))
            {
                userDataUrl = DefaultUserDataUrl;
            }

            cfnFolder = ConfigurationManager.AppSettings["cfn-folder"];
            if (string.IsNullOrEmpty(cfnFolder))
            {
                cfnFolder = DefaultCfnFolder;
            }
            stateService = new UserDataState(cfnFolder);
            CtxTrace.TraceVerbose("UserData Url {0}, CFN folder {1}", userDataUrl, cfnFolder);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Simple "GET" on the specified Url returing the contents as a string. If an error occurs
 /// it is logged and the method returns null
 /// </summary>
 /// <param name="url"></param>
 /// <returns></returns>
 public static string HttpGet(string url)
 {
     CtxTrace.TraceVerbose("url={0}", url);
     try {
         HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
         request.Method = "GET";
         using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) {
             using (Stream responseStream = response.GetResponseStream()) {
                 using (StreamReader streamReader = new StreamReader(responseStream, Encoding.UTF8)) {
                     return(streamReader.ReadToEnd());
                 }
             }
         }
     } catch (Exception e) {
         CtxTrace.TraceError(e);
         return(null);
     }
 }