Imported Upstream version 5.14.0.78

Former-commit-id: 3494343bcc9ddb42b36b82dd9ae7b69e85e0229f
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-05-10 08:37:03 +00:00
parent 74b74abd9f
commit 19234507ba
1776 changed files with 67755 additions and 31107 deletions

View File

@@ -1,162 +0,0 @@
//
// System.Net.FtpAsyncResult.cs
//
// Authors:
// Carlos Alberto Cortez (calberto.cortez@gmail.com)
//
// (c) Copyright 2006 Novell, Inc. (http://www.novell.com)
//
using System;
using System.IO;
using System.Threading;
using System.Net;
namespace System.Net
{
class FtpAsyncResult : IAsyncResult
{
FtpWebResponse response;
ManualResetEvent waitHandle;
Exception exception;
AsyncCallback callback;
Stream stream;
object state;
bool completed;
bool synch;
object locker = new object ();
public FtpAsyncResult (AsyncCallback callback, object state)
{
this.callback = callback;
this.state = state;
}
public object AsyncState {
get {
return state;
}
}
public WaitHandle AsyncWaitHandle {
get {
lock (locker) {
if (waitHandle == null)
waitHandle = new ManualResetEvent (false);
}
return waitHandle;
}
}
public bool CompletedSynchronously {
get {
return synch;
}
}
public bool IsCompleted {
get {
lock (locker) {
return completed;
}
}
}
internal bool GotException {
get {
return exception != null;
}
}
internal Exception Exception {
get {
return exception;
}
}
internal FtpWebResponse Response {
get {
return response;
}
set {
response = value;
}
}
internal Stream Stream {
get {
return stream;
}
set { stream = value; }
}
internal void WaitUntilComplete ()
{
if (IsCompleted)
return;
AsyncWaitHandle.WaitOne ();
}
internal bool WaitUntilComplete (int timeout, bool exitContext)
{
if (IsCompleted)
return true;
return AsyncWaitHandle.WaitOne (timeout, exitContext);
}
internal void SetCompleted (bool synch, Exception exc, FtpWebResponse response)
{
this.synch = synch;
this.exception = exc;
this.response = response;
lock (locker) {
completed = true;
if (waitHandle != null)
waitHandle.Set ();
}
DoCallback ();
}
internal void SetCompleted (bool synch, FtpWebResponse response)
{
SetCompleted (synch, null, response);
}
internal void SetCompleted (bool synch, Exception exc)
{
SetCompleted (synch, exc, null);
}
internal void DoCallback ()
{
if (callback != null)
try {
callback (this);
}
catch (Exception) {
}
}
// Cleanup resources
internal void Reset ()
{
exception = null;
synch = false;
response = null;
state = null;
lock (locker) {
completed = false;
if (waitHandle != null)
waitHandle.Reset ();
}
}
}
}

View File

