// Token: 0x06001345 RID: 4933 RVA: 0x0004F85C File Offset: 0x0004DA5C
        private PhotoResponse LoadPreview(PhotoRequest request, PhotoResponse response)
        {
            Dictionary <UserPhotoSize, byte[]> dictionary = new Dictionary <UserPhotoSize, byte[]>();

            try
            {
                int num = this.reader.ReadAllPreviewSizes(this.session, dictionary);
                this.tracer.TraceDebug <string, int>((long)this.GetHashCode(), "Preview photo upload handler: read preview photo of {0} with thumbprint {1:X8}.", request.TargetPrimarySmtpAddress, num);
                response.UploadedPhotos = dictionary;
                response.Thumbprint     = new int?(num);
                response.PreviewUploadHandlerProcessed = true;
            }
            catch (ObjectNotFoundException arg)
            {
                this.tracer.TraceError <ObjectNotFoundException>((long)this.GetHashCode(), "Preview photo upload handler: preview photo does NOT exist in mailbox.  Exception: {0}", arg);
                throw;
            }
            catch (StoragePermanentException arg2)
            {
                this.tracer.TraceError <StoragePermanentException>((long)this.GetHashCode(), "Preview photo upload handler: hit a permanent storage exception loading preview photo from mailbox.  Exception: {0}", arg2);
                throw;
            }
            catch (StorageTransientException arg3)
            {
                this.tracer.TraceError <StorageTransientException>((long)this.GetHashCode(), "Preview photo upload handler: hit a transient storage exception loading preview photo from mailbox.  Exception: {0}", arg3);
                throw;
            }
            return(response);
        }
        // Token: 0x06001344 RID: 4932 RVA: 0x0004F768 File Offset: 0x0004D968
        private PhotoResponse UploadPreview(PhotoRequest request, PhotoResponse response)
        {
            if (request.RawUploadedPhoto == null || request.RawUploadedPhoto.Length == 0L)
            {
                this.tracer.TraceDebug((long)this.GetHashCode(), "Preview photo upload handler: skipped because no photo was uploaded in the request.");
                return(response);
            }
            request.RawUploadedPhoto.Seek(0L, SeekOrigin.Begin);
            int num = PhotoThumbprinter.Default.Compute(request.RawUploadedPhoto);

            this.tracer.TraceDebug <string, int>((long)this.GetHashCode(), "Preview photo upload handler: uploading preview photo of {0}.  Its thumbprint is {1:X8}.", request.TargetPrimarySmtpAddress, num);
            try
            {
                this.writer.UploadPreview(num, this.CropAndScaleRawPhoto(request.RawUploadedPhoto));
                response.PreviewUploadHandlerProcessed = true;
            }
            catch (StoragePermanentException arg)
            {
                this.tracer.TraceError <StoragePermanentException>((long)this.GetHashCode(), "Preview photo upload handler: hit a permanent storage exception uploading photo to mailbox.  Exception: {0}", arg);
                throw;
            }
            catch (StorageTransientException arg2)
            {
                this.tracer.TraceError <StorageTransientException>((long)this.GetHashCode(), "Preview photo upload handler: hit a transient storage exception uploading photo to mailbox.  Exception: {0}", arg2);
                throw;
            }
            return(response);
        }
Exemplo n.º 3
0
        private int ReadThumbprintAndStampOntoResponse(PhotoRequest request, PhotoResponse response, IMailboxSession session, bool forceReloadThumbprint)
        {
            int num = this.reader.ReadThumbprint(session, request.Preview, forceReloadThumbprint);

            response.Thumbprint = new int?(num);
            return(num);
        }
