コード例 #1
0
        public void AddField(HttpField field)
        {
            switch (field.Name)
            {
            case HttpConst.Host:
                Host = field.Value;
                break;

            case HttpConst.Accept:
                Accept.AddRange(field.Values);
                break;

            case HttpConst.AcceptLanguage:
                AcceptLanguage.AddRange(field.Values);
                break;

            case HttpConst.AcceptEncoding:
                AcceptEncoding.AddRange(field.Values);
                break;

            case HttpConst.AcceptCharset:
                AcceptCharset.AddRange(field.Values);

                if (AcceptCharset.Count > 0)
                {
                    ContentTransferEncoding = Encoding.GetEncoding(AcceptCharset[0]);
                }
                break;

            case HttpConst.KeepAlive:
                KeepAlive = field.Value;
                break;

            case HttpConst.Connection:
                Connection = field.Value;
                break;

            case HttpConst.UserAgent:
                UserAgent = field.RawValue;
                break;

            case HttpConst.Referer:
                Referer = field.Value;
                break;

            case HttpConst.Cookie:
                Cookie = field.Value;
                break;

            case HttpConst.IfUnmodifiedSince:
                // lastModified = HtmlTime.TimeHtml2Date(value);
                break;

            case HttpConst.IfModifiedSince:
                // se pueden recibir varios parametros "If-Modified-Since: Tue, 10 Oct 2006 13:16:15 GMT; length=13757"
                IfModifiedSince = HttpTime.TimeHtml2Date(field.RawValue);
                break;

            case HttpConst.IfNoneMatch:
                break;

            case HttpConst.ContentType:
                ContentType = field.Value;
                break;

            case HttpConst.ContentLength:
                ContentLength = int.Parse(field.Value);
                break;

            case HttpConst.ContentTransferEncoding:
                ContentTransferEncoding = Encoding.GetEncoding(field.Value);
                break;

            case HttpConst.Authorization:
                ParserUserAndPassword(field.Value);
                break;

            default:
                // currentRequest.RestHeaders.Add(tag.ToLower(), field);
                // Head.Fields.Add(field.Name, field);
                break;
            }

            Head.Fields.Add(field.Name, field);
        }
コード例 #2
0
 /// <summary>
 /// redondear una fecha para que sea compatible con las fechas que llegan desde mensajes
 /// HTTP que no tienen milisegundos
 /// </summary>
 /// <param name="dateTime"></param>
 /// <returns></returns>
 public static DateTime RoundDate(DateTime dateTime)
 {
     return(HttpTime.TimeHtml2Date(HttpTime.Date2TimeHtml(dateTime)));;
 }