@@ -1,252 +0,0 @@
//
// System.Net.FtpDataStream.cs
//
// Authors:
// Carlos Alberto Cortez (calberto.cortez@gmail.com)
//
// (c) Copyright 2006 Novell, Inc. (http://www.novell.com)
//
using System;
using System.IO;
using System.Net.Sockets;
using System.Runtime.Remoting.Messaging;
using System.Threading;
using System.Net;
namespace System.Net
{
class FtpDataStream : Stream, IDisposable
{
FtpWebRequest request;
Stream networkStream;
bool disposed;
bool isRead;
int totalRead;
internal FtpDataStream (FtpWebRequest request, Stream stream, bool isRead)
{
if (request == null)
throw new ArgumentNullException ("request");
this.request = request;
this.networkStream = stream;
this.isRead = isRead;
}
public override bool CanRead {
get {
return isRead;
}
}
public override bool CanWrite {
get {
return !isRead;
}
}
public override bool CanSeek {
get {
return false;
}
}
public override long Length {
get {
throw new NotSupportedException ();
}
}
public override long Position {
get {
throw new NotSupportedException ();
}
set {
throw new NotSupportedException ();
}
}
internal Stream NetworkStream {
get {
CheckDisposed ();
return networkStream;
}
}
public override void Close ()
{
Dispose (true);
}
public override void Flush ()
{
// Do nothing.
}
public override long Seek (long offset, SeekOrigin origin)
{
throw new NotSupportedException ();
}
public override void SetLength (long value)
{
throw new NotSupportedException ();
}
int ReadInternal (byte [] buffer, int offset, int size)
{
int nbytes = 0;
request.CheckIfAborted ();
try {
// Probably it would be better to have the socket here
nbytes = networkStream.Read (buffer, offset, size);
} catch (IOException) {
throw new ProtocolViolationException ("Server commited a protocol violation");
}
totalRead += nbytes;
if (nbytes == 0) {
networkStream = null;
request.CloseDataConnection ();
request.SetTransferCompleted ();
}
return nbytes;
}
public override IAsyncResult BeginRead (byte [] buffer, int offset, int size, AsyncCallback cb, object state)
{
CheckDisposed ();
if (!isRead)
throw new NotSupportedException ();
if (buffer == null)
throw new ArgumentNullException ("buffer");
if (offset < 0 || offset > buffer.Length)
throw new ArgumentOutOfRangeException ("offset");
if (size < 0 || size > buffer.Length - offset)
throw new ArgumentOutOfRangeException ("offset+size");
ReadDelegate del = ReadInternal;
return del.BeginInvoke (buffer, offset, size, cb, state);
}
public override int EndRead (IAsyncResult asyncResult)
{
if (asyncResult == null)
throw new ArgumentNullException ("asyncResult");
AsyncResult ar = asyncResult as AsyncResult;
if (ar == null)
throw new ArgumentException ("Invalid asyncResult", "asyncResult");
ReadDelegate del = ar.AsyncDelegate as ReadDelegate;
if (del == null)
throw new ArgumentException ("Invalid asyncResult", "asyncResult");
return del.EndInvoke (asyncResult);
}
public override int Read (byte [] buffer, int offset, int size)
{
request.CheckIfAborted ();
IAsyncResult ar = BeginRead (buffer, offset, size, null, null);
if (!ar.IsCompleted && !ar.AsyncWaitHandle.WaitOne (request.ReadWriteTimeout, false))
throw new WebException ("Read timed out.", WebExceptionStatus.Timeout);
return EndRead (ar);
}
delegate void WriteDelegate (byte [] buffer, int offset, int size);
void WriteInternal (byte [] buffer, int offset, int size)
{
request.CheckIfAborted ();
try {
networkStream.Write (buffer, offset, size);
} catch (IOException) {
throw new ProtocolViolationException ();
}
}
public override IAsyncResult BeginWrite (byte [] buffer, int offset, int size, AsyncCallback cb, object state)
{
CheckDisposed ();
if (isRead)
throw new NotSupportedException ();
if (buffer == null)
throw new ArgumentNullException ("buffer");
if (offset < 0 || offset > buffer.Length)
throw new ArgumentOutOfRangeException ("offset");
if (size < 0 || size > buffer.Length - offset)
throw new ArgumentOutOfRangeException ("offset+size");
WriteDelegate del = WriteInternal;
return del.BeginInvoke (buffer, offset, size, cb, state);
}
public override void EndWrite (IAsyncResult asyncResult)
{
if (asyncResult == null)
throw new ArgumentNullException ("asyncResult");
AsyncResult ar = asyncResult as AsyncResult;
if (ar == null)
throw new ArgumentException ("Invalid asyncResult.", "asyncResult");
WriteDelegate del = ar.AsyncDelegate as WriteDelegate;
if (del == null)
throw new ArgumentException ("Invalid asyncResult.", "asyncResult");
del.EndInvoke (asyncResult);
}
public override void Write (byte [] buffer, int offset, int size)
{
request.CheckIfAborted ();
IAsyncResult ar = BeginWrite (buffer, offset, size, null, null);
if (!ar.IsCompleted && !ar.AsyncWaitHandle.WaitOne (request.ReadWriteTimeout, false))
throw new WebException ("Read timed out.", WebExceptionStatus.Timeout);
EndWrite (ar);
}
~FtpDataStream ()
{
Dispose (false);
}
void IDisposable.Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
protected override void Dispose (bool disposing)
{
if (disposed)
return;
disposed = true;
if (networkStream != null) {
request.CloseDataConnection ();
request.SetTransferCompleted ();
request = null;
networkStream = null;
}
}
void CheckDisposed ()
{
if (disposed)
throw new ObjectDisposedException (GetType ().FullName);
}
delegate int ReadDelegate (byte [] buffer, int offset, int size);
}
}

View File

@@ -1,43 +0,0 @@
//
// System.Net.FtpbRequestCreator.cs
//
// Authors:
// Carlos Alberto Cortez (calberto.cortez@gmail.com)
//
// (c) Copyright 2006 Novell, Inc. (http://www.novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Net
{
class FtpRequestCreator : IWebRequestCreate
{
public WebRequest Create (Uri uri)
{
return new FtpWebRequest (uri);
}
}
}

