Example #1
0
 private static void Main(string[] args)
 {
     var http = new HttpClient();
     http.Request.Accept = HttpContentTypes.ApplicationJson;
     http.Request.ParametersAsSegments = true;
     var trees = http.Get("http://localhost:65367/trees");
     Console.WriteLine(trees.StaticBody<Object>().SerializeToString());
     var result = http.Get("http://localhost:65367/trees/1");
     Console.WriteLine(result.StaticBody<Object>().SerializeToString());
     result = http.Get("http://localhost:65367/trees", new { Id = 2 });
     var tree2 = result.DynamicBody;
     Console.WriteLine(tree2.Id);
     Console.WriteLine(tree2.Genus);
     http.Request.Accept = "application/pdf";
     http.Request.ParametersAsSegments = true;
     const string filename = "e:\\temp\\Test.pdf";
     const string filename2 = "e:\\temp\\Test2.pdf";
     if (File.Exists(filename)) File.Delete(filename);
     if (File.Exists(filename2)) File.Delete(filename2);
     Console.WriteLine("Get pdf of 1 tree");
     http.GetAsFile("http://localhost:65367/trees/1", filename);
     Console.WriteLine("Pdf created");
     Console.WriteLine("Get pdf of all trees");
     http.GetAsFile("http://localhost:65367/trees", filename2);
     Console.WriteLine("Pdf created");
     Console.ReadLine();
 }
        private void Check(object sender, ElapsedEventArgs e)
        {
            var http = new HttpClient();
            var result = false;
            string message = "";

            try
            {
                var response = http.Get(_url);
                result =  response.RawText.Contains(_textToMatch);
                message += result ?  string.Format(@"Message:  ""{0}"" found in page", _textToMatch) : string.Format(@"Message:  ""{0}"" not found in page", _textToMatch);

            }
            catch (Exception exception)
            {
                message += exception.Message;
            }

            _threadDispatcher.Invoke(DispatcherPriority.Input, new Action(() =>
            {
                _statusIndicator.Fill = result
                    ? new SolidColorBrush(Colors.Chartreuse)
                    : new SolidColorBrush(Colors.Red);
                _lastUpdatedTextBlock.Text = string.Format("Last tested at {0}", DateTime.Now);
                _messageTextBox.Text = message;

            }));
        }
		public void HEAD_NotSupported()
		{
			var client = new HttpClient();
			HttpResponse response = client.Head(UrlFor("/translation/DK/en"));

			Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.InternalServerError));
		}
Example #4
0
 public void easyhttp()
 {
     var httpClient = new HttpClient();
     var response = httpClient.Get("http://www.amazon.co.uk/s/ref=nb_sb_noss_2?url=search-alias%3Daps&field-keywords=Testing+ASP.net&x=0&y=0");
     var dom = CsQuery.CQ.Create(response.RawText);
     StringAssert.Contains("Ben Hall", dom.Find(".ptBrand").Text());
 }
        public dynamic Get(string apiName)
        {
            var url = string.Format("https://slack.com/api/{0}?token={1}", apiName, SlackWindowsTray.Default.SlackToken);

            var http = new HttpClient();
            var response = http.Get(url);
            return JsonConvert.DeserializeObject(response.RawText);
        }
Example #6
0
        public static HttpResponse Get(string url)
        {
            var httpClient = new EasyHttp.Http.HttpClient();

            httpClient.Request.Accept = HttpContentTypes.ApplicationJson;

            return(httpClient.Get(url));
        }
Example #7
0
        public CouchServer(string host, int port, string database)
        {
            _baseUrl = String.Format("http://{0}:{1}/{2}", host, port, database);

            _connection = new HttpClient();

            _connection.Request.Accept = HttpContentTypes.ApplicationJson;
        }
		public void POST_LanguageNotSupported_BadRequest()
		{
			var client = new HttpClient();
			HttpResponse response = client.Post(UrlFor("/translation"),
				new TranslationMsg { Code = "ES", Language = "notSupported", Data = "something" },
				HttpContentTypes.ApplicationJson);

			Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
		}
Example #9
0
        static void Main(string[] args)
        {
            var client = new HttpClient();
            var response = client.Get("http://localhost:5656");

            Console.WriteLine();
            Console.WriteLine(response.RawText);
            Console.WriteLine();
        }
