Esempio n. 1
0
 void Reset()
 {
     lock (this) {
         tunnel = null;
         ResetNtlm();
     }
 }
Esempio n. 2
0
        async Task <bool> CreateStream(WebOperation operation, bool reused, CancellationToken cancellationToken)
        {
#if MONO_WEB_DEBUG
            var requestID = ++nextRequestID;
#else
            var requestID = 0;
#endif

            try {
                var stream = new NetworkStream(socket, false);

                Debug($"WC CREATE STREAM: Cnc={ID} {requestID} {reused} socket={socket.ID}");

                if (operation.Request.Address.Scheme == Uri.UriSchemeHttps)
                {
                    if (!reused || monoTlsStream == null)
                    {
                        if (ServicePoint.UseConnect)
                        {
                            if (tunnel == null)
                            {
                                tunnel = new WebConnectionTunnel(operation.Request, ServicePoint.Address);
                            }
                            await tunnel.Initialize(stream, cancellationToken).ConfigureAwait(false);

                            if (!tunnel.Success)
                            {
                                return(false);
                            }
                        }
                        monoTlsStream = new MonoTlsStream(operation.Request, stream);
                        networkStream = await monoTlsStream.CreateStream(tunnel, cancellationToken).ConfigureAwait(false);
                    }
                    return(true);
                }

                networkStream = stream;
                return(true);
            } catch (Exception ex) {
                ex = HttpWebRequest.FlattenException(ex);
                Debug($"WC CREATE STREAM EX: Cnc={ID} {requestID} {operation.Aborted} - {ex.Message}");
                if (operation.Aborted || monoTlsStream == null)
                {
                    throw GetException(WebExceptionStatus.ConnectFailure, ex);
                }
                throw GetException(monoTlsStream.ExceptionStatus, ex);
            } finally {
                Debug($"WC CREATE STREAM DONE: Cnc={ID} {requestID}");
            }
        }
Esempio n. 3
0
        public WebRequestStream(WebConnection connection, WebOperation operation,
                                Stream stream, WebConnectionTunnel tunnel)
            : base(connection, operation, stream)
        {
            allowBuffering = operation.Request.InternalAllowBuffering;
            sendChunked    = operation.Request.SendChunked && operation.WriteBuffer == null;
            if (!sendChunked && allowBuffering && operation.WriteBuffer == null)
            {
                writeBuffer = new MemoryStream();
            }

            KeepAlive = Request.KeepAlive;
            if (tunnel?.ProxyVersion != null && tunnel?.ProxyVersion != HttpVersion.Version11)
            {
                KeepAlive = false;
            }

#if MONO_WEB_DEBUG
            ME = $"WRQ(Cnc={Connection.ID}, Op={Operation.ID})";
#endif
        }