Exemplo n.º 4
0
        private PhotoResponse CacheToFileSystem(PhotoRequest request, PhotoResponse response)
        {
            PhotoResponse result;

            using (new StopwatchPerformanceTracker("CachingHandlerCachePhoto", request.PerformanceLogger))
            {
                using (new CpuPerformanceTracker("CachingHandlerCachePhoto", request.PerformanceLogger))
                {
                    if (!response.OutputPhotoStream.CanSeek || !response.OutputPhotoStream.CanRead)
                    {
                        this.tracer.TraceError((long)this.GetHashCode(), "CACHING HANDLER: skipped because photo stream is unreadable and/or not seekable.");
                        result = response;
                    }
                    else
                    {
                        response.CachingHandlerProcessed = true;
                        request.PerformanceLogger.Log("CachingHandlerProcessed", string.Empty, 1U);
                        int num = this.ComputeAndStampThumbprintOntoResponse(response);
                        response.OutputPhotoStream.Seek(0L, SeekOrigin.Begin);
                        this.tracer.TraceDebug <string, int, long>((long)this.GetHashCode(), "CACHING HANDLER: caching photo at {0} with thumbprint {1:X8} and size {2} bytes", response.PhotoFullPathOnFileSystem, num, response.OutputPhotoStream.Length);
                        this.writer.Write(response.PhotoFullPathOnFileSystem, num, response.OutputPhotoStream);
                        response.PhotoWrittenToFileSystem = true;
                        this.tracer.TraceDebug((long)this.GetHashCode(), "CACHING HANDLER: photo has been cached successfully");
                        result = response;
                    }
                }
            }
            return(result);
        }
Exemplo n.º 5
0
        private void ClearPhotoFromFileSystem(PhotoRequest request, PhotoResponse response, FileSystemPhotoMap map, UserPhotoSize size)
        {
            int    num  = PhotoThumbprinter.Default.GenerateThumbprintForNegativeCache();
            string text = map.Map(request.TargetPrimarySmtpAddress, size);

            this.tracer.TraceDebug <string, int>((long)this.GetHashCode(), "File system photo upload handler: clearing photo at {0}.  Replacing it with NEGATIVE caching photo with thumbprint = {1:X8}", text, num);
            this.DeleteThenWritePhoto(text, num, Stream.Null);
        }
Exemplo n.º 6
0
 private PhotoResponse ServePhotoHasBeenDeleted(PhotoRequest request, PhotoResponse response)
 {
     this.tracer.TraceDebug((long)this.GetHashCode(), "MAILBOX HANDLER: photo has been deleted.");
     response.Served            = true;
     response.Status            = HttpStatusCode.NotFound;
     response.HttpExpiresHeader = UserAgentPhotoExpiresHeader.Default.ComputeExpiresHeader(DateTime.UtcNow, HttpStatusCode.NotFound, this.configuration);
     request.PerformanceLogger.Log("MailboxHandlerPhotoServed", string.Empty, 0U);
     return(response);
 }
Exemplo n.º 7
0
 // Token: 0x0600114B RID: 4427 RVA: 0x00047AF5 File Offset: 0x00045CF5
 private PhotoResponse FindTargetAndReadPhoto(PhotoRequest request, PhotoResponse response)
 {
     this.ComputeTargetADObjectIdAndStampOntoRequest(request);
     if (request.TargetAdObjectId == null)
     {
         this.tracer.TraceDebug((long)this.GetHashCode(), "AD HANDLER: cannot serve photo because target AD object ID has not been initialized.");
         return(response);
     }
     return(this.ReadPhotoOntoResponse(request, response));
 }
Exemplo n.º 8
0
        private PhotoResponse FindContactOrPersonAndServePhoto(PhotoRequest request, PhotoResponse response)
        {
            StoreObjectId storeObjectId = this.FindContactId(request);

            if (storeObjectId == null)
            {
                return(this.FindPersonAndServePhoto(request, response));
            }
            return(this.ReadPhotoOffOfContactAndServe(storeObjectId, request, response));
        }
Exemplo n.º 9
0
 private PhotoResponse ServePhotoNotModified(PhotoRequest request, PhotoResponse response)
 {
     this.tracer.TraceDebug <string>((long)this.GetHashCode(), "MAILBOX HANDLER: NOT MODIFIED.  Requestor already has photo cached.  ETag: {0}", request.ETag);
     response.Served            = true;
     response.Status            = HttpStatusCode.NotModified;
     response.HttpExpiresHeader = UserAgentPhotoExpiresHeader.Default.ComputeExpiresHeader(DateTime.UtcNow, HttpStatusCode.NotModified, this.configuration);
     request.PerformanceLogger.Log("MailboxHandlerPhotoAvailable", string.Empty, 1U);
     request.PerformanceLogger.Log("MailboxHandlerPhotoServed", string.Empty, 1U);
     return(response);
 }
