using System.Collections;
using System.Globalization;
using System.IO;
+using System.IO.Compression;
using System.Net.Sockets;
using System.Runtime.Serialization;
using System.Text;
-#if NET_2_0
-using System.IO.Compression;
-#endif
namespace System.Net
{
+#if MOONLIGHT
+ internal class HttpWebResponse : WebResponse, ISerializable, IDisposable {
+#else
[Serializable]
- public class HttpWebResponse : WebResponse, ISerializable, IDisposable
- {
+ public class HttpWebResponse : WebResponse, ISerializable, IDisposable {
+#endif
Uri uri;
WebHeaderCollection webHeaders;
CookieCollection cookieCollection;
try {
string cl = webHeaders ["Content-Length"];
-#if NET_2_0
if (String.IsNullOrEmpty (cl) || !Int64.TryParse (cl, out contentLength))
contentLength = -1;
-#else
- if (cl != null && cl != String.Empty)
- contentLength = (long) UInt64.Parse (cl);
-#endif
} catch (Exception) {
contentLength = -1;
}
this.cookie_container = container;
FillCookies ();
}
-#if NET_2_0
+
string content_encoding = webHeaders ["Content-Encoding"];
if (content_encoding == "gzip" && (data.request.AutomaticDecompression & DecompressionMethods.GZip) != 0)
stream = new GZipStream (stream, CompressionMode.Decompress);
else if (content_encoding == "deflate" && (data.request.AutomaticDecompression & DecompressionMethods.Deflate) != 0)
stream = new DeflateStream (stream, CompressionMode.Decompress);
-#endif
}
-#if NET_2_0
[Obsolete ("Serialization is obsoleted for this type", false)]
-#endif
protected HttpWebResponse (SerializationInfo serializationInfo, StreamingContext streamingContext)
{
SerializationInfo info = serializationInfo;
public override WebHeaderCollection Headers {
get {
-#if ONLY_1_1
- CheckDisposed ();
-#endif
return webHeaders;
}
}
-#if NET_2_0
static Exception GetMustImplement ()
{
return new NotImplementedException ();
throw GetMustImplement ();
}
}
-#endif
public DateTime LastModified {
get {
}
// Methods
-#if !NET_2_0
- public override int GetHashCode ()
- {
- return base.GetHashCode ();
- }
-#endif
public string GetResponseHeader (string headerName)
{
GetObjectData (serializationInfo, streamingContext);
}
-#if NET_2_0
- protected override
-#endif
- void GetObjectData (SerializationInfo serializationInfo,
- StreamingContext streamingContext)
+ protected override void GetObjectData (SerializationInfo serializationInfo,
+ StreamingContext streamingContext)
{
SerializationInfo info = serializationInfo;
GC.SuppressFinalize (this);
}
-#if !NET_2_0
- protected virtual
-#endif
void Dispose (bool disposing)
{
if (this.disposed)
if (disposing) {
// release managed resources
uri = null;
-#if !NET_2_0
- webHeaders = null;
-#endif
cookieCollection = null;
method = null;
version = null;
if (cookie.Domain == "")
cookie.Domain = val;
break;
-#if NET_2_0
case "HTTPONLY":
cookie.HttpOnly = true;
break;
-#endif
case "MAX-AGE": // RFC Style Set-Cookie2
if (cookie.Expires == DateTime.MinValue) {
try {
DateTime cookieExpiresUtc = DateTime.ParseExact (value, cookieExpiresFormats [i], CultureInfo.InvariantCulture);
//convert UTC/GMT time to local time
-#if NET_2_0
cookieExpiresUtc = DateTime.SpecifyKind (cookieExpiresUtc, DateTimeKind.Utc);
return TimeZone.CurrentTimeZone.ToLocalTime (cookieExpiresUtc);
-#else
- //DateTime.Kind is only available on .NET 2.0, so do some calculation
- TimeSpan localOffset = TimeZone.CurrentTimeZone.GetUtcOffset (cookieExpiresUtc.Date);
- return cookieExpiresUtc.Add (localOffset);
-#endif
} catch {}
}