Пример #1
0
        private void Add(HttpMessage http, object data, Suffix suffix = Suffix.None)
        {
            if (http == null)
            {
                return;
            }

            StringBuilder sb = new StringBuilder();

            if (JsonBase.IsJson(http.Data))
            {
                data = JsonPacket.Parse(http.Data);
            }
            else if (IsHandshake(http.Data))
            {
                data = http.Data;
            }

            sb.Append(http.Message.Substring(0, http.Message.Length - HttpMessage.EndOfMessage.Length));

            if (data != null)
            {
                sb.Append(HttpMessage.EndOfMessage);
                sb.Append(data);
            }

            switch (suffix)
            {
            case Suffix.EOL:
            {
                sb.Append(Constant.Newline);
                sb.Append("________________________________________________________________________________________________________________________________________________________________________________________________");
                break;
            }
            }

            sb.Append(Constant.Newline);

            Add(sb);
        }