コード例 #1
0
            public override WebResponse GetResponse()
            {
                WebResponse response = null;

                if (this.client == null || !this.client.IsConnected)
                {
                    this.client = SshRequestCreator.GetOrCreateClient(this);
                }

                switch (this.Method)
                {
                case IOConnection.WrmDeleteFile:
                    response = SshWebResponse.GetDeleteResponse(this.client, this.RequestUri.AbsolutePath);
                    break;

                case IOConnection.WrmMoveFile:
                    var moveTo    = this.Headers[IOConnection.WrhMoveFileTo];
                    var authority = this.RequestUri.GetLeftPart(UriPartial.Authority);

                    if (moveTo?.StartsWith(authority) == true)
                    {
                        response = SshWebResponse.GetMoveResponse(this.client, this.RequestUri.AbsolutePath.TrimStart('/'), moveTo.Substring(authority.Length).TrimStart('/'));
                    }

                    break;

                case null:
                    response = SshWebResponse.GetDownloadResponse(this.client, this.RequestUri.AbsolutePath);
                    break;
                }

                return(response ?? new SshWebResponse());
            }
コード例 #2
0
            public override Stream GetRequestStream()
            {
                if (this.client == null || !this.client.IsConnected)
                {
                    this.client = SshRequestCreator.GetOrCreateClient(this);
                }

                return(this.client.OpenWrite(this.RequestUri.AbsolutePath.TrimStart('/')));
            }
コード例 #3
0
        private static void RegisterPlugin()
        {
            if (propertiesRegistered)
            {
                return;
            }

            propertiesRegistered = true;

            var creator = new SshRequestCreator();

            foreach (var protocol in protocols)
            {
                System.Net.WebRequest.RegisterPrefix(protocol, creator);
            }

            IocPropertyInfoPool.Add(new IocPropertyInfo(PropertyKeys.PrivateKey,
                                                        typeof(string), "SSH private key path", protocols));
            IocPropertyInfoPool.Add(new IocPropertyInfo(PropertyKeys.HostKey,
                                                        typeof(string), "Fingerprint of expected SSH host key", protocols));
        }