Ejemplo n.º 1
0
		void HandleNtlmAuth (WebAsyncResult r)
		{
			WebConnectionStream wce = webResponse.GetResponseStream () as WebConnectionStream;
			if (wce != null) {
				WebConnection cnc = wce.Connection;
				cnc.PriorityRequest = this;
				bool isProxy = (proxy != null && !proxy.IsBypassed (actualUri));
				ICredentials creds = (!isProxy) ? credentials : proxy.Credentials;
				if (creds != null) {
					cnc.NtlmCredential = creds.GetCredential (requestUri, "NTLM");
					cnc.UnsafeAuthenticatedConnectionSharing = unsafe_auth_blah;
				}
			}
			r.Reset ();
			finished_reading = false;
			haveResponse = false;
			webResponse.ReadAll ();
			webResponse = null;
		}
Ejemplo n.º 2
0
		void HandleNtlmAuth (WebAsyncResult r)
		{
			WebConnectionStream wce = webResponse.GetResponseStream () as WebConnectionStream;
			if (wce != null) {
				WebConnection cnc = wce.Connection;
				cnc.PriorityRequest = this;
				bool isProxy = (proxy != null && !proxy.IsBypassed (actualUri));
				ICredentials creds = (!isProxy) ? credentials : proxy.Credentials;
				if (creds != null) {
					cnc.NtlmCredential = creds.GetCredential (requestUri, "NTLM");
					cnc.UnsafeAuthenticatedConnectionSharing = unsafe_auth_blah;
				}
			}
			r.Reset ();
			finished_reading = false;
			haveResponse = false;
			webResponse.ReadAll ();
			webResponse = null;
		}
Ejemplo n.º 3
0
		bool HandleNtlmAuth (WebAsyncResult r)
		{
			bool isProxy = webResponse.StatusCode == HttpStatusCode.ProxyAuthenticationRequired;
			if ((isProxy ? proxy_auth_state.NtlmAuthState : auth_state.NtlmAuthState) == NtlmAuthState.None)
				return false;

			WebConnectionStream wce = webResponse.GetResponseStream () as WebConnectionStream;
			if (wce != null) {
				WebConnection cnc = wce.Connection;
				cnc.PriorityRequest = this;
				ICredentials creds = !isProxy ? credentials : proxy.Credentials;
				if (creds != null) {
					cnc.NtlmCredential = creds.GetCredential (requestUri, "NTLM");
					cnc.UnsafeAuthenticatedConnectionSharing = unsafe_auth_blah;
				}
			}
			r.Reset ();
			finished_reading = false;
			haveResponse = false;
			webResponse.ReadAll ();
			webResponse = null;
			return true;
		}
Ejemplo n.º 4
0
        internal void SetResponseData(WebConnectionData data)
        {
            if (aborted)
            {
                if (data.stream != null)
                {
                    data.stream.Close();
                }
                return;
            }

            WebException wexc = null;

            try {
                webResponse  = new HttpWebResponse(actualUri, method, data, cookieContainer);
                haveResponse = true;
            } catch (Exception e) {
                wexc = new WebException(e.Message, e, WebExceptionStatus.ProtocolError, null);
                if (data.stream != null)
                {
                    data.stream.Close();
                }
            }

            if (wexc == null && (method == "POST" || method == "PUT"))
            {
                lock (locker) {
                    CheckSendError(data);
                    if (saved_exc != null)
                    {
                        wexc = (WebException)saved_exc;
                    }
                }
            }

            WebAsyncResult r = asyncRead;

            if (r != null)
            {
                if (wexc != null)
                {
                    r.SetCompleted(false, wexc);
                    r.DoCallback();
                    return;
                }

                bool redirected;
                try {
                    redirected = CheckFinalStatus(r);
                    if (!redirected)
                    {
                        r.SetCompleted(false, webResponse);
                        r.DoCallback();
                    }
                    else
                    {
                        if (webResponse != null)
                        {
                            webResponse.Close();
                            webResponse = null;
                        }
                        haveResponse = false;
                        webResponse  = null;
                        r.Reset();
                        servicePoint = GetServicePoint();
                        abortHandler = servicePoint.SendRequest(this, connectionGroup);
                    }
                } catch (WebException wexc2) {
                    r.SetCompleted(false, wexc2);
                    r.DoCallback();
                    return;
                } catch (Exception ex) {
                    wexc = new WebException(ex.Message, ex, WebExceptionStatus.ProtocolError, null);
                    r.SetCompleted(false, wexc);
                    r.DoCallback();
                    return;
                }
            }
        }