Example #10
0
        public static HttpResponse Get(string uri)
        {
            var httpClient = new EasyHttp.Http.HttpClient();

            httpClient.Request.Accept  = HttpContentTypes.ApplicationJson;
            httpClient.Request.Timeout = Convert.ToInt32(TimeSpan.FromSeconds(10).TotalMilliseconds);

            return(httpClient.Get(uri));
        }
 public ActionResult ListarVehiculos()
 {
     VehiculoRepositorio repositorio = new VehiculoRepositorio();
     List<Vehiculo> vehiculos = repositorio.ConsultarVehiculos();
     HttpClient cliente = new HttpClient();
     //EasyHttp.Http.HttpResponse respuesta = cliente.Get("http://localhost:49671/api/vehiculo/ObtenerVehiculos");
     //var vehiculos = respuesta.StaticBody<Vehiculo[]>();
     return View(vehiculos);
 }
        private EasyHttp.Http.HttpClient CreateEasyHttpClient()
        {
            var httpClient = new EasyHttp.Http.HttpClient();

            httpClient.Request.Accept = HttpContentTypes.TextCsv;
            httpClient.Request.SetBasicAuthentication(_userName, _password);
            httpClient.Request.ForceBasicAuth = true;

            return(httpClient);
        }
        public MainWindow()
        {
            var http = new HttpClient("http://localhost:8080");

            InitializeComponent();

            http.Request.Accept = HttpContentTypes.ApplicationJson;
            listener.Start();
            listener.Prefixes.Add("http://127.0.0.1:8080/");
        }
		public void GET_DidNotExist_NotFound()
		{
			var repository = Substitute.For<ITranslationRepository>();
			Replacing(repository);
			repository.Get(Arg.Any<string>(), Arg.Any<CultureInfo>()).Returns(default(TranslationMdl));

			var client = new HttpClient();
			HttpResponse response = client.Get(UrlFor("/translation/DK/es"));

			Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
		}
        public GeolocalizationResult PerformGeolocalization(GeolocalizationCommand command)
        {
            var http = new HttpClient
            {
                Request = { Accept = HttpContentTypes.ApplicationJson }
            };

            var builtUrl = string.Format(ServiceUrl, command);
            var response = http.Get(builtUrl);
            var parser = new GoogleMapsGeolocalizationServiceParser();
            return parser.ParseJsonText(response.RawText);
        }
		public void GET_NotAvailableLanguage_NotFound()
		{
			var repository = Substitute.For<ITranslationRepository>();
			Replacing(repository);

			var client = new HttpClient();
			HttpResponse response = client.Get(UrlFor("/translation/DK/es-ES"));

			Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));

			repository.DidNotReceive().Get(Arg.Any<string>(), Arg.Any<CultureInfo>());
		}
		public void Countries_Empty_NotFound()
		{
			var repository = Substitute.For<ICountryRepository>();
			Replacing(repository);
			repository.FindCurrent(Arg.Any<CultureInfo>()).Returns(new Country[] { });

			var client = new HttpClient();
			client.Request.AcceptLanguage = "en";
			HttpResponse response = client.Get(UrlFor("/countries"));

			Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
		}
		public void Country_HeadOverMissing_NotFound()
		{
			var repository = Substitute.For<ICountryRepository>();
			Replacing(repository);
			repository.Exists("ES", Arg.Any<CultureInfo>()).Returns(false);

			var client = new HttpClient();
			client.Request.Accept = HttpContentTypes.ApplicationXml;
			HttpResponse response = client.Head(UrlFor("/country/ES/en"));

			Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
			Assert.That(response.ContentType, Is.Null);
		}
