using System; using System.Collections.Generic; using System.IO; using System.Text; namespace MediaBrowser.Dlna.Ssdp { public class SsdpHelper { /// /// Parses the socket response into a location Uri for the DeviceDescription.xml. /// /// The data. /// public static Dictionary ParseSsdpResponse(byte[] data) { var headers = new Dictionary(StringComparer.OrdinalIgnoreCase); using (var reader = new StreamReader(new MemoryStream(data), Encoding.ASCII)) { for (var line = reader.ReadLine(); line != null; line = reader.ReadLine()) { line = line.Trim(); if (string.IsNullOrEmpty(line)) { break; } var parts = line.Split(new[] { ':' }, 2); if (parts.Length == 2) { headers[parts[0]] = parts[1].Trim(); } } } return headers; } } }