Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -1,362 +0,0 @@
//
// System.Net.Cookie.cs
//
// Authors:
// Lawrence Pit (loz@cable.a2000.nl)
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
// Daniel Nauck (dna(at)mono-project(dot)de)
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2004,2009 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.
//
using System;
using System.Text;
using System.Globalization;
using System.Collections;
namespace System.Net {
// Supported cookie formats are:
// Netscape: http://home.netscape.com/newsref/std/cookie_spec.html
// RFC 2109: http://www.ietf.org/rfc/rfc2109.txt
// RFC 2965: http://www.ietf.org/rfc/rfc2965.txt
[Serializable]
public sealed class Cookie
{
string comment;
Uri commentUri;
bool discard;
string domain;
DateTime expires;
bool httpOnly;
string name;
string path;
string port;
int [] ports;
bool secure;
DateTime timestamp;
string val;
int version;
static char [] reservedCharsName = new char [] {' ', '=', ';', ',', '\n', '\r', '\t'};
static char [] portSeparators = new char [] {'"', ','};
static string tspecials = "()<>@,;:\\\"/[]?={} \t"; // from RFC 2965, 2068
public Cookie ()
{
expires = DateTime.MinValue;
timestamp = DateTime.Now;
domain = String.Empty;
name = String.Empty;
val = String.Empty;
comment = String.Empty;
port = String.Empty;
}
public Cookie (string name, string value)
: this ()
{
Name = name;
Value = value;
}
public Cookie (string name, string value, string path)
: this (name, value)
{
Path = path;
}
public Cookie (string name, string value, string path, string domain)
: this (name, value, path)
{
Domain = domain;
}
public string Comment {
get { return comment; }
set { comment = value == null ? String.Empty : value; }
}
public Uri CommentUri {
get { return commentUri; }
set { commentUri = value; }
}
public bool Discard {
get { return discard; }
set { discard = value; }
}
public string Domain {
get { return domain; }
set {
if (String.IsNullOrEmpty (value)) {
domain = String.Empty;
HasDomain = false;
} else {
domain = value;
IPAddress test;
if (IPAddress.TryParse (value, out test))
HasDomain = false;
else
HasDomain = true;
}
}
}
/*
* Set this to false to disable same-origin checks.
*
* This should be done whenever the cookie does not actually
* contain a domain and we fallback to the Uri's hostname.
*
*/
internal bool HasDomain {
get; set;
}
public bool Expired {
get {
return expires <= DateTime.Now &&
expires != DateTime.MinValue;
}
set {
if (value)
expires = DateTime.Now;
}
}
public DateTime Expires {
get { return expires; }
set { expires = value; }
}
public bool HttpOnly {
get { return httpOnly; }
set { httpOnly = value; }
}
public string Name {
get { return name; }
set {
if (String.IsNullOrEmpty (value))
throw new CookieException ("Name cannot be empty");
if (value [0] == '$' || value.IndexOfAny (reservedCharsName) != -1) {
// see CookieTest, according to MS implementation
// the name value changes even though it's incorrect
name = String.Empty;
throw new CookieException ("Name contains invalid characters");
}
name = value;
}
}
public string Path {
get { return (path == null) ? String.Empty : path; }
set { path = (value == null) ? String.Empty : value; }
}
public string Port {
get { return port; }
set {
if (String.IsNullOrEmpty (value)) {
port = String.Empty;
return;
}
if (value [0] != '"' || value [value.Length - 1] != '"') {
throw new CookieException("The 'Port'='" + value + "' part of the cookie is invalid. Port must be enclosed by double quotes.");
}
port = value;
string [] values = port.Split (portSeparators);
ports = new int[values.Length];
for (int i = 0; i < ports.Length; i++) {
ports [i] = Int32.MinValue;
if (values [i].Length == 0)
continue;
try {
ports [i] = Int32.Parse (values [i]);
} catch (Exception e) {
throw new CookieException("The 'Port'='" + value + "' part of the cookie is invalid. Invalid value: " + values [i], e);
}
}
Version = 1;
}
}
internal int [] Ports {
get { return ports; }
set { ports = value; }
}
public bool Secure {
get { return secure; }
set { secure = value; }
}
public DateTime TimeStamp {
get { return timestamp; }
}
public string Value {
get { return val; }
set {
if (value == null) {
val = String.Empty;
return;
}
// LAMESPEC: According to .Net specs the Value property should not accept
// the semicolon and comma characters, yet it does. For now we'll follow
// the behaviour of MS.Net instead of the specs.
/*
if (value.IndexOfAny(reservedCharsValue) != -1)
throw new CookieException("Invalid value. Value cannot contain semicolon or comma characters.");
*/
val = value;
}
}
public int Version {
get { return version; }
set {
if ((value < 0) || (value > 10))
version = 0;
else
version = value;
}
}
public override bool Equals (Object comparand)
{
System.Net.Cookie c = comparand as System.Net.Cookie;
return c != null &&
String.Compare (this.name, c.name, true, CultureInfo.InvariantCulture) == 0 &&
String.Compare (this.val, c.val, false, CultureInfo.InvariantCulture) == 0 &&
String.Compare (this.Path, c.Path, false, CultureInfo.InvariantCulture) == 0 &&
String.Compare (this.domain, c.domain, true, CultureInfo.InvariantCulture) == 0 &&
this.version == c.version;
}
public override int GetHashCode ()
{
return hash(CaseInsensitiveHashCodeProvider.DefaultInvariant.GetHashCode(name),
val.GetHashCode (),
Path.GetHashCode (),
CaseInsensitiveHashCodeProvider.DefaultInvariant.GetHashCode (domain),
version);
}
private static int hash (int i, int j, int k, int l, int m)
{
return i ^ (j << 13 | j >> 19) ^ (k << 26 | k >> 6) ^ (l << 7 | l >> 25) ^ (m << 20 | m >> 12);
}
// returns a string that can be used to send a cookie to an Origin Server
// i.e., only used for clients
// see para 4.2.2 of RFC 2109 and para 3.3.4 of RFC 2965
// see also bug #316017
public override string ToString ()
{
return ToString (null);
}
internal string ToString (Uri uri)
{
if (name.Length == 0)
return String.Empty;
StringBuilder result = new StringBuilder (64);
if (version > 0)
result.Append ("$Version=").Append (version).Append ("; ");
result.Append (name).Append ("=").Append (val);
if (version == 0)
return result.ToString ();
if (!String.IsNullOrEmpty (path))
result.Append ("; $Path=").Append (path);
bool append_domain = (uri == null) || (uri.Host != domain);
if (append_domain && !String.IsNullOrEmpty (domain))
result.Append ("; $Domain=").Append (domain);
if (port != null && port.Length != 0)
result.Append ("; $Port=").Append (port);
return result.ToString ();
}
internal string ToClientString ()
{
if (name.Length == 0)
return String.Empty;
StringBuilder result = new StringBuilder (64);
if (version > 0)
result.Append ("Version=").Append (version).Append (";");
result.Append (name).Append ("=").Append (val);
if (path != null && path.Length != 0)
result.Append (";Path=").Append (QuotedString (path));
if (domain != null && domain.Length != 0)
result.Append (";Domain=").Append (QuotedString (domain));
if (port != null && port.Length != 0)
result.Append (";Port=").Append (port);
return result.ToString ();
}
// See par 3.6 of RFC 2616
string QuotedString (string value)
{
if (version == 0 || IsToken (value))
return value;
else
return "\"" + value.Replace("\"", "\\\"") + "\"";
}
bool IsToken (string value)
{
int len = value.Length;
for (int i = 0; i < len; i++) {
char c = value [i];
if (c < 0x20 || c >= 0x7f || tspecials.IndexOf (c) != -1)
return false;
}
return true;
}
}
}