Example #19
0
        public virtual HttpClient CreateClient()
        {
            var client = new HttpClient(m_Settings.TeamCityBaseUrl)
                         {
                             Request = {Accept = HttpContentTypes.ApplicationJson}
                         };
            if (m_Settings.TeamCityRequiresAuthentication)
            {
                client.Request.ForceBasicAuth = true;
                ConfigureForBasicAuthentication(client, m_Settings.TeamCityUserName, m_Settings.TeamCityPassword);
            }

            return client;
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var toAdd = new InvoiceAdd()
            {
                TermsAndConditions = Guid.NewGuid().ToString()
            };

            var http = new EasyHttp.Http.HttpClient();

            // http.Post("http://localhost:32772/api/Invoice", toAdd, HttpContentTypes.ApplicationJson);
            var response = http.Post("http://localhost:55526/api/Invoice", toAdd, HttpContentTypes.ApplicationJson);

            MessageBox.Show(response.StatusCode.ToString());
        }
		public void Countries_HeadOverExisting_Ok()
		{
			var repository = Substitute.For<ICountryRepository>();
			Replacing(repository);
			repository.AreTranslated(Arg.Any<CultureInfo>()).Returns(true);

			var client = new HttpClient();
			client.Request.Accept = HttpContentTypes.ApplicationXml;
			HttpResponse response = client.Head(UrlFor("/countries/ES"));

			Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
			Assert.That(response.ContentType, Is.EqualTo(HttpContentTypes.ApplicationXml));
			Assert.That(response.RawText, Is.Empty);
		}
        public void Send(TextMessage message)
        {
            if (!message.IsValid())
                throw new ArgumentException("Invalid Message");

            var http = new HttpClient { Request = { Accept = HttpContentTypes.ApplicationJson } };
            var url = string.Format("http://api.clickatell.com/http/sendmsg?user={0}&password={1}&api_id={2}&{3}&to={4}&text={5}",
                                    _user,
                                    _password,
                                    _apiId,
                                    string.IsNullOrWhiteSpace(_sender) ? null : string.Format("&from={0}", _sender),
                                    HttpUtility.UrlEncode(message.Number),
                                    HttpUtility.UrlEncode(message.Message));
            http.Get(url);
        }
		public void FormatNotSupported_HtmlReturned()
		{
			var repository = Substitute.For<ILanguageRepository>();
			Replacing(repository);
			repository.FindAll().Returns(new[] { "es" });

			var client = new HttpClient
			{
				Request = { Accept = HttpContentTypes.ApplicationOctetStream }
			};

			HttpResponse response = client.Get(UrlFor("/languages"));

			Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
			Assert.That(response.RawHeaders[HttpResponseHeader.ContentType], Is.EqualTo(HttpContentTypes.TextHtml));
		}
		public void Country_Get_NotEmptyBody()
		{
			var repository = Substitute.For<ICountryRepository>();
			Replacing(repository);
			string translation = "España";
			repository.Get("ES", Arg.Any<CultureInfo>()).Returns(
				new Country { Translation = new Translation { Name = translation}});

			var client = new HttpClient();
			client.Request.Accept = HttpContentTypes.ApplicationJson;
			HttpResponse response = client.Get(UrlFor("/country/ES/en"));

			Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
			Assert.That(response.ContentType, Is.EqualTo(HttpContentTypes.ApplicationJson));
			Assert.That(response.DynamicBody.country.name, Is.EqualTo(translation));
		}
        public static string Authorize(string baseUrl, string accountId, string apiKey)
        {
            var http = new HttpClient();
            var uri = new UriBuilder(baseUrl);
            uri.Path = "authenticate";

            var result = http.Get(uri.ToString(), new { accountid = accountId, key = apiKey });
            var json = JObject.Parse(result.RawText);
            if (((string)json["status"]).ToLower() == "error")
            {
                Logger.WriteError((string)json["msg"]);
                throw new ApplicationException((string)json["msg"]);
            }
            if (!String.IsNullOrEmpty((string)json["accesstoken"]))
                return json["accesstoken"].ToString();
            throw new ApplicationException(result.RawText);
        }
		public void GET_Existing_OK()
		{
			string code = "DK", language = "es", translation = "Dinamarca";
			var repository = Substitute.For<ITranslationRepository>();
			Replacing(repository);
			repository.Get(code, Arg.Is(CultureInfo.GetCultureInfo(language))).Returns(
				new TranslationMdl{Alpha2 = code, Language = language, Name = translation});

			var client = new HttpClient();
			client.Request.Accept = HttpContentTypes.ApplicationJson;
			HttpResponse response = client.Get(UrlFor("/translation/DK/es"));

			Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
			Assert.That(response.DynamicBody.success, Is.True);
			Assert.That(response.DynamicBody.translation.data, Is.EqualTo(translation));

		}
