Ejemplo n.º 1
0
 /// <summary>
 /// HTTP请求处理[TRY]
 /// </summary>
 /// <param name="socket">HTTP套接字</param>
 public override unsafe void Request(Http.SocketBase socket)
 {
     if ((socket.HttpHeader.Flag & Http.HeaderFlag.IsSetIfModifiedSince) == 0)
     {
         Http.Response response = file(socket.HttpHeader);
         if (response != null)
         {
             socket.ResponseIdentity(ref response);
         }
         else
         {
             socket.ResponseErrorIdentity(Http.ResponseState.NotFound404);
         }
     }
     else
     {
         socket.ResponseIdentity(Http.Response.NotChanged304);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// HTTP请求处理[TRY]
 /// </summary>
 /// <param name="socket">HTTP套接字</param>
 public override unsafe void Request(Http.SocketBase socket)
 {
     Http.Response response = file(socket.HttpHeader);
     if (response != null)
     {
         socket.ResponseIdentity(ref response);
     }
     else
     {
         socket.ResponseErrorIdentity(Http.ResponseState.NotFound404);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// HTTP请求处理[TRY]
        /// </summary>
        /// <param name="socket">HTTP套接字</param>
        public override unsafe void Request(Http.SocketBase socket)
        {
            Http.Header     header = socket.HttpHeader;
            SubArray <byte> path   = header.Path;
            int             index;

            if (header.IsSearchEngine == 0)
            {
                byte[] rewritePath;
#if !MONO
                if (WebConfigIgnoreCase)
                {
                    if ((index = callSearcher.SearchLower(ref path)) >= 0)
                    {
                        call(index, socket);
                        return;
                    }
                    rewritePath = rewritePaths.GetLower(ref path);
                }
                else
#endif
                {
                    if ((index = callSearcher.Search(ref path)) >= 0)
                    {
                        call(index, socket);
                        return;
                    }
                    rewritePath = rewritePaths.Get(ref path);
                }
                if (rewritePath != null)
                {
                    Http.Response response = null;
                    file(header, file(rewritePath, (header.Flag & Http.HeaderFlag.IsSetIfModifiedSince) == 0 ? new SubArray <byte>() : header.IfModifiedSince, ref response, false), ref response);
                    if (response != null)
                    {
                        socket.ResponseIdentity(ref response);
                        return;
                    }
                    socket.ResponseErrorIdentity(Http.ResponseState.NotFound404);
                }
            }
            else
            {
#if !MONO
                if (WebConfigIgnoreCase)
                {
                    if ((index = rewriteSearcher.SearchLower(ref path)) >= 0)
                    {
                        request(index, socket);
                        return;
                    }
                    if ((index = viewSearcher.SearchLower(ref path)) >= 0)
                    {
                        request(index, socket);
                        return;
                    }
                    if ((index = callSearcher.SearchLower(ref path)) >= 0)
                    {
                        call(index, socket);
                        return;
                    }
                }
                else
#endif
                {
                    if ((index = rewriteSearcher.Search(ref path)) >= 0)
                    {
                        request(index, socket);
                        return;
                    }
                    if ((index = viewSearcher.Search(ref path)) >= 0)
                    {
                        request(index, socket);
                        return;
                    }
                    if ((index = callSearcher.Search(ref path)) >= 0)
                    {
                        call(index, socket);
                        return;
                    }
                }
            }
            if (beforeFile(socket))
            {
                base.Request(socket);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// HTTP请求处理[TRY]
        /// </summary>
        /// <param name="socket">HTTP套接字</param>
        public override unsafe void Request(Http.SocketBase socket)
        {
            Http.Header header = socket.HttpHeader;
            if (((uint)header.ContentLength | (uint)header.IsBoundary) == 0)
            {
                Http.Response            response = Http.Response.Get();
                SubBuffer.PoolBufferFull buffer   = header.Buffer;
                byte[]      domain = socket.IsSsl ? sslLocationDomain : locationDomain, bufferArray = buffer.Buffer;
                BufferIndex uri    = header.UriIndex;
                int         length = domain.Length + uri.Length;
                if (uri.Length != 0)
                {
                    if (bufferArray[buffer.StartIndex + uri.StartIndex] == '/')
                    {
                        uri.Next();
                        if (uri.Length == 0)
                        {
                            goto END;
                        }
                        --length;
                    }
                    if (length <= header.HeaderEndIndex)
                    {
                        int startIndex = uri.StartIndex - domain.Length;
                        if (startIndex >= 0)
                        {
                            Buffer.BlockCopy(domain, 0, bufferArray, startIndex += buffer.StartIndex, domain.Length);
                            response.SetLocation(bufferArray, startIndex, length, locationState);
                        }
                        else
                        {
                            Buffer.BlockCopy(bufferArray, buffer.StartIndex + uri.StartIndex, bufferArray, buffer.StartIndex + domain.Length, uri.Length);
                            Buffer.BlockCopy(domain, 0, bufferArray, buffer.StartIndex, domain.Length);
                            response.SetLocation(bufferArray, buffer.StartIndex, length, locationState);
                        }
                        socket.ResponseIdentity(ref response);
                        return;
                        //int endIndex = uri.EndIndex;
                        //if (header.HeaderEndIndex - endIndex - 7 >= length)
                        //{
                        //    fixed (byte* bufferFixed = bufferArray)
                        //    {
                        //        byte* bufferStart = bufferFixed + buffer.StartIndex, write = bufferStart + endIndex;
                        //        Memory.SimpleCopyNotNull64(domain, write, domain.Length);
                        //        Memory.SimpleCopyNotNull64(bufferStart + uri.StartIndex, write + domain.Length, uri.Length);
                        //    }
                        //    response.SetLocation(bufferArray, buffer.StartIndex + endIndex, length, locationState);
                        //    socket.Response(socketIdentity, ref response);
                        //    return;
                        //}
                    }
                }
END:
                response.SetLocation(domain, locationState);
                socket.ResponseIdentity(ref response);
            }
            else
            {
                socket.ResponseErrorIdentity(Http.ResponseState.BadRequest400);
            }
        }