View File

@@ -1,180 +0,0 @@
//
// System.Net.CookieCollection
//
// Authors:
// Lawrence Pit (loz@cable.a2000.nl)
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2004,2009 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.
//
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.Serialization;
namespace System.Net
{
[Serializable]
#if NET_2_1
public sealed class CookieCollection : ICollection, IEnumerable {
#else
public class CookieCollection : ICollection, IEnumerable {
#endif
// not 100% identical to MS implementation
sealed class CookieCollectionComparer : IComparer<Cookie> {
public int Compare (Cookie x, Cookie y)
{
if (x == null || y == null)
return 0;
var ydomain = y.Domain.Length - (y.Domain[0] == '.' ? 1 : 0);
var xdomain = x.Domain.Length - (x.Domain[0] == '.' ? 1 : 0);
int result = ydomain - xdomain;
return result == 0 ? y.Path.Length - x.Path.Length : result;
}
}
static CookieCollectionComparer Comparer = new CookieCollectionComparer ();
List<Cookie> list = new List<Cookie> ();
internal IList<Cookie> List {
get { return list; }
}
// ICollection
public int Count {
get { return list.Count; }
}
public bool IsSynchronized {
get { return false; }
}
public Object SyncRoot {
get { return this; }
}
public void CopyTo (Array array, int index)
{
(list as IList).CopyTo (array, index);
}
public void CopyTo (Cookie [] array, int index)
{
list.CopyTo (array, index);
}
// IEnumerable
public IEnumerator GetEnumerator ()
{
return list.GetEnumerator ();
}
// This
// LAMESPEC: So how is one supposed to create a writable CookieCollection
// instance?? We simply ignore this property, as this collection is always
// writable.
public bool IsReadOnly {
get { return true; }
}
public void Add (Cookie cookie)
{
if (cookie == null)
throw new ArgumentNullException ("cookie");
int pos = SearchCookie (cookie);
if (pos == -1)
list.Add (cookie);
else
list [pos] = cookie;
}
internal void Sort ()
{
if (list.Count > 0)
list.Sort (Comparer);
}
int SearchCookie (Cookie cookie)
{
string name = cookie.Name;
string domain = cookie.Domain;
string path = cookie.Path;
for (int i = list.Count - 1; i >= 0; i--) {
Cookie c = list [i];
if (c.Version != cookie.Version)
continue;
if (0 != String.Compare (domain, c.Domain, true, CultureInfo.InvariantCulture))
continue;
if (0 != String.Compare (name, c.Name, true, CultureInfo.InvariantCulture))
continue;
if (0 != String.Compare (path, c.Path, true, CultureInfo.InvariantCulture))
continue;
return i;
}
return -1;
}
public void Add (CookieCollection cookies)
{
if (cookies == null)
throw new ArgumentNullException ("cookies");
foreach (Cookie c in cookies)
Add (c);
}
public Cookie this [int index] {
get {
if (index < 0 || index >= list.Count)
throw new ArgumentOutOfRangeException ("index");
return list [index];
}
}
public Cookie this [string name] {
get {
foreach (Cookie c in list) {
if (0 == String.Compare (c.Name, name, true, CultureInfo.InvariantCulture))
return c;
}
return null;
}
}
} // CookieCollection
} // System.Net

File diff suppressed because it is too large Load Diff

View File

@@ -1,68 +0,0 @@
//
// System.Net.CookieException.cs
//
// Author:
// Lawrence Pit (loz@cable.a2000.nl)
//
//
// 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.
//
using System.Globalization;
using System.Runtime.Serialization;
namespace System.Net
{
[Serializable]
public class CookieException : FormatException, ISerializable
{
// Constructors
public CookieException () : base ()
{
}
internal CookieException (string msg) : base (msg)
{
}
internal CookieException (string msg, Exception e) : base (msg, e)
{
}
protected CookieException (SerializationInfo serializationInfo, StreamingContext streamingContext)
: base (serializationInfo, streamingContext)
{
}
// Methods
void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)
{
base.GetObjectData (info, context);
}
public override void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)
{
base.GetObjectData (serializationInfo, streamingContext);
}
}
}

