private HttpWebRequest GetProxyRequest(int contentLength) { NetworkServiceImpersonator.Initialize(); if (NetworkServiceImpersonator.Exception != null) { ExTraceGlobals.ProxyCallTracer.TraceError <LocalizedException>(0L, "Unable to impersonate network service to call EWS due exception {0}", NetworkServiceImpersonator.Exception); throw new AsyncExceptionWrapper(NetworkServiceImpersonator.Exception); } HttpWebRequest httpWebRequest = ProxyUtilities.CreateHttpWebRequestForProxying(base.OwaContext, this.proxyRequestUrl); httpWebRequest.Method = "POST"; httpWebRequest.ContentType = this.HttpContext.Request.ContentType; httpWebRequest.ContentLength = (long)contentLength; httpWebRequest.UserAgent = "OwaProxy"; httpWebRequest.PreAuthenticate = true; return(httpWebRequest); }
internal void BeginSend(OwaContext owaContext, AsyncCallback callback, object extraData) { ExTraceGlobals.ProxyCallTracer.TraceDebug((long)this.GetHashCode(), "ProxyPingRequest.BeginSend"); Uri uri = new UriBuilder(owaContext.SecondCasUri.Uri) { Path = OwaUrl.ProxyPing.GetExplicitUrl(owaContext) }.Uri; HttpWebRequest httpWebRequest = ProxyUtilities.CreateHttpWebRequestForProxying(owaContext, uri); httpWebRequest.Method = "GET"; httpWebRequest.UserAgent = "OwaProxy"; this.request = httpWebRequest; this.asyncResult = new OwaAsyncResult(callback, extraData); this.requestTimedOut = false; IAsyncResult asyncResult = ProxyUtilities.BeginGetResponse(this.request, new AsyncCallback(this.GetResponseCallback), this, out this.requestClock); this.timeoutWaitHandle = ThreadPool.RegisterWaitForSingleObject(asyncResult.AsyncWaitHandle, new WaitOrTimerCallback(this.RequestTimeoutCallback), asyncResult, (long)owaContext.HttpContext.Server.ScriptTimeout * 1000L, true); }
// Token: 0x06001262 RID: 4706 RVA: 0x0006FFC8 File Offset: 0x0006E1C8 internal static HttpWebRequest GetProxyRequestInstance(HttpRequest originalRequest, OwaContext owaContext, Uri requestUri) { string name = "X-LogonType"; string value = "Public"; HttpWebRequest httpWebRequest = ProxyUtilities.CreateHttpWebRequestForProxying(owaContext, requestUri); for (int i = 0; i < originalRequest.Headers.Count; i++) { string text = originalRequest.Headers.Keys[i]; if (ProxyUtilities.ShouldCopyProxyRequestHeader(text)) { httpWebRequest.Headers[text] = originalRequest.Headers[text]; } } httpWebRequest.UserAgent = originalRequest.UserAgent; string text2 = originalRequest.Headers["referer"]; if (text2 != null) { httpWebRequest.Referer = text2; } text2 = originalRequest.Headers["accept"]; if (text2 != null) { httpWebRequest.Accept = text2; } text2 = originalRequest.Headers["transfer-encoding"]; if (text2 != null) { httpWebRequest.TransferEncoding = text2; } httpWebRequest.ContentLength = (long)originalRequest.ContentLength; httpWebRequest.ContentType = originalRequest.ContentType; httpWebRequest.UserAgent = originalRequest.UserAgent; if (httpWebRequest.Headers[name] == null && owaContext.SessionContext != null && owaContext.SessionContext.IsPublicRequest(originalRequest)) { httpWebRequest.Headers.Add(name, value); } httpWebRequest.Headers["X-OWA-ProxyUri"] = owaContext.LocalHostName; httpWebRequest.Headers["X-OWA-ProxyVersion"] = Globals.ApplicationVersion; if (Globals.OwaVDirType == OWAVDirType.OWA) { httpWebRequest.Headers["X-OWA-ProxySid"] = owaContext.LogonIdentity.UserSid.ToString(); } httpWebRequest.Headers["X-OWA-ProxyCanary"] = Utilities.GetCurrentCanary(owaContext.SessionContext); if (owaContext.RequestType == OwaRequestType.WebPart) { httpWebRequest.Headers["X-OWA-ProxyWebPart"] = "1"; } if (owaContext.TryGetUserContext() != null && owaContext.UserContext.ProxyUserContextCookie != null) { ExTraceGlobals.ProxyDataTracer.TraceDebug <UserContextCookie>(0L, "Setting proxy user context cookie: {0}", owaContext.UserContext.ProxyUserContextCookie); Cookie netCookie = owaContext.UserContext.ProxyUserContextCookie.NetCookie; ProxyUtilities.AddCookieToProxyRequest(httpWebRequest, netCookie, requestUri.Host); } else { ExTraceGlobals.ProxyDataTracer.TraceDebug(0L, "No user context cookie used for the proxy request"); } foreach (string name2 in ProxyUtilities.ProxyAllowedCookies) { if (owaContext.HttpContext.Request.Cookies[name2] != null) { Cookie cookie = new Cookie(name2, owaContext.HttpContext.Request.Cookies[name2].Value); ProxyUtilities.AddCookieToProxyRequest(httpWebRequest, cookie, requestUri.Host); } } return(httpWebRequest); }