예제 #1
0
        internal HttpResponse GetResponse(Stream stream, int millisecondsTimeout)
        {
            byte[] byteArray = base.ToByteArray();
            stream.Write(byteArray, 0, (int)byteArray.Length);
            HttpResponse httpResponse = HttpBase.Read <HttpResponse>(stream, new Func <string[], HttpResponse>(HttpResponse.Parse), millisecondsTimeout);

            return(httpResponse);
        }
예제 #2
0
        protected static T Read <T>(Stream stream, Func <string[], T> parser, int millisecondsTimeout)
            where T : HttpBase
        {
            string str;
            bool   flag  = false;
            Timer  timer = new Timer((object state) => {
                flag = true;
                stream.Close();
            }, null, millisecondsTimeout, -1);
            T         t         = default(T);
            Exception exception = null;

            try
            {
                try
                {
                    t = parser(HttpBase.readHeaders(stream, 8192));
                    string item = t.Headers["Content-Length"];
                    if ((item == null ? false : item.Length > 0))
                    {
                        t.EntityBodyData = HttpBase.readEntityBody(stream, item);
                    }
                }
                catch (Exception exception1)
                {
                    exception = exception1;
                }
            }
            finally
            {
                timer.Change(-1, -1);
                timer.Dispose();
            }
            if (flag)
            {
                str = "A timeout has occurred while reading an HTTP request/response.";
            }
            else if (exception != null)
            {
                str = "An exception has occurred while reading an HTTP request/response.";
            }
            else
            {
                str = null;
            }
            string str1 = str;

            if (str1 != null)
            {
                throw new WebSocketException(str1, exception);
            }
            return(t);
        }
예제 #3
0
 internal static HttpResponse Read(Stream stream, int millisecondsTimeout)
 {
     return(HttpBase.Read(stream, Parse, millisecondsTimeout));
 }
예제 #4
0
        internal static HttpRequest Read(Stream stream, int millisecondsTimeout)
        {
            HttpRequest httpRequest = HttpBase.Read <HttpRequest>(stream, new Func <string[], HttpRequest>(HttpRequest.Parse), millisecondsTimeout);

            return(httpRequest);
        }
        internal static HttpResponse Read(Stream stream, int millisecondsTimeout)
        {
            HttpResponse httpResponse = HttpBase.Read <HttpResponse>(stream, new Func <string[], HttpResponse>(HttpResponse.Parse), millisecondsTimeout);

            return(httpResponse);
        }
예제 #6
0
 internal HttpResponse GetResponse(Stream stream, int millisecondsTimeout)
 {
     byte[] array = ToByteArray();
     stream.Write(array, 0, array.Length);
     return(HttpBase.Read(stream, HttpResponse.Parse, millisecondsTimeout));
 }