private static Request GetRequest(Session oS)
        {
            var url = new Uri(oS.fullUrl);
            var host = url.Host;
            var path = url.AbsolutePath;

            var request = new Request();
            request.host = host;
            request.path = path;
            request.method = oS.oRequest.headers.HTTPMethod;
            request.url = oS.fullUrl;
            request.httpVersion = oS.oRequest.headers.HTTPVersion;
            request.headersSize = oS.oRequest.headers.ByteCount() + 2;
            request.bodySize = oS.requestBodyBytes.Length;
            request.headers = GetHeaders(oS.oRequest.headers);
            request.cookies = GetCookies(oS.oRequest.headers);
            request.queryString = GetQueryString(oS.fullUrl);

            if ((oS.requestBodyBytes != null) && (oS.requestBodyBytes.Length > 0))
            {
                request.postData = GetPostData(oS);
            }
            return request;
        }
        private static byte[] GetRequestFromEntry(Request request)
        {
            string b = request.method;
            string httpVersion = request.httpVersion;
            if (string.IsNullOrEmpty(httpVersion))
            {
                httpVersion = "HTTP/0.0";
            }
            string url = request.url;

            string str4 = GetHeaderStringFromParams(request.headers);
            string str5 = string.Empty;
            if (request.postData != null)
            {
                if (!string.IsNullOrEmpty(request.postData.text))
                {
                    str5 = request.postData.text;
                }
                else if (request.postData.@params != null)
                {
                    str5 = GetStringFromParams(request.postData.@params);
                }
            }
            if (string.Equals("CONNECT", b, StringComparison.OrdinalIgnoreCase))
            {
                url = Utilities.TrimBeforeLast(url, '/');
            }

            string s = string.Format("{0} {1} {2}\r\n{3}\r\n{4}", new object[] { b, url, httpVersion, str4, str5 });

            return CONFIG.oHeaderEncoding.GetBytes(s);
        }
Esempio n. 3
0
        private static void AddRequest(Table table, Request request)
        {
            if (request == null)
            {
                return;
            }
            Table subtable = CreateSubtable("request", table);
            //AddTextRow("bodySize", request.bodySize, subtable);
            //AddTextRow("comment", request.comment, subtable);
            //AddTextRow("headersSize", request.headersSize, subtable);
            //AddTextRow("host", request.host, subtable);
            AddTextRow("url", request.url, subtable);
            AddTextRow("method", request.method, subtable);

            //AddTextRow("httpVersion", request.httpVersion, subtable);
            //AddTextRow("path", request.path, subtable);

            AddCookies(subtable, request.cookies);
            AddNameValueTable(subtable, request.headers, "headers");
            AddNameValueTable(subtable, request.queryString, "queryString");
            AddPostData(subtable, request.postData);
        }