View File

@@ -1,270 +0,0 @@
//
// System.Net.CookieParser
//
// Authors:
// Lawrence Pit (loz@cable.a2000.nl)
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
// Daniel Nauck (dna(at)mono-project(dot)de)
//
// (c) 2002 Lawrence Pit
// (c) 2003 Ximian, Inc. (http://www.ximian.com)
// (c) 2008 Daniel Nauck
//
//
// 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.
//
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
namespace System.Net {
struct CookieParser
{
static readonly string[] cookieExpiresFormats =
new string[] { "r",
"ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'",
"ddd, dd'-'MMM'-'yy HH':'mm':'ss 'GMT'" };
readonly string header;
readonly int length;
int pos;
public CookieParser (string header)
{
this.header = header;
this.length = header.Length;
pos = 0;
}
public IEnumerable<Cookie> Parse ()
{
while (pos < length) {
Cookie cookie;
try {
cookie = DoParse ();
} catch {
while ((pos < length) && (header [pos] != ','))
pos++;
pos++;
continue;
}
yield return cookie;
}
}
Cookie DoParse ()
{
var name = GetCookieName ();
if (pos >= length)
return new Cookie (name, string.Empty);
var value = string.Empty;
if (header [pos] == '=') {
pos++;
value = GetCookieValue ();
}
var cookie = new Cookie (name, value);
if (pos >= length) {
return cookie;
} else if (header [pos] == ',') {
pos++;
return cookie;
} else if ((header [pos++] != ';') || (pos >= length)) {
return cookie;
}
while (pos < length) {
var argName = GetCookieName ();
string argVal = string.Empty;
if ((pos < length) && (header [pos] == '=')) {
pos++;
argVal = GetCookieValue ();
}
ProcessArg (cookie, argName, argVal);
if (pos >= length)
break;
if (header [pos] == ',') {
pos++;
break;
} else if (header [pos] != ';') {
break;
}
pos++;
}
return cookie;
}
void ProcessArg (Cookie cookie, string name, string val)
{
if ((name == null) || (name == string.Empty))
throw new InvalidOperationException ();
switch (name.ToUpperInvariant ()) {
case "COMMENT":
if (cookie.Comment == null)
cookie.Comment = val;
break;
case "COMMENTURL":
if (cookie.CommentUri == null)
cookie.CommentUri = new Uri (val);
break;
case "DISCARD":
cookie.Discard = true;
break;
case "DOMAIN":
if (cookie.Domain == "")
cookie.Domain = val;
break;
case "HTTPONLY":
cookie.HttpOnly = true;
break;
case "MAX-AGE": // RFC Style Set-Cookie2
if (cookie.Expires == DateTime.MinValue) {
try {
cookie.Expires = cookie.TimeStamp.AddSeconds (UInt32.Parse (val));
} catch {}
}
break;
case "EXPIRES": // Netscape Style Set-Cookie
if (cookie.Expires != DateTime.MinValue)
break;
if ((pos < length) && (header [pos] == ',') && IsWeekDay (val)) {
pos++;
val = val + ", " + GetCookieValue ();
}
cookie.Expires = TryParseCookieExpires (val);
break;
case "PATH":
cookie.Path = val;
break;
case "PORT":
if (cookie.Port == null)
cookie.Port = val;
break;
case "SECURE":
cookie.Secure = true;
break;
case "VERSION":
try {
cookie.Version = (int) UInt32.Parse (val);
} catch {}
break;
}
}
string GetCookieName ()
{
int k = pos;
while (k < length && Char.IsWhiteSpace (header [k]))
k++;
int begin = k;
while (k < length && header [k] != ';' && header [k] != ',' && header [k] != '=')
k++;
pos = k;
return header.Substring (begin, k - begin).Trim ();
}
string GetCookieValue ()
{
if (pos >= length)
return null;
int k = pos;
while (k < length && Char.IsWhiteSpace (header [k]))
k++;
int begin;
if (header [k] == '"'){
int j;
begin = k++;
while (k < length && header [k] != '"')
k++;
for (j = ++k; j < length && header [j] != ';' && header [j] != ','; j++)
;
pos = j;
} else {
begin = k;
while (k < length && header [k] != ';' && header [k] != ',')
k++;
pos = k;
}
return header.Substring (begin, k - begin).Trim ();
}
static bool IsWeekDay (string value)
{
switch (value.ToLowerInvariant ()) {
case "mon":
case "tue":
case "wed":
case "thu":
case "fri":
case "sat":
case "sun":
case "monday":
case "tuesday":
case "wednesday":
case "thursday":
case "friday":
case "saturday":
case "sunday":
return true;
default:
return false;
}
}
static DateTime TryParseCookieExpires (string value)
{
if (String.IsNullOrEmpty (value))
return DateTime.MinValue;
for (int i = 0; i < cookieExpiresFormats.Length; i++) {
try {
DateTime cookieExpiresUtc = DateTime.ParseExact (value, cookieExpiresFormats [i], CultureInfo.InvariantCulture);
//convert UTC/GMT time to local time
cookieExpiresUtc = DateTime.SpecifyKind (cookieExpiresUtc, DateTimeKind.Utc);
return TimeZone.CurrentTimeZone.ToLocalTime (cookieExpiresUtc);
} catch {}
}
//If we can't parse Expires, use cookie as session cookie (expires is DateTime.MinValue)
return DateTime.MinValue;
}
}
}

