Example #1
0
        private void SendFileContent(HttpListenerContext context, FileInfo fileInfo)
        {
            byte[]      fileContent  = GetContent(fileInfo);
            ContentType contentType  = GetContentType(fileInfo.Extension);
            string      lastModified = fileInfo.LastWriteTime.ToString("R");
            string      expires      = fileInfo.LastWriteTime.AddHours(23).ToString("R");

            responseWriter.AddLastModifiedAndExpires(context.Response, lastModified,
                                                     expires);

            if (RequestParser.GzipCanBeUsed(context.Request) &&
                fileContent.Length > 1024)
            {
                responseWriter.SendZippedResponse(context.Response,
                                                  new ByteResponseData(fileContent,
                                                                       contentType));
            }
            else
            {
                responseWriter.SendResponse(context.Response,
                                            new ByteResponseData(fileContent,
                                                                 contentType));
            }
        }