예제 #1
0
        public static string Call(string path)
        {
            // TODO: There's got to be a better way than using regexps.
            // new Uri (kerbalstuff_api, path) doesn't work, it only uses the *base* of the first arg,
            // and hence drops the /api path.

            // Remove leading slashes.
            path = Regex.Replace(path, "^/+", "");

            string url = kerbalstuff_api + path;

            log.DebugFormat("Calling {0}", url);

            using (var web = new Web())
            {
                return(web.DownloadString(url));
            }
        }
예제 #2
0
파일: KSAPI.cs 프로젝트: johndalton/CKAN
        public static string Call(string path)
        {
            // TODO: There's got to be a better way than using regexps.
            // new Uri (kerbalstuff_api, path) doesn't work, it only uses the *base* of the first arg,
            // and hence drops the /api path.

            // Remove leading slashes.
            path = Regex.Replace(path, "^/+", "");

            string url = kerbalstuff_api + path;

            log.DebugFormat("Calling {0}", url);
            try
            {
                using (var web = new Web())
                {
                    return(web.DownloadString(url));
                }
            }
            catch (DllNotFoundException exc)
            {
                //Curl is not installed. Curl is a workaround for a mono issue.
                //TODO Richard - Once repos are merged go and check all Platform calls to see if they are mono checks
                if (!Platform.IsWindows)
                {
                    throw;
                }
                //On mircrosft.net so try native code.
                using (var web = new WebClient())
                {
                    try
                    {
                        return(web.DownloadString(url));
                    }
                    catch (WebException web_ex)
                    {
                        log.ErrorFormat("WebException while accessing {0}: {1}", url, web_ex);
                        throw;
                    }
                }
            }
        }
예제 #3
0
파일: KSAPI.cs 프로젝트: Rusk85/CKAN
        public static string Call(string path)
        {
            // TODO: There's got to be a better way than using regexps.
            // new Uri (kerbalstuff_api, path) doesn't work, it only uses the *base* of the first arg,
            // and hence drops the /api path.

            // Remove leading slashes.
            path = Regex.Replace(path, "^/+", "");

            string url = kerbalstuff_api + path;

            log.DebugFormat("Calling {0}", url);
            try
            {
                using (var web = new Web())
                {
                    return web.DownloadString(url);
                }
            }
            catch (DllNotFoundException)
            {
                //Curl is not installed. Curl is a workaround for a mono issue.
                //TODO Richard - Once repos are merged go and check all Platform calls to see if they are mono checks
                if (!Platform.IsWindows) throw;
                //On mircrosft.net so try native code.
                using (var web = new WebClient())
                {
                    try
                    {
                        return web.DownloadString(url);
                    }
                    catch (WebException web_ex)
                    {
                        log.ErrorFormat("WebException while accessing {0}: {1}", url, web_ex);
                        throw;
                    }
                }
            }
        }