View File

@@ -41,9 +41,7 @@ using System.Collections;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Runtime.Remoting.Messaging;
#if NET_4_5
using System.Threading.Tasks;
#endif
#if !MOBILE
using Mono.Net.Dns;
@@ -456,7 +454,6 @@ namespace System.Net {
return ret;
}
#if NET_4_5
public static Task<IPAddress[]> GetHostAddressesAsync (string hostNameOrAddress)
{
return Task<IPAddress[]>.Factory.FromAsync (BeginGetHostAddresses, EndGetHostAddresses, hostNameOrAddress, null);
@@ -471,7 +468,6 @@ namespace System.Net {
{
return Task<IPHostEntry>.Factory.FromAsync (BeginGetHostEntry, EndGetHostEntry, hostNameOrAddress, null);
}
#endif
}
}

View File

@@ -28,7 +28,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_0
using System.Net.Sockets;
@@ -106,4 +105,3 @@ namespace System.Net {
}
}
#endif

View File

@@ -1,53 +0,0 @@
//
// DownloadDataCompletedEventArgs.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// (C) 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.
//
using System.ComponentModel;
using System.IO;
namespace System.Net
{
public class DownloadDataCompletedEventArgs : AsyncCompletedEventArgs
{
internal DownloadDataCompletedEventArgs (byte [] result,
Exception error, bool cancelled, object userState)
: base (error, cancelled, userState)
{
this.result = result;
}
byte [] result;
public byte [] Result {
get {
return result;
}
}
}
}

