void IHttpServerAgent.HandleRequest(BaseConnection c, HttpMessageReader httpReader, ArraySegment<byte> httpContent) { if (httpReader.Method != Methods.Get) { var writer = new HttpMessageWriter(); writer.WriteResponse(StatusCodes.NotAcceptable); httpServer.SendResponse(c, writer); } else { if (httpReader.RequestUri.Equals(uri1)) { var writer = new HttpMessageWriter(); writer.WriteStatusLine(StatusCodes.MovedPermanently); writer.WriteContentLength(0); writer.WriteLocation(c.LocalEndPoint.Protocol == ServerProtocol.Tcp, httpReader.Host.Host, httpReader.Host.Port, uri2); writer.WriteCRLF(); httpServer.SendResponse(c, writer); } else { var rawFile = GetFile(httpReader); if (rawFile.HasValue == false) { var writer = new HttpMessageWriter(); writer.WriteResponse(StatusCodes.NotFound); httpServer.SendResponse(c, writer); } else { var file = rawFile.Value; var writer = new HttpMessageWriter(); writer.WriteStatusLine(StatusCodes.OK); writer.WriteContentType(file.ContentType); writer.WriteContentLength(file.Content.Length); writer.WriteCRLF(); httpServer.SendResponse(c, writer); httpServer.SendResponse(c, new ArraySegment<byte>(file.Content)); } } } }