Example #27
0
        public Version GetVersion()
        {
            var client = new HttpClient(m_BaseUri)
                         {
                             Request = { Accept = HttpContentTypes.ApplicationJson }
                         };

            var response = client.Get("/about/version",
                                      new
                                      {
                                          // TODO: should be in settings right!?
                                          apiKey="pass@word1"
                                      });
            var version = JsonConvert.DeserializeObject<Version>(response.RawText);

            return version;
        }
        public void Validate()
        {
            if (string.IsNullOrWhiteSpace(Url))
                throw new ArgumentNullException("Url", "Url to validate must be specified");

            string urlToValidate = BuildUrl(ValidatorType);
            var http = new HttpClient
            {
                Request = { Accept = HttpContentTypes.TextHtml }
            };

            var response = http.Get(urlToValidate);
            var validationSummary = response.RawText;

            var reportName = string.Format("{0}Report.html", ValidatorType);
            FileSave.SaveTheResponse(validationSummary, reportName);
        }
        public static EasyHttp.Http.HttpResponse send(TextMessageView view)
        {
            var deliveredUrl = "http://www.adoer.se/api/sms/deliveredelk";
            var responseUrl = "http://www.adoer.se/api/sms/recieveelk";

            var apiUrl = "https://api.46elks.com/a1/SMS";

            var username = "******";
            var password = "******";

            var data = String.Format("from={0}&to={1}&message={2}&whendelivered={3}$sms_url={4}",
                view.from, view.to, view.message, deliveredUrl, responseUrl);

            var http = new EasyHttp.Http.HttpClient();
            http.Request.SetBasicAuthentication(username, password);

            return http.Post(apiUrl, data, HttpContentTypes.ApplicationXWwwFormUrlEncoded);
        }
        public HttpResponseMessage PostElk(TextMessageView view)
        {
            var deliveredUrl = "http://www.adoer.se/api/sms/deliveredelk";
            var responseUrl  = "http://www.adoer.se/api/sms/recieveelk";
            var apiUrl       = "https://api.46elks.com/a1/SMS";

            var username = "******";
            var password = "******";

            var data = String.Format("from={0}&to={1}&message={2}&whendelivered={3}$sms_url={4}",
                                     view.from, view.to, view.message, deliveredUrl, responseUrl);

            var http = new EasyHttp.Http.HttpClient();

            http.Request.SetBasicAuthentication(username, password);

            var ans = http.Post(apiUrl, data, HttpContentTypes.ApplicationXWwwFormUrlEncoded);

            var model = view.getModel();

            model.created = DateTime.UtcNow;

            if (ans.StatusCode == HttpStatusCode.OK)
            {
                var body = ans.DynamicBody;

                model.apiId = body.id;
                model.error = false;

                model = repo.createTextMessage(model);

                return(Request.CreateResponse(ans.StatusCode, model));
            }
            else
            {
                var message = ans.RawText.Replace("\"", String.Empty);

                model.error        = true;
                model.errorMessage = message;
                model = repo.createTextMessage(model);

                return(Request.CreateResponse(ans.StatusCode, message));
            }
        }
        public HttpResponse Request(string method, string url, WebHeaderCollection headers, string body)
        {
            var client = new HttpClient();

            client.ThrowExceptionOnHttpError = false;

            foreach (var header in headers.AllKeys)
            {
                var value = headers[header];

                switch (header)
                {
                    case "Content-Type":
                        client.Request.ContentType = value;
                        break;
                    case "User-Agent":
                        client.Request.UserAgent = value;
                        break;
                    default:
                        client.Request.AddExtraHeader(header, value);
                        break;
                }
            }

            try
            {
                var response = client.Post(url, body, headers["Content-Type"]);

                return new HttpResponse()
                {
                    Status = new HttpStatus()
                    {
                        Code = response.StatusCode,
                        Message = response.StatusDescription
                    },
                    Headers = response.RawHeaders,
                    Body = response.RawText
                };
            }
            catch (WebException exception)
            {
                throw new UserAppException(exception.Message, exception);
            }
        }
        public static EasyHttp.Http.HttpResponse send(TextMessageView view)
        {
            var deliveredUrl = "http://www.adoer.se/api/sms/deliveredelk";
            var responseUrl  = "http://www.adoer.se/api/sms/recieveelk";

            var apiUrl = "https://api.46elks.com/a1/SMS";

            var username = "******";
            var password = "******";

            var data = String.Format("from={0}&to={1}&message={2}&whendelivered={3}$sms_url={4}",
                                     view.from, view.to, view.message, deliveredUrl, responseUrl);

            var http = new EasyHttp.Http.HttpClient();

            http.Request.SetBasicAuthentication(username, password);

            return(http.Post(apiUrl, data, HttpContentTypes.ApplicationXWwwFormUrlEncoded));
        }
        public HttpResponseMessage PostElk(TextMessageView view)
        {
            var deliveredUrl = "http://www.adoer.se/api/sms/deliveredelk";
            var responseUrl = "http://www.adoer.se/api/sms/recieveelk";
            var apiUrl = "https://api.46elks.com/a1/SMS";

            var username = "******";
            var password = "******";

            var data = String.Format("from={0}&to={1}&message={2}&whendelivered={3}$sms_url={4}",
                view.from, view.to, view.message, deliveredUrl, responseUrl);

            var http = new EasyHttp.Http.HttpClient();
            http.Request.SetBasicAuthentication(username, password);

            var ans = http.Post(apiUrl, data, HttpContentTypes.ApplicationXWwwFormUrlEncoded);

            var model = view.getModel();
            model.created = DateTime.UtcNow;

            if (ans.StatusCode == HttpStatusCode.OK)
            {
                var body = ans.DynamicBody;

                model.apiId = body.id;
                model.error = false;

                model = repo.createTextMessage(model);

                return Request.CreateResponse(ans.StatusCode, model);
            }
            else
            {
                var message = ans.RawText.Replace("\"", String.Empty);

                model.error = true;
                model.errorMessage = message;
                model = repo.createTextMessage(model);

                return Request.CreateResponse(ans.StatusCode, message);
            }
        }
