+2008-07-25 Gert Driesen <drieseng@users.sourceforge.net>ยต
+
+ * HttpWebResponse.cs: Initialize contentLength in ctor, as it must
+ remain accessible after the response is disposed (and the headers are
+ no longer available). Adding missing disposed checks in properties
+ (except for StatusCode) and GetResponseHeader. On the 2.0 profile,
+ headers must remain accessible after the HttpWebResponse is disposed.
+
2008-06-10 Stephane Delcroix <sdelcroix@novell.com>
* IPAddress.cs: allow usage on 2.1 as smcs knows nothing about
Version version;
HttpStatusCode statusCode;
string statusDescription;
- long contentLength = -1;
+ long contentLength;
string contentType;
CookieContainer cookie_container;
- bool disposed = false;
+ bool disposed;
Stream stream;
// Constructors
statusCode = (HttpStatusCode) data.StatusCode;
statusDescription = data.StatusDescription;
stream = data.stream;
+
+ try {
+ contentLength = (long) UInt64.Parse (webHeaders ["Content-Length"]);
+ } catch (Exception) {
+ contentLength = - 1;
+ }
+
if (container != null) {
this.cookie_container = container;
FillCookies ();
}
public string ContentEncoding {
- get {
+ get {
+ CheckDisposed ();
string h = webHeaders ["Content-Encoding"];
return h != null ? h : "";
}
public override long ContentLength {
get {
- if (contentLength != -1)
- return contentLength;
-
- try {
- contentLength = (long) UInt64.Parse (webHeaders ["Content-Length"]);
- } catch (Exception) {
- return -1;
- }
-
return contentLength;
}
}
public override string ContentType {
get {
+ CheckDisposed ();
+
if (contentType == null)
contentType = webHeaders ["Content-Type"];
}
public CookieCollection Cookies {
- get {
+ get {
+ CheckDisposed ();
if (cookieCollection == null)
cookieCollection = new CookieCollection ();
return cookieCollection;
}
set {
+ CheckDisposed ();
cookieCollection = value;
}
}
public override WebHeaderCollection Headers {
- get {
+ get {
+#if ONLY_1_1
+ CheckDisposed ();
+#endif
return webHeaders;
}
}
public DateTime LastModified {
get {
+ CheckDisposed ();
try {
string dtStr = webHeaders ["Last-Modified"];
return MonoHttpDate.Parse (dtStr);
}
public string Method {
- get {
+ get {
+ CheckDisposed ();
return method;
}
}
public Version ProtocolVersion {
- get {
+ get {
+ CheckDisposed ();
return version;
}
}
public override Uri ResponseUri {
- get {
+ get {
+ CheckDisposed ();
return uri;
}
}
public string Server {
- get {
+ get {
+ CheckDisposed ();
return webHeaders ["Server"];
}
}
public HttpStatusCode StatusCode {
- get {
+ get {
return statusCode;
}
}
public string StatusDescription {
- get {
+ get {
+ CheckDisposed ();
return statusDescription;
}
}
public string GetResponseHeader (string headerName)
{
+ CheckDisposed ();
string value = webHeaders [headerName];
return (value != null) ? value : "";
}
if (disposing) {
// release managed resources
uri = null;
+#if !NET_2_0
webHeaders = null;
+#endif
cookieCollection = null;
method = null;
version = null;
System.Net/FileWebRequestTest.cs
System.Net/FileWebResponseTest.cs
System.Net/HttpWebRequestTest.cs
+System.Net/HttpWebResponseTest.cs
System.Net/HttpListenerTest.cs
System.Net/HttpListenerBasicIdentityTest.cs
System.Net/HttpListenerPrefixCollectionTest.cs