public void DefaultValues()
        {
            var dateHeader = new DateHeader();

            Assert.Null(dateHeader.Value);
            Assert.Null(dateHeader.RawValue);
        }
Beispiel #2
0
        internal void WriteHeader(HeaderId id, ExDateTime data)
        {
            if (this.hasAllHeaders)
            {
                return;
            }
            DateHeader header = (DateHeader)Header.Create(id);

            MimeInternalHelpers.SetDateHeaderValue(header, data.UniversalTime, data.Bias);
            this.WriteHeader(header);
        }
Beispiel #3
0
            public void Must_parse_correctly(string headerValue, int year, int month, int day, int hour, int minute, int second)
            {
                DateHeader header = DateHeader.Parse(headerValue);

                Assert.That(header, Is.Not.Null);
                Assert.That(header.HttpDate.Year, Is.EqualTo(year));
                Assert.That(header.HttpDate.Month, Is.EqualTo(month));
                Assert.That(header.HttpDate.Day, Is.EqualTo(day));
                Assert.That(header.HttpDate.Hour, Is.EqualTo(hour));
                Assert.That(header.HttpDate.Minute, Is.EqualTo(minute));
                Assert.That(header.HttpDate.Second, Is.EqualTo(second));
            }
Beispiel #4
0
        public void DecorateMessage(TransportMailItem message)
        {
            message.HeloDomain           = ConfigurationProvider.GetDefaultDomainName();
            message.ReceiveConnectorName = "FromLocal";
            message.RefreshMimeSize();
            long       mimeSize = message.MimeSize;
            HeaderList headers  = message.RootPart.Headers;

            if (!(headers.FindFirst(HeaderId.Date) is DateHeader))
            {
                DateHeader newChild = new DateHeader("Date", DateTime.UtcNow.ToLocalTime());
                headers.AppendChild(newChild);
            }
            headers.RemoveAll(HeaderId.Received);
            DateHeader     dateHeader = new DateHeader("Date", DateTime.UtcNow.ToLocalTime());
            string         value      = dateHeader.Value;
            ReceivedHeader newChild2  = new ReceivedHeader(this.SourceServerFqdn, SubmissionItemBase.FormatIPAddress(this.SourceServerNetworkAddress), this.LocalIP.HostName, this.ReceivedHeaderTcpInfo, null, this.mailProtocol, SubmissionItemBase.serverVersion, null, value);

            headers.PrependChild(newChild2);
            message.ExtendedProperties.SetValue <bool>("Microsoft.Exchange.Transport.ElcJournalReport", this.IsElcJournalReport);
            if (this.IsMapiAdminSubmission)
            {
                headers.AppendChild(new AsciiTextHeader("X-MS-Exchange-Organization-Mapi-Admin-Submission", string.Empty));
            }
            if (this.IsDlExpansionProhibited)
            {
                headers.AppendChild(new AsciiTextHeader("X-MS-Exchange-Organization-DL-Expansion-Prohibited", string.Empty));
            }
            headers.AppendChild(new AsciiTextHeader("X-MS-Exchange-Organization-Processed-By-MBTSubmission", string.Empty));
            if (ConfigurationProvider.GetForwardingProhibitedFeatureStatus() && this.IsAltRecipientProhibited)
            {
                headers.AppendChild(new AsciiTextHeader("X-MS-Exchange-Organization-Alt-Recipient-Prohibited", string.Empty));
            }
            headers.RemoveAll("X-MS-Exchange-Organization-OriginalSize");
            headers.AppendChild(new AsciiTextHeader("X-MS-Exchange-Organization-OriginalSize", mimeSize.ToString(NumberFormatInfo.InvariantInfo)));
            headers.RemoveAll("X-MS-Exchange-Organization-OriginalArrivalTime");
            Header newChild3 = new AsciiTextHeader("X-MS-Exchange-Organization-OriginalArrivalTime", Util.FormatOrganizationalMessageArrivalTime(this.OriginalCreateTime));

            headers.AppendChild(newChild3);
            headers.RemoveAll("X-MS-Exchange-Organization-MessageSource");
            Header newChild4 = new AsciiTextHeader("X-MS-Exchange-Organization-MessageSource", "StoreDriver");

            headers.AppendChild(newChild4);
            headers.AppendChild(new AsciiTextHeader("X-MS-Exchange-Transport-FromEntityHeader", RoutingEndpoint.Hosted.ToString()));
            headers.AppendChild(new AsciiTextHeader("X-MS-Exchange-Organization-FromEntityHeader", RoutingEndpoint.Hosted.ToString()));
            message.Directionality = MailDirectionality.Originating;
            message.UpdateDirectionalityAndScopeHeaders();
        }
