Exemple #1
0
 /// <summary>
 /// Enables redirecting of all request over local server using the given password.
 /// </summary>
 /// <param name="password">The password.</param>
 public static void EnableRedirect(SongStorage songs, BackgroundStorage backgrounds)
 {
     redirectSongStorage = songs;
     redirectBackgroundStorage = backgrounds;
 }
Exemple #2
0
 /// <summary>
 /// Disables the redirect.
 /// </summary>
 public static void DisableRedirect()
 {
     redirectSongStorage = null;
     redirectBackgroundStorage = null;
 }
 public SongUriResolver(SongStorage forceStorage)
 {
     ForceStorage = forceStorage;
 }
		public SongUriResolver(SongStorage forceStorage)
		{
			ForceStorage = forceStorage;
		}
Exemple #5
0
		private async Task RespondPutSong(OwinRequest request, OwinResponse response, SongStorage storage, string name)
		{
			var contentLength = request.Headers["Content-Length"];
			// TODO: error handling
			var ft = storage.Put(name);
			await request.Body.CopyToAsync(ft.Stream);
			await ft.FinishAsync();
		}
Exemple #6
0
		private async Task RespondGetSong(OwinResponse response, SongStorage storage, string name)
		{
			bool success = true;
			try
			{
				using (var entry = await storage.GetAsync(name, CancellationToken.None))
				{
					response.SetHeader("Content-Type", "text/xml");
					if (entry.LastModified.HasValue)
					{
						response.SetHeader("Last-Modified", entry.LastModified.Value.ToString("r"));
					}
					await entry.Stream.CopyToAsync(response.Body);
				}
			}
			catch (FileNotFoundException)
			{
				success = false;
			}
			catch (ArgumentException)
			{
				success = false;
			}

			if (!success)
			{
				await response.RespondNotFound();
			}
		}