コード例 #1
0
 private static int GetTotalSize(Response response)
 {
     if ((response.headersSize >= 0) && (response.bodySize >= 0))
     {
         // #TODO: i don't understand the condition
         return (response.headersSize + response.bodySize);
     }
     return -1;
 }
コード例 #2
0
        private static Response GetResponse(Session session)
        {
            var response = new Response();
            response.status = session.responseCode;
            response.statusText = Utilities.TrimBefore(session.oResponse.headers.HTTPResponseStatus, ' ');
            response.httpVersion = session.oResponse.headers.HTTPVersion;
            response.headersSize = session.oResponse.headers.ByteCount() + 2;
            response.redirectURL = session.oResponse["Location"];
            response.bodySize = session.responseBodyBytes.Length;
            response.headers = GetHeaders(session.oResponse.headers);
            response.cookies = GetCookies(session.oResponse.headers);
            response.content = GetBodyInfo(session);

            return response;
        }
コード例 #3
0
        private static byte[] GetResponseFromEntry(Response response)
        {
            string sHeaders = GetHeaderStringFromParams(response.headers);

            byte[] src = GetBodyArrayFromContent(response.content, sHeaders);

            string s = string.Format("{0} {1} {2}\r\n{3}\r\n",
                                     string.IsNullOrEmpty(response.httpVersion) ? "HTTP/0.0" : response.httpVersion,
                                     response.status,
                                     response.statusText,
                                     sHeaders);

            byte[] bytes = CONFIG.oHeaderEncoding.GetBytes(s);
            var dst = new byte[bytes.Length + src.Length];
            Buffer.BlockCopy(bytes, 0, dst, 0, bytes.Length);
            Buffer.BlockCopy(src, 0, dst, bytes.Length, src.Length);
            return dst;
        }
コード例 #4
0
ファイル: EntryRenderer.cs プロジェクト: bitpusher/mocument
        private static void AddResponse(Table table, Response response)
        {
            if (response == null)
            {
                return;
            }
            Table subtable = CreateSubtable("response", table);
            AddTextRow("status", response.status, subtable);

            AddTextRow("statusText", response.statusText, subtable);
            AddTextRow("redirectURL", response.redirectURL, subtable);
            //AddTextRow("httpVersion", response.httpVersion, subtable);

            //AddTextRow("headersSize", response.headersSize, subtable);
            AddTextRow("comment", response.comment, subtable);
            //AddTextRow("bodySize", response.bodySize, subtable);

            AddCookies(subtable, response.cookies);
            AddNameValueTable(subtable, response.headers, "headers");

            Content content = response.content;

            Table cntable = CreateSubtable("content", subtable);

            AddTextRow("mimeType", content.mimeType, cntable);
            AddTextRow("size", content.size, cntable);
            AddTextRow("encoding", content.encoding, cntable);
            AddTextRow("compression", content.compression, cntable);
            AddTextRow("text", content.text, cntable);
            //AddTextRow("comment", content.comment, cntable);
        }