View File

@@ -1,34 +0,0 @@
//
// DownloadDataCompletedEventHandler.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.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
{
public delegate void DownloadDataCompletedEventHandler (object sender, DownloadDataCompletedEventArgs e);
}

View File

@@ -1,55 +0,0 @@
//
// DownloadProgressChangedEventArgs.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// (C) 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.
//
using System.ComponentModel;
using System.IO;
namespace System.Net
{
public class DownloadProgressChangedEventArgs : ProgressChangedEventArgs
{
internal DownloadProgressChangedEventArgs (long bytesReceived, long totalBytesToReceive, object userState)
: base (totalBytesToReceive != -1 ? ((int)(bytesReceived * 100 / totalBytesToReceive)) : 0, userState)
{
this.received = bytesReceived;
this.total = totalBytesToReceive;
}
long received, total;
public long BytesReceived {
get { return received; }
}
public long TotalBytesToReceive {
get { return total; }
}
}
}

View File

@@ -1,32 +0,0 @@
//
// DownloadProgressChangedEventHandler.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.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
{
public delegate void DownloadProgressChangedEventHandler (object sender, DownloadProgressChangedEventArgs e);
}

View File

@@ -1,55 +0,0 @@
//
// DownloadStringCompletedEventArgs.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006,2009 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.
//
using System.ComponentModel;
namespace System.Net
{
public class DownloadStringCompletedEventArgs : AsyncCompletedEventArgs
{
internal DownloadStringCompletedEventArgs (string result,
Exception error, bool cancelled, object userState)
: base (error, cancelled, userState)
{
this.result = result;
}
string result;
public string Result {
get {
#if NET_2_1
RaiseExceptionIfNecessary ();
#endif
return result;
}
}
}
}