View File

@@ -28,9 +28,9 @@
namespace System.Net
{
class FtpRequestCreator : IWebRequestCreate
class FtpWebRequestCreator : IWebRequestCreate
{
internal const string EXCEPTION_MESSAGE = "System.Net.FtpRequestCreator is not supported on the current platform.";
internal const string EXCEPTION_MESSAGE = "System.Net.FtpWebRequestCreator is not supported on the current platform.";
public WebRequest Create (Uri uri)
{
throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);

View File

@@ -1,51 +0,0 @@
// System.Net.FtpStatus.cs
//
// Authors:
// David Elkind (davide@mainsoft.com)
//
// Copyright (C) 2006 Mainsoft Corp.
// http://www.mainsoft.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Net
{
internal class FtpStatus
{
readonly FtpStatusCode statusCode;
readonly string statusDescription;
public FtpStatus (FtpStatusCode statusCode, string statusDescription) {
this.statusCode = statusCode;
this.statusDescription = statusDescription;
}
public FtpStatusCode StatusCode {
get { return statusCode; }
}
public string StatusDescription {
get { return statusDescription; }
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,184 +0,0 @@
//
// System.Net.FtpWebResponse.cs
//
// Authors:
// Carlos Alberto Cortez (calberto.cortez@gmail.com)
//
// (c) Copyright 2006 Novell, Inc. (http://www.novell.com)
//
using System;
using System.IO;
using System.Runtime.Serialization;
using System.Net;
namespace System.Net
{
public class FtpWebResponse : WebResponse
{
Stream stream;
Uri uri;
FtpStatusCode statusCode;
DateTime lastModified = DateTime.MinValue;
string bannerMessage = String.Empty;
string welcomeMessage = String.Empty;
string exitMessage = String.Empty;
string statusDescription;
string method;
//bool keepAlive;
bool disposed;
FtpWebRequest request;
internal long contentLength = -1;
internal FtpWebResponse (FtpWebRequest request, Uri uri, string method, bool keepAlive)
{
this.request = request;
this.uri = uri;
this.method = method;
//this.keepAlive = keepAlive;
}
internal FtpWebResponse (FtpWebRequest request, Uri uri, string method, FtpStatusCode statusCode, string statusDescription)
{
this.request = request;
this.uri = uri;
this.method = method;
this.statusCode = statusCode;
this.statusDescription = statusDescription;
}
internal FtpWebResponse (FtpWebRequest request, Uri uri, string method, FtpStatus status) :
this (request, uri, method, status.StatusCode, status.StatusDescription)
{
}
public override long ContentLength {
get {
return contentLength;
}
}
public override WebHeaderCollection Headers {
get {
return new WebHeaderCollection ();
}
}
public override Uri ResponseUri {
get {
return uri;
}
}
public DateTime LastModified {
get {
return lastModified;
}
internal set {
lastModified = value;
}
}
public string BannerMessage {
get {
return bannerMessage;
}
internal set {
bannerMessage = value;
}
}
public string WelcomeMessage {
get {
return welcomeMessage;
}
internal set {
welcomeMessage = value;
}
}
public string ExitMessage {
get {
return exitMessage;
}
internal set {
exitMessage = value;
}
}
public FtpStatusCode StatusCode {
get {
return statusCode;
}
internal set {
statusCode = value;
}
}
public override bool SupportsHeaders {
get {
return true;
}
}
public string StatusDescription {
get {
return statusDescription;
}
internal set {
statusDescription = value;
}
}
public override void Close ()
{
if (disposed)
return;
disposed = true;
if (stream != null) {
stream.Close ();
if (stream == Stream.Null)
request.OperationCompleted ();
}
stream = null;
}
public override Stream GetResponseStream ()
{
if (stream == null)
return Stream.Null; // After a STOR we get this
if (method != WebRequestMethods.Ftp.DownloadFile &&
method != WebRequestMethods.Ftp.ListDirectory)
CheckDisposed ();
return stream;
}
internal Stream Stream {
set {
stream = value;
}
get { return stream; }
}
internal void UpdateStatus (FtpStatus status) {
statusCode = status.StatusCode;
statusDescription = status.StatusDescription;
}
void CheckDisposed ()
{
if (disposed)
throw new ObjectDisposedException (GetType ().FullName);
}
internal bool IsFinal () {
return ((int) statusCode >= 200);
}
}
}