Пример #1
0
        /// <summary>
        /// Matches a request by HTTP header on a datetime value (per RFC-2616).
        /// </summary>
        /// <param name="builder">The request matching builder instance.</param>
        /// <param name="name">The header name.</param>
        /// <param name="date">The header value.</param>
        /// <returns>The request matching builder instance.</returns>
        public static RequestMatching Header(this RequestMatching builder, string name, DateTimeOffset date)
        {
            // https://tools.ietf.org/html/rfc2616#section-3.3.1
            CultureInfo ci = CultureInfo.InvariantCulture;

#if NETFRAMEWORK
            // .NET Framework does not normalize other common date formats,
            // so we use multiple matches.
            return(builder.Any(any => any
                               .Header(name, date.ToString("R", ci))
                               .Header(name, date.ToString("dddd, dd-MMM-yy HH:mm:ss 'GMT'", ci))       // RFC 1036
                               .Header(name, date.ToString("ddd MMM  d  H:mm:ss yyyy", ci))             // ANSI C's asctime()
                               ));
#else
            return(builder.Header(name, date.ToString("R", ci)));
#endif
        }