Beispiel #1
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();
            }
        }