View File

@@ -1,31 +0,0 @@
//
// DownloadStringCompletedEventHandler.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.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
{
public delegate void DownloadStringCompletedEventHandler (object sender, DownloadStringCompletedEventArgs e);
}

View File

@@ -153,9 +153,7 @@ namespace System.Net
GC.SuppressFinalize (this);
}
#if NET_4_0
protected override
#endif
void Dispose (bool disposing)
{
if (this.disposed)
@@ -173,9 +171,7 @@ namespace System.Net
fileStream = null;
if (stream != null)
stream.Close (); // also closes webRequest
#if NET_4_0
base.Dispose (disposing);
#endif
}
private void CheckDisposed ()

View File

@@ -94,6 +94,8 @@ namespace System.Net
WebRequestMethods.Ftp.UploadFileWithUniqueName // STUR
};
Encoding dataEncoding = Encoding.UTF8;
internal FtpWebRequest (Uri uri)
{
this.requestUri = uri;
@@ -793,7 +795,11 @@ namespace System.Net
Authenticate ();
FtpStatus status = SendCommand ("OPTS", "utf8", "on");
// ignore status for OPTS
if ((int)status.StatusCode < 200 || (int)status.StatusCode > 300)
dataEncoding = Encoding.Default;
else
dataEncoding = Encoding.UTF8;
status = SendCommand (WebRequestMethods.Ftp.PrintWorkingDirectory);
initial_path = GetInitialPath (status);
}
@@ -1080,7 +1086,7 @@ namespace System.Net
commandString += " " + String.Join (" ", parameters);
commandString += EOL;
cmd = Encoding.ASCII.GetBytes (commandString);
cmd = dataEncoding.GetBytes (commandString);
try {
controlStream.Write (cmd, 0, cmd.Length);
} catch (IOException) {

View File

@@ -1,35 +0,0 @@
//
// System.Net.HttpContinueDelegate.cs
//
// Author:
// Lawrence Pit (loz@cable.a2000.nl)
//
//
// 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
{
public
delegate void HttpContinueDelegate (
int StatusCode,
WebHeaderCollection httpHeaders);
}

View File

@@ -32,9 +32,7 @@
using System.Collections;
using System.Threading;
#if NET_4_5
using System.Threading.Tasks;
#endif
//TODO: logging
namespace System.Net {
@@ -288,12 +286,10 @@ namespace System.Net {
disposed = true;
}
#if NET_4_5
public Task<HttpListenerContext> GetContextAsync ()
{
return Task<HttpListenerContext>.Factory.FromAsync (BeginGetContext, EndGetContext, null);
}
#endif
internal void CheckDisposed ()
{

View File

@@ -32,10 +32,8 @@ using System.Collections.Specialized;
using System.IO;
using System.Security.Principal;
using System.Text;
#if NET_4_5
using System.Threading.Tasks;
using System.Net.WebSockets;
#endif
namespace System.Net {
public sealed class HttpListenerContext {
@@ -139,7 +137,6 @@ namespace System.Net {
}
}
#if NET_4_5
public Task<HttpListenerWebSocketContext> AcceptWebSocketAsync (string subProtocol)
{
throw new NotImplementedException ();
@@ -154,7 +151,6 @@ namespace System.Net {
{
throw new NotImplementedException ();
}
#endif
}
}
#endif

View File

@@ -43,17 +43,12 @@ using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Text;
#if NET_4_0
using System.Security.Authentication.ExtendedProtection;
#endif
#if NET_4_5
using System.Threading.Tasks;
#endif
namespace System.Net {
public sealed class HttpListenerRequest
{
#if NET_4_0
class Context : TransportContext
{
public override ChannelBinding GetChannelBinding (ChannelBindingKind kind)
@@ -61,7 +56,6 @@ namespace System.Net {
throw new NotImplementedException ();
}
}
#endif
string [] accept_types;
Encoding content_encoding;
@@ -329,6 +323,9 @@ namespace System.Net {
return false;
if (InputStream.EndRead (ares) <= 0)
return true;
} catch (ObjectDisposedException e) {
input_stream = null;
return true;
} catch {
return false;
}
@@ -509,7 +506,6 @@ namespace System.Net {
return context.Connection.ClientCertificate;
}
#if NET_4_0
[MonoTODO]
public string ServiceName {
get {
@@ -522,9 +518,7 @@ namespace System.Net {
return new Context ();
}
}
#endif
#if NET_4_5
[MonoTODO]
public bool IsWebSocketRequest {
get {
@@ -536,7 +530,6 @@ namespace System.Net {
{
return Task<X509Certificate2>.Factory.FromAsync (BeginGetClientCertificate, EndGetClientCertificate, null);
}
#endif
}
}
#endif

View File

@@ -475,7 +475,7 @@ namespace System.Net {
if (cookies != null) {
foreach (Cookie cookie in cookies)
headers.SetInternal ("Set-Cookie", cookie.ToClientString ());
headers.SetInternal ("Set-Cookie", CookieToClientString (cookie));
}
StreamWriter writer = new StreamWriter (ms, encoding, 256);
@@ -492,6 +492,51 @@ namespace System.Net {
HeadersSent = true;
}
static string CookieToClientString (Cookie cookie)
{
if (cookie.Name.Length == 0)
return String.Empty;
StringBuilder result = new StringBuilder (64);
if (cookie.Version > 0)
result.Append ("Version=").Append (cookie.Version).Append (";");
result.Append (cookie.Name).Append ("=").Append (cookie.Value);
if (cookie.Path != null && cookie.Path.Length != 0)
result.Append (";Path=").Append (QuotedString (cookie, cookie.Path));
if (cookie.Domain != null && cookie.Domain.Length != 0)
result.Append (";Domain=").Append (QuotedString (cookie, cookie.Domain));
if (cookie.Port != null && cookie.Port.Length != 0)
result.Append (";Port=").Append (cookie.Port);
return result.ToString ();
}
static string QuotedString (Cookie cookie, string value)
{
if (cookie.Version == 0 || IsToken (value))
return value;
else
return "\"" + value.Replace("\"", "\\\"") + "\"";
}
static string tspecials = "()<>@,;:\\\"/[]?={} \t"; // from RFC 2965, 2068
static bool IsToken (string value)
{
int len = value.Length;
for (int i = 0; i < len; i++) {
char c = value [i];
if (c < 0x20 || c >= 0x7f || tspecials.IndexOf (c) != -1)
return false;
}
return true;
}
public void SetCookie (Cookie cookie)
{
if (cookie == null)

Some files were not shown because too many files have changed in this diff Show More