Exemplo n.º 10
0
        // Token: 0x06001149 RID: 4425 RVA: 0x000478C4 File Offset: 0x00045AC4
        public PhotoResponse Retrieve(PhotoRequest request, PhotoResponse response)
        {
            PhotoResponse result;

            using (new StopwatchPerformanceTracker("ADHandlerTotal", request.PerformanceLogger))
            {
                using (new ADPerformanceTracker("ADHandlerTotal", request.PerformanceLogger))
                {
                    if (request.ShouldSkipHandlers(PhotoHandlers.ActiveDirectory))
                    {
                        this.tracer.TraceDebug((long)this.GetHashCode(), "AD HANDLER: skipped by request.");
                        result = response;
                    }
                    else if (response.Served)
                    {
                        this.tracer.TraceDebug((long)this.GetHashCode(), "AD HANDLER: skipped because photo has already been served by an upstream handler.");
                        result = response;
                    }
                    else
                    {
                        response.ADHandlerProcessed = true;
                        request.PerformanceLogger.Log("ADHandlerProcessed", string.Empty, 1U);
                        try
                        {
                            result = this.FindTargetAndReadPhoto(request, response);
                        }
                        catch (ADNoSuchObjectException arg)
                        {
                            this.tracer.TraceDebug <ADNoSuchObjectException>((long)this.GetHashCode(), "AD HANDLER: no photo.  Exception: {0}", arg);
                            request.PerformanceLogger.Log("ADHandlerPhotoAvailable", string.Empty, 0U);
                            result = response;
                        }
                        catch (TransientException arg2)
                        {
                            this.tracer.TraceError <TransientException>((long)this.GetHashCode(), "AD HANDLER: transient exception at reading photo.  Exception: {0}", arg2);
                            request.PerformanceLogger.Log("ADHandlerError", string.Empty, 1U);
                            throw;
                        }
                        catch (ADOperationException arg3)
                        {
                            this.tracer.TraceError <ADOperationException>((long)this.GetHashCode(), "AD HANDLER: AD exception at reading photo.  Exception: {0}", arg3);
                            request.PerformanceLogger.Log("ADHandlerError", string.Empty, 1U);
                            throw;
                        }
                        catch (IOException arg4)
                        {
                            this.tracer.TraceError <IOException>((long)this.GetHashCode(), "AD HANDLER: I/O exception at reading photo.  Exception: {0}", arg4);
                            request.PerformanceLogger.Log("ADHandlerError", string.Empty, 1U);
                            throw;
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 11
0
        private PhotoResponse FindPersonAndServePhoto(PhotoRequest request, PhotoResponse response)
        {
            Person person = this.FindPerson(request);

            if (person == null)
            {
                this.tracer.TraceDebug((long)this.GetHashCode(), "PRIVATE HANDLER: person could not be found.");
                return(this.ServePhotoNotFound(response));
            }
            return(this.ReadPhotoOffOfPersonAndServe(person, request, response));
        }
 private PhotoResponse ServePhotoNotModified(PhotoRequest request, PhotoResponse response)
 {
     this.tracer.TraceDebug <string>((long)this.GetHashCode(), "FILE SYSTEM HANDLER: NOT MODIFIED.  Requestor already has photo cached.  ETag: {0}", request.ETag);
     response.ServerCacheHit          = true;
     response.Served                  = true;
     response.Status                  = HttpStatusCode.NotModified;
     response.IsPhotoFileOnFileSystem = true;
     request.PerformanceLogger.Log("FileSystemHandlerPhotoAvailable", string.Empty, 1U);
     request.PerformanceLogger.Log("FileSystemHandlerPhotoServed", string.Empty, 1U);
     return(response);
 }
Exemplo n.º 13
0
        private PhotoResponse SavePhotosToFileSystem(PhotoRequest request, PhotoResponse response)
        {
            response.FileSystemUploadHandlerProcessed = true;
            this.tracer.TraceDebug <string>((long)this.GetHashCode(), "File system photo upload handler: saving photos of {0} to file system.", request.TargetPrimarySmtpAddress);
            FileSystemPhotoMap map = new FileSystemPhotoMap(this.photosRootDirectoryFullPath, this.upstreamTracer);

            foreach (UserPhotoSize size in this.sizesToCacheOnFileSystem)
            {
                this.SavePhotoToFileSystem(request, response, map, size);
            }
            return(response);
        }
Exemplo n.º 14
0
        public PhotoResponse Retrieve(PhotoRequest request, PhotoResponse response)
        {
            ArgumentValidator.ThrowIfNull("request", request);
            ArgumentValidator.ThrowIfNull("response", response);
            PhotoResponse result;

            using (new StopwatchPerformanceTracker("PrivateHandlerTotal", request.PerformanceLogger))
            {
                using (new StorePerformanceTracker("PrivateHandlerTotal", request.PerformanceLogger))
                {
                    if (request.ShouldSkipHandlers(PhotoHandlers.Private))
                    {
                        this.tracer.TraceDebug((long)this.GetHashCode(), "PRIVATE HANDLER: skipped by request.");
                        result = response;
                    }
                    else if (response.Served)
                    {
                        this.tracer.TraceDebug((long)this.GetHashCode(), "PRIVATE HANDLER: skipped because photo has already been served by an upstream handler.");
                        result = response;
                    }
                    else if (request.RequestorMailboxSession == null)
                    {
                        this.tracer.TraceDebug((long)this.GetHashCode(), "PRIVATE HANDLER: skipped because a session to the requestor's mailbox has NOT been initialized.");
                        result = response;
                    }
                    else
                    {
                        response.PrivateHandlerProcessed = true;
                        request.PerformanceLogger.Log("PrivateHandlerProcessed", string.Empty, 1U);
                        try
                        {
                            result = this.FindContactOrPersonAndServePhoto(request, response);
                        }
                        catch (ObjectNotFoundException arg)
                        {
                            this.tracer.TraceDebug <ObjectNotFoundException>((long)this.GetHashCode(), "PRIVATE HANDLER: photo not found.  Exception: {0}", arg);
                            result = response;
                        }
                        catch (StorageTransientException arg2)
                        {
                            this.tracer.TraceError <StorageTransientException>((long)this.GetHashCode(), "PRIVATE HANDLER: transient exception at reading photo.  Exception: {0}", arg2);
                            throw;
                        }
                        catch (StoragePermanentException arg3)
                        {
                            this.tracer.TraceError <StoragePermanentException>((long)this.GetHashCode(), "PRIVATE HANDLER: permanent exception at reading photo.  Exception: {0}", arg3);
                            throw;
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 15
0
 private PhotoResponse ServePhotoWithRedirect(PhotoRequest request, PhotoResponse response, string photoUrl, StoreObjectId photoSourceContactId, string photoSourceNetworkId)
 {
     this.tracer.TraceDebug <string, StoreObjectId, string>((long)this.GetHashCode(), "PRIVATE HANDLER: serving photo at '{0}';  found in contact with ID: '{1}';  source network: '{2}'", photoUrl, photoSourceContactId, photoSourceNetworkId);
     response.Served            = true;
     response.Status            = HttpStatusCode.Found;
     response.PhotoUrl          = photoUrl;
     response.HttpExpiresHeader = UserAgentPhotoExpiresHeader.Default.ComputeExpiresHeader(DateTime.UtcNow, HttpStatusCode.Found, this.configuration);
     response.Thumbprint        = null;
     this.TraceInformationAboutContact(photoSourceContactId, request);
     request.PerformanceLogger.Log("PrivateHandlerServedRedirect", string.Empty, 1U);
     return(response);
 }
Exemplo n.º 16
0
        private int ComputeAndStampThumbprintOntoResponse(PhotoResponse response)
        {
            if (response.Thumbprint != null)
            {
                this.tracer.TraceDebug((long)this.GetHashCode(), "CACHING HANDLER: thumbprint has already been computed by upstream handler.");
                return(response.Thumbprint.Value);
            }
            this.tracer.TraceDebug((long)this.GetHashCode(), "CACHING HANDLER: thumbprint has NOT been computed by upstream handler.  Computing now.");
            response.OutputPhotoStream.Seek(0L, SeekOrigin.Begin);
            int num = PhotoThumbprinter.Default.Compute(response.OutputPhotoStream);

            response.Thumbprint = new int?(num);
            return(num);
        }
Exemplo n.º 17
0
 // Token: 0x06001174 RID: 4468 RVA: 0x00048AC4 File Offset: 0x00046CC4
 public PhotoResponse Retrieve(PhotoRequest request, PhotoResponse response)
 {
     if (request.Trace)
     {
         this.tracer.TraceDebug((long)this.GetHashCode(), "Diagnostics photo handler: skipped because request is already being traced.");
         return(response);
     }
     if (this.ShouldTraceRequest(response))
     {
         request.Trace = true;
         this.tracer.TraceDebug((long)this.GetHashCode(), "Diagnostics photo handler: enabled tracing on this request.");
     }
     return(response);
 }
Exemplo n.º 18
0
 private PhotoResponse SavePhotoToAD(PhotoRequest request, PhotoResponse response)
 {
     byte[] photoToSaveToAD = this.GetPhotoToSaveToAD(response.UploadedPhotos);
     if (photoToSaveToAD == null || photoToSaveToAD.Length == 0)
     {
         this.tracer.TraceDebug((long)this.GetHashCode(), "AD photo upload handler: skipped because photo to save to AD is not available.");
         return(response);
     }
     response.ADUploadHandlerProcessed = true;
     using (MemoryStream memoryStream = new MemoryStream(photoToSaveToAD))
     {
         this.writer.Write(request.UploadTo, memoryStream);
     }
     return(response);
 }
        // Token: 0x060011DE RID: 4574 RVA: 0x0004B13C File Offset: 0x0004933C
        public PhotoResponse Retrieve(PhotoRequest request, PhotoResponse response)
        {
            PhotoResponse result;

            try
            {
                result = this.localServerPipeline.Retrieve(request, response);
            }
            catch (WrongServerException)
            {
                this.tracer.TraceDebug((long)this.GetHashCode(), "LOCAL SERVER WITH FALLBACK TO OTHER SERVER PIPELINE: target mailbox is NOT on this server.  Falling back to other server.");
                result = this.FallbackToOtherServer(request, response);
            }
            return(result);
        }
 public PhotoResponse Retrieve(PhotoRequest request, PhotoResponse response)
 {
     ArgumentValidator.ThrowIfNull("request", request);
     ArgumentValidator.ThrowIfNull("response", response);
     if (response.Served)
     {
         this.tracer.TraceDebug((long)this.GetHashCode(), "TARGET NOT FOUND HANDLER: skipped because photo has already been served by an upstream handler.");
         return(response);
     }
     this.tracer.TraceDebug((long)this.GetHashCode(), "TARGET NOT FOUND HANDLER: responding request with HTTP 404 Not Found.");
     response.TargetNotFoundHandlerProcessed = true;
     response.Served            = true;
     response.Status            = HttpStatusCode.NotFound;
     response.HttpExpiresHeader = UserAgentPhotoExpiresHeader.Default.ComputeExpiresHeader(DateTime.UtcNow, HttpStatusCode.NotFound, this.configuration);
     return(response);
 }
        private int ReadThumbprintAndStampOntoResponse(PhotoRequest request, PhotoResponse response, string photoFullPath)
        {
            this.tracer.TraceDebug <string, string, UserPhotoSize>((long)this.GetHashCode(), "FILE SYSTEM HANDLER: reading thumbprint of photo file {0} for ({1}, {2})", photoFullPath, request.TargetSmtpAddress, request.Size);
            int result;

            using (new StopwatchPerformanceTracker("FileSystemHandlerReadThumbprint", request.PerformanceLogger))
            {
                using (new CpuPerformanceTracker("FileSystemHandlerReadThumbprint", request.PerformanceLogger))
                {
                    int num = this.reader.ReadThumbprint(photoFullPath);
                    response.Thumbprint = new int?(num);
                    result = num;
                }
            }
            return(result);
        }
Exemplo n.º 22
0
        private void SavePhotoToFileSystem(PhotoRequest request, PhotoResponse response, FileSystemPhotoMap map, UserPhotoSize size)
        {
            byte[] uploadedPhotoOfSize = this.GetUploadedPhotoOfSize(response.UploadedPhotos, size);
            if (uploadedPhotoOfSize == null || uploadedPhotoOfSize.Length == 0)
            {
                this.tracer.TraceError <UserPhotoSize>((long)this.GetHashCode(), "File system photo upload handler: photo of size {0} NOT available and will NOT be saved to file system.", size);
                return;
            }
            string text = map.Map(request.TargetPrimarySmtpAddress, size);

            using (MemoryStream memoryStream = new MemoryStream(uploadedPhotoOfSize))
            {
                this.tracer.TraceDebug <string>((long)this.GetHashCode(), "File system photo upload handler: writing photo at {0}", text);
                this.DeleteThenWritePhoto(text, response.Thumbprint.Value, memoryStream);
            }
        }
Exemplo n.º 23
0
        private void ComputeAndStampPhotoFullPathOntoResponse(PhotoRequest request, PhotoResponse response)
        {
            if (!string.IsNullOrEmpty(response.PhotoFullPathOnFileSystem))
            {
                return;
            }
            string smtpAddressForCacheFilename = this.GetSmtpAddressForCacheFilename(request);

            if (string.IsNullOrEmpty(smtpAddressForCacheFilename))
            {
                this.tracer.TraceDebug((long)this.GetHashCode(), "CACHING HANDLER: cannot compute SMTP address for cache filename.");
                return;
            }
            response.PhotoFullPathOnFileSystem = new FileSystemPhotoMap(this.photosRootDirectoryFullPath, this.tracer).Map(smtpAddressForCacheFilename, request.Size);
            this.tracer.TraceDebug <string>((long)this.GetHashCode(), "CACHING HANDLER: computed photo full path: {0}", response.PhotoFullPathOnFileSystem);
        }
Exemplo n.º 24
0
        public PhotoResponse Upload(PhotoRequest request, PhotoResponse response)
        {
            if (request.Preview)
            {
                return(response);
            }
            PhotoResponse result;

            try
            {
                switch (request.UploadCommand)
                {
                case UploadCommand.Upload:
                    result = this.SavePhotosToFileSystem(request, response);
                    break;

                case UploadCommand.Clear:
                    result = this.ClearPhotosFromFileSystem(request, response);
                    break;

                default:
                    result = response;
                    break;
                }
            }
            catch (CannotMapInvalidSmtpAddressToPhotoFileException arg)
            {
                this.tracer.TraceError <CannotMapInvalidSmtpAddressToPhotoFileException>((long)this.GetHashCode(), "File system photo upload handler: invalid SMTP address cannot be mapped to file system.  Exception: {0}", arg);
                throw;
            }
            catch (IOException arg2)
            {
                this.tracer.TraceError <string, IOException>((long)this.GetHashCode(), "File system photo upload handler: failed to write photo for {0}.  Exception: {1}", request.TargetPrimarySmtpAddress, arg2);
                result = response;
            }
            catch (UnauthorizedAccessException arg3)
            {
                this.tracer.TraceError <string, UnauthorizedAccessException>((long)this.GetHashCode(), "File system photo upload handler: authorization failure writing photo for {0}.  Exception: {1}", request.TargetPrimarySmtpAddress, arg3);
                result = response;
            }
            catch (Win32Exception arg4)
            {
                this.tracer.TraceDebug <string, Win32Exception>((long)this.GetHashCode(), "File system photo upload handler: Win32 exception writing photo for {0}.  Exception: {1}", request.TargetPrimarySmtpAddress, arg4);
                result = response;
            }
            return(result);
        }
Exemplo n.º 25
0
        // Token: 0x060011AB RID: 4523 RVA: 0x0004A628 File Offset: 0x00048828
        private PhotoResponse ProcessResponseFromRemoteServer(PhotoRequest request, PhotoResponse response, HttpWebResponse httpResponse)
        {
            this.WriteTracesCollectedByRemoteServerOntoLocalTracer(httpResponse);
            HttpStatusCode statusCode = httpResponse.StatusCode;

            if (statusCode <= HttpStatusCode.NotModified)
            {
                if (statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.NotModified)
                {
                    goto IL_78;
                }
            }
            else if (statusCode != HttpStatusCode.Unauthorized && statusCode == HttpStatusCode.NotFound)
            {
                goto IL_78;
            }
            this.tracer.TraceError <HttpStatusCode, string>((long)this.GetHashCode(), "HTTP HANDLER: request to remote service FAILED.  Returning HTTP {0}: {1}", httpResponse.StatusCode, httpResponse.StatusDescription);
            response.Status = httpResponse.StatusCode;
            return(response);

IL_78:
            using (new StopwatchPerformanceTracker("HttpHandlerGetAndReadResponseStream", request.PerformanceLogger))
            {
                using (Stream responseStream = httpResponse.GetResponseStream())
                {
                    string text  = httpResponse.Headers[HttpResponseHeader.ETag];
                    string text2 = httpResponse.Headers[HttpResponseHeader.Expires];
                    this.tracer.TraceDebug((long)this.GetHashCode(), "HTTP HANDLER: request to remote service was SUCCESSFUL.  HTTP status: {0};  ETag: {1};  Content-Length: {2};  Content-Type: {3};  Expires: {4}", new object[]
                    {
                        httpResponse.StatusCode,
                        text,
                        httpResponse.ContentLength,
                        httpResponse.ContentType,
                        text2
                    });
                    responseStream.CopyTo(response.OutputPhotoStream);
                    response.Served            = true;
                    response.ContentLength     = httpResponse.ContentLength;
                    response.ContentType       = httpResponse.ContentType;
                    response.Status            = httpResponse.StatusCode;
                    response.ETag              = text;
                    response.HttpExpiresHeader = text2;
                }
            }
            return(response);
        }
Exemplo n.º 26
0
        public PhotoResponse Retrieve(PhotoRequest request, PhotoResponse response)
        {
            ArgumentValidator.ThrowIfNull("request", request);
            ArgumentValidator.ThrowIfNull("response", response);
            if (!response.Served)
            {
                return(response);
            }
            response.OrganizationalToPrivateHandlerTransitionProcessed = true;
            HttpStatusCode status = response.Status;

            if (status <= HttpStatusCode.NotModified)
            {
                if (status != HttpStatusCode.OK)
                {
                    switch (status)
                    {
                    case HttpStatusCode.Found:
                    case HttpStatusCode.NotModified:
                        break;

                    case HttpStatusCode.SeeOther:
                        goto IL_6C;

                    default:
                        goto IL_6C;
                    }
                }
                return(response);
            }
            if (status != HttpStatusCode.NotFound && status != HttpStatusCode.InternalServerError)
            {
            }
IL_6C:
            this.tracer.TraceDebug <HttpStatusCode>((long)this.GetHashCode(), "ORGANIZATIONAL to PRIVATE HANDLER TRANSITION: resetting response.  Original status: {0}", response.Status);
            response.Served            = false;
            response.Status            = HttpStatusCode.NotFound;
            response.ContentLength     = -1L;
            response.ContentType       = null;
            response.Thumbprint        = null;
            response.HttpExpiresHeader = string.Empty;
            response.PhotoUrl          = string.Empty;
            response.ServerCacheHit    = false;
            return(response);
        }
Exemplo n.º 27
0
 private PhotoResponse NegativeCacheToFileSystem(PhotoRequest request, PhotoResponse response)
 {
     using (new StopwatchPerformanceTracker("CachingHandlerCacheNegativePhoto", request.PerformanceLogger))
     {
         using (new CpuPerformanceTracker("CachingHandlerCacheNegativePhoto", request.PerformanceLogger))
         {
             response.CachingHandlerProcessed = true;
             request.PerformanceLogger.Log("CachingHandlerProcessed", string.Empty, 1U);
             int num = PhotoThumbprinter.Default.GenerateThumbprintForNegativeCache();
             this.tracer.TraceDebug <string, int>((long)this.GetHashCode(), "CACHING HANDLER: caching NEGATIVE photo at {0} with thumbprint = {1:X8}", response.PhotoFullPathOnFileSystem, num);
             this.writer.Write(response.PhotoFullPathOnFileSystem, num, Stream.Null);
             response.PhotoWrittenToFileSystem = true;
             this.tracer.TraceDebug((long)this.GetHashCode(), "CACHING HANDLER: wrote NEGATIVE cache photo file.");
             response.Thumbprint = new int?(num);
         }
     }
     return(response);
 }
        // Token: 0x06001342 RID: 4930 RVA: 0x0004F714 File Offset: 0x0004D914
        public PhotoResponse Upload(PhotoRequest request, PhotoResponse response)
        {
            switch (request.UploadCommand)
            {
            case UploadCommand.Upload:
                if (request.Preview)
                {
                    return(this.UploadPreview(request, response));
                }
                return(this.LoadPreview(request, response));

            case UploadCommand.Clear:
                return(this.ClearPreview(request, response));

            default:
                return(response);
            }
        }
Exemplo n.º 29
0
 // Token: 0x0600114D RID: 4429 RVA: 0x00047BA8 File Offset: 0x00045DA8
 private PhotoResponse ReadPhotoOntoResponse(PhotoRequest request, PhotoResponse response)
 {
     using (new StopwatchPerformanceTracker("ADHandlerReadPhoto", request.PerformanceLogger))
     {
         using (new ADPerformanceTracker("ADHandlerReadPhoto", request.PerformanceLogger))
         {
             PhotoMetadata photoMetadata = this.reader.Read(this.recipientSession, request.TargetAdObjectId, response.OutputPhotoStream);
             response.Served        = true;
             response.Status        = HttpStatusCode.OK;
             response.ContentLength = photoMetadata.Length;
             response.ContentType   = photoMetadata.ContentType;
             response.Thumbprint    = null;
             request.PerformanceLogger.Log("ADHandlerPhotoAvailable", string.Empty, 1U);
             request.PerformanceLogger.Log("ADHandlerPhotoServed", string.Empty, 1U);
         }
     }
     return(response);
 }
        // Token: 0x06001208 RID: 4616 RVA: 0x0004C380 File Offset: 0x0004A580
        public PhotoResponse Upload(PhotoRequest request, PhotoResponse response)
        {
            if (request.Preview)
            {
                return(response);
            }
            PhotoResponse result;

            try
            {
                switch (request.UploadCommand)
                {
                case UploadCommand.Upload:
                    result = this.SavePhotoToMailbox(request, response);
                    break;

                case UploadCommand.Clear:
                    result = this.ClearPhotoFromMailbox(request, response);
                    break;

                default:
                    result = response;
                    break;
                }
            }
            catch (ObjectNotFoundException arg)
            {
                this.tracer.TraceDebug <ObjectNotFoundException>((long)this.GetHashCode(), "Mailbox photo upload handler: photo not found.  Exception: {0}", arg);
                throw;
            }
            catch (StorageTransientException arg2)
            {
                this.tracer.TraceError <StorageTransientException>((long)this.GetHashCode(), "Mailbox photo upload handler: transient exception saving or clearing photo.  Exception: {0}", arg2);
                throw;
            }
            catch (StoragePermanentException arg3)
            {
                this.tracer.TraceError <StoragePermanentException>((long)this.GetHashCode(), "Mailbox photo upload handler: permanent exception saving or clearing photo.  Exception: {0}", arg3);
                throw;
            }
            return(result);
        }