public void LocationFiltering(MediaQueryContext query, MediaLocationContext location) { // TODO: Could be an interface instead for further extensibility if (!(location is FileSystemLocationContext)) return; var fileLocation = location as FileSystemLocationContext; // Add header detail query.Headers.Add( new MediaHeaderContext(location) { ContentLength = fileLocation.File.GetSize(), // TODO: MIME will be auto-accepted since we leave ContentType blank; so format match will just be on extension. Not a viable long-term solution. ContentType = "", //fileLocation.File.GetFileType(),// .Trim('.').ToLower()), HashCode = fileLocation.File.GetHashCode(), TimeStamp = fileLocation.File.GetLastUpdated(), Title = fileLocation.File.GetName().ExtractFileName() }); }
public static HttpHeaderContext ProbeHttpHeaders(MediaLocationContext location) { var url = location.Location; WebRequest WebRequestObject = HttpWebRequest.Create(url); // Begin GET WebRequestObject.Method = "GET"; WebResponse ResponseObject = WebRequestObject.GetResponse(); // Extract title from URL // TODO: Could be an extension method var title = url.ExtractFileName(); var headers = new HttpHeaderContext(location) { ContentLength = ResponseObject.ContentLength, Headers = ResponseObject.Headers, HashCode = ResponseObject.GetHashCode(), Title = title }; string contentType = ResponseObject.ContentType; string contentTypeParameter = ""; int index = contentType.IndexOf(";"); if (index > 0) { contentType = contentType.Substring(0, index); // e.g. CHARSET contentTypeParameter = contentType.Substring(index+1).Trim(); } headers.ContentType = contentType; headers.ContentTypeParameter = contentTypeParameter; if (ResponseObject.Headers["Last-Modified"]!=null) { DateTime timeStamp; if (!DateTime.TryParse(ResponseObject.Headers["Last-Modified"],out timeStamp)) { timeStamp = DateTime.Now; } headers.TimeStamp = timeStamp; } ResponseObject.Close(); return headers; }
public void LocationFiltered(MediaQueryContext query, MediaLocationContext location) { if (!(location is FileSystemLocationContext)) return; }
public MediaHeaderContext(MediaLocationContext location) { LocationContext = location; }
public void LocationFiltered(MediaQueryContext query, MediaLocationContext location) { return; }
public void LocationFiltering(MediaQueryContext query, MediaLocationContext location) { if (location.QueryName != "Http") return; query.Headers.Add(ProbeHttpHeaders(location)); }