Exemple #1
0
 public HttpResponse()
 //: base("HttpResponse")
 {
     //setType(typeof(HttpResponse));
     m_EntityHeader   = new HttpEntityHeader();
     m_ResponseHeader = new HttpResponseHeader();
     m_Body           = new HttpBody();
 }
        private static void ReadBody(UInt32 handler, HttpRequest httpRequest,
                                     byte[] BodyContent, Int32 BodyBytesInHeader,
                                     Int32 BodyLength, Int32 HeaderBytesToSkip)
        {
            if (0 == BodyLength)
            {
                return;
            }

            int bytesRec = 0, readSoFar = 0;

            List <Byte> BByte = new List <Byte>(BodyLength);

            for (int i = HeaderBytesToSkip; i < BodyBytesInHeader; ++i)
            {
                ++readSoFar;
                BByte.Add(BodyContent[i]);
            }

            Int32    remaining = BodyLength - readSoFar;
            HttpBody body      = httpRequest.GetBody();

            byte[] bytes = new byte[Magic_Number_Buffer];
            if (readSoFar < BodyLength)
            {
                //body contents remain to be completely read
                do
                {
                    //bytesRec = handler.Receive(bytes);
                    unsafe
                    {
                        fixed(Byte *sptr = bytes)
                        {
                            TCPSocket.SendReply(handler, sptr, Magic_Number_Buffer);
                        }
                    }
                    BByte.AddRange(bytes);
                    readSoFar += bytesRec;
                    remaining -= bytesRec;
                } while (remaining != 0);
            }

            body.Body = BByte.ToArray();
        }