Example #34
0
        public SurfModule()
        {
            Get["/"] = _ => Response.AsRedirect("/nexus4", Nancy.Responses.RedirectResponse.RedirectType.SeeOther);

            Get["/nexus4"] = _ =>
                Response.AsText(
                    String.Format(
                        new HttpClient()
                            .Get("http://play.google.com/store/devices/details?id=nexus_4_16gb&feature=microsite&hl=en")
                            .RawText
                            .Contains("We are out of inventory. Please check back soon.") ? "Fortfarande s**t {0}" : "Nu finns telefonen inne {0}!",
                        DateTime.Now.ToString("G")
                    )
                );

            Get["/surf"] = _ =>
                {
                    Uri path;

                    if (Uri.TryCreate(Request.Query.url, UriKind.Absolute, out path))
                    {
                        var client = new HttpClient();
                        client.StreamResponse = true;
                        client.Request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11";

                        client.Get(path.ToString());

                        using (var responseStream = client.Response.ResponseStream)
                        {
                            var memoryStream = new MemoryStream();
                            responseStream.CopyTo(memoryStream);
                            memoryStream.Position = 0;

                            return Response.FromStream(memoryStream, "text/html");
                        }
                    }
                    else
                    {
                        return Response.AsText("ogiltig url");
                    }
                };
        }
        public void PostMessage(string channelId, string text)
        {
            // It is only allowed to post messages to users via their IM channel id.
            if (channelId.StartsWith("U"))
            {
                channelId = SlackUserToIm(channelId);
            }

            var url = string.Format("https://slack.com/api/chat.postMessage?token={0}&channel={1}&as_user=true", SlackWindowsTray.Default.SlackToken, channelId);

            dynamic data = new ExpandoObject(); // Or any dynamic type
            data.text = text;

            var http = new HttpClient();
            var response = http.Post(url, data, HttpContentTypes.ApplicationXWwwFormUrlEncoded).DynamicBody;
            if (!response.ok)
            {
                throw new ExternalException("Message failed: " + response);
            }
        }
        public HttpResponseMessage List()
        {
            string hostAddress = string.Empty;

            //string hostAddress = "http://13.93.209.195:4243/";

            if (Request.Headers.Contains(hostaddress))
            {
                hostAddress = Request.Headers.GetValues(hostaddress).First();
            }

            var url  = string.Join("/", hostAddress, "images/json");
            var http = new HttpClient();

            http.Request.Accept = HttpContentTypes.ApplicationJson;
            HttpResponse        response            = http.Get(url);
            var                 deserializeObject   = JsonConvert.DeserializeObject(response.RawText);
            HttpResponseMessage httpResponseMessage = Request.CreateResponse(response.StatusCode, deserializeObject, new HttpConfiguration().Formatters.JsonFormatter);

            return(httpResponseMessage);
        }
