public virtual long ServeFile(ContextRFC AContext, string AFile, CustomHttpServer server) { if (ContentType.Length == 0) { ContentType = server.MimeTable.GetFileMIMEType(AFile); } ContentLength = (int)new FileInfo(AFile).Length; Date = File.GetLastWriteTime(AFile); WriteHeader(); AContext.TcpConnection.Socket.WriteFile(AFile); return(ContentLength); }
public virtual long SmartServeFile(ContextRFC AContext, HttpRequestInfo ARequestInfo, string AFile, CustomHttpServer server) { DateTime LFileDate = File.GetLastWriteTime(AFile); DateTime LReqDate = Http.GmtToLocalDateTime(ARequestInfo.RawHeaders["If-Modified-Since"]); if (LReqDate.Ticks > 0 && LReqDate.Subtract(new TimeSpan(LFileDate.Ticks)).Ticks < 20000) { ResponseNo = 304; return(0); } else { return(ServeFile(AContext, AFile, server)); } }