Beispiel #5
0
        // Token: 0x06000334 RID: 820 RVA: 0x0000CC4C File Offset: 0x0000AE4C
        private static void SetResponseHeadersForZipAttachments(IAttachmentWebOperationContext webOperationContext, string fileName)
        {
            if (webOperationContext == null)
            {
                throw new ArgumentNullException("webOperationContext");
            }
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException("Argument fileName may not be null or empty string");
            }
            webOperationContext.ContentType = "application/zip; authoritative=true;";
            ZipFileAttachments.SetZipContentDispositionResponseHeader(webOperationContext, fileName);
            DateHeader dateHeader = new DateHeader("Date", DateTime.UtcNow.AddDays(-1.0));

            webOperationContext.Headers["Expires"] = dateHeader.Value;
        }
Beispiel #6
0
        private ExDateTime GetReceivedDate(Stream mimeStream, bool useSentTime)
        {
            ExDateTime?exDateTime = null;

            try
            {
                using (MimeReader mimeReader = new MimeReader(new SuppressCloseStream(mimeStream)))
                {
                    if (mimeReader.ReadNextPart())
                    {
                        while (mimeReader.HeaderReader.ReadNextHeader())
                        {
                            if (mimeReader.HeaderReader.HeaderId == HeaderId.Received)
                            {
                                ReceivedHeader receivedHeader = Header.ReadFrom(mimeReader.HeaderReader) as ReceivedHeader;
                                if (receivedHeader != null && receivedHeader.Date != null)
                                {
                                    DateTime dateTime = this.ToDateTime(receivedHeader.Date);
                                    return(new ExDateTime(ExTimeZone.UtcTimeZone, dateTime));
                                }
                            }
                            if (useSentTime && mimeReader.HeaderReader.HeaderId == HeaderId.Date)
                            {
                                DateHeader dateHeader = Header.ReadFrom(mimeReader.HeaderReader) as DateHeader;
                                if (dateHeader != null)
                                {
                                    exDateTime = new ExDateTime?(new ExDateTime(ExTimeZone.UtcTimeZone, dateHeader.DateTime));
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                mimeStream.Seek(0L, SeekOrigin.Begin);
            }
            if (exDateTime != null)
            {
                return(exDateTime.Value);
            }
            return(ExDateTime.MinValue);
        }
        // Token: 0x0600010A RID: 266 RVA: 0x00004630 File Offset: 0x00002830
        private void WriteResponseHeaders(string contentType, AttachmentPolicyLevel policyLevel, Attachment attachment)
        {
            if (policyLevel == AttachmentPolicyLevel.ForceSave)
            {
                this.webOperationContext.Headers["X-Download-Options"] = "noopen";
            }
            if (string.Compare(contentType, "text/html", StringComparison.OrdinalIgnoreCase) == 0)
            {
                attachment.IsInline = false;
            }
            this.webOperationContext.ContentType = contentType + "; authoritative=true;";
            this.WriteContentDispositionResponseHeader(attachment.FileName, attachment.IsInline);
            if (attachment.IsInline || this.IsImagePreview)
            {
                this.webOperationContext.SetNoCacheNoStore();
                return;
            }
            DateHeader dateHeader = new DateHeader("Date", DateTime.UtcNow.AddDays(-1.0));

            this.webOperationContext.Headers["Expires"] = dateHeader.Value;
        }
Beispiel #8
0
    public static async Task Main(string[] args)
    {
        Args = args;

        Console.WriteLine(BenchmarkApplication.ApplicationName);
#if !DATABASE
        Console.WriteLine(BenchmarkApplication.Paths.Plaintext);
        Console.WriteLine(BenchmarkApplication.Paths.Json);
#else
        Console.WriteLine(BenchmarkApplication.Paths.Fortunes);
        Console.WriteLine(BenchmarkApplication.Paths.SingleQuery);
        Console.WriteLine(BenchmarkApplication.Paths.Updates);
        Console.WriteLine(BenchmarkApplication.Paths.MultipleQueries);
#endif
        DateHeader.SyncDateTimer();

        var host   = BuildWebHost(args);
        var config = (IConfiguration)host.Services.GetService(typeof(IConfiguration));
        BatchUpdateString.DatabaseServer = config.Get <AppSettings>().Database;
#if DATABASE
        await BenchmarkApplication.Db.PopulateCache();
#endif
        await host.RunAsync();
    }
 public DateHeaderTest()
 {
     _dateHeader = new DateHeader();
 }
Beispiel #10
0
 public static void SetDateHeaderValue(DateHeader header, DateTime value, TimeSpan timeZoneOffset)
 {
     header.SetValue(value, timeZoneOffset);
 }
Beispiel #11
0
 public void Must_not_result_in_header(string headerValue)
 {
     Assert.That(DateHeader.Parse(headerValue), Is.Null);
 }