Example #37
0
        private void TestButton_Click(object sender, RoutedEventArgs e)
        {
            var address = SiteTextBox.Text;
            var textToMatch = TextToMatchTextBox.Text;
            MessageTextBox.Text = "Message: ";

            var http = new HttpClient();
            bool result = false;
            try
            {
                var response = http.Get(address);
                result = response.RawText.Contains(textToMatch);
                MessageTextBox.Text = result ? string.Format(@"Message:  ""{0}"" found in page", textToMatch) : string.Format(@"Message:  ""{0}"" not found in page", textToMatch);
            }
            catch (Exception ex)
            {
                MessageTextBox.Text = "Message: " + ex.Message;
            }

                StatusIndicator.Fill = result ? new SolidColorBrush(Colors.Chartreuse) : new SolidColorBrush(Colors.Red);
                LastTestAtTextBox.Text = string.Format("Last tested at {0}", DateTime.Now);
        }
 public OSHttpClient()
 {
     _easyHttpClient = new EasyHttp.Http.HttpClient();
     _easyHttpClient.Request.Accept            = HttpContentTypes.ApplicationJson;
     _easyHttpClient.ThrowExceptionOnHttpError = true;
 }
Example #39
0
        /// <summary>
        /// Parse the command line arguments and take appropriate actions. Stolen from Modboy
        /// </summary>
        public static void ParseArguments(string[] args)
        {
            if (!args.AnySafe())
            {
                return;
            }

            bool launchedViaProtocolHandle = args[0].ContainsInvariant(Constants.ProtocolHandle);

            // Launched via protocol handle - parse task
            if (launchedViaProtocolHandle)
            {
                // find example at: https://dev.gamebanana.com/skins/150504?modboy
                // ex: modboy://Skin,150504,363769
                // Extract the input from the arguments
                var regex = new Regex(Constants.ProtocolHandle + "([A-Za-z]+),([0-9]+),([0-9]+)",
                                      RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
                if (!regex.IsMatch(args[0]))
                {
                    MessageBox.Show("QLMM failed to process the URL. Sorry!");
                    return;
                }
                var match = regex.Match(args[0]);

                // Get the valuable data
                var subType = match.Groups[1].Value;
                var subId   = match.Groups[2].Value;
                var fileId  = match.Groups[3].Value;

                string httptarget = "https://gamebanana.com/apiv3/" + subType + "/" + subId;
                Uri    uritarget  = new Uri(httptarget);
                EasyHttp.Http.HttpClient client = new EasyHttp.Http.HttpClient();
                httpresponse = client.Get(httptarget).RawText;

                JObject apiJSON = JObject.Parse(httpresponse);

                try
                {
                    string modName = (string)apiJSON[""]["_sName"]; // Causes NullReferenceException, please fix.
                    string modUrl  = "https://gamebanana.com/dl/" + fileId;
                    //string modfileName = (string)apiJSON["_aFiles"]["_sFile"];

                    // Create directory if necessary
                    if (!Directory.Exists(FileSystem.TempStorageDirectory))
                    {
                        Directory.CreateDirectory(FileSystem.TempStorageDirectory);
                    }

                    WebClient fileClient = new WebClient();
                    fileClient.DownloadFileCompleted   += new AsyncCompletedEventHandler(Completed);
                    fileClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
                    fileClient.DownloadFileAsync(new Uri(modUrl), Path.Combine(FileSystem.TempStorageDirectory, fileId));

                    outerFilePath  = Path.Combine(FileSystem.TempStorageDirectory, fileId);
                    outerFileName  = fileId;
                    modDisplayName = modName;

                    main.label1.Text = "Downloading " + modName + "...";
                }
                catch (Exception e) {
                    MessageBox.Show("An error has occurred!\n\n" + e.Message + "\n\n" + e.StackTrace);
                    Process.GetCurrentProcess().Kill();
                }
            }
        }