// Author:\r
// Lawrence Pit (loz@cable.a2000.nl)\r
//\r
-
-//
-// 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.
-//
+\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
\r
using System;\r
using System.IO;\r
private FileStream fileStream;\r
private long contentLength;\r
private WebHeaderCollection webHeaders;\r
- private bool disposed = false;\r
+ private bool disposed;\r
+ Exception exception;\r
\r
// Constructors\r
\r
this.contentLength = fileStream.Length;\r
this.webHeaders = new WebHeaderCollection ();\r
this.webHeaders.Add ("Content-Length", Convert.ToString (contentLength));\r
- this.webHeaders.Add ("Content-Type", "binary/octet-stream");\r
+ this.webHeaders.Add ("Content-Type", "application/octet-stream");\r
} catch (Exception e) {\r
throw new WebException (e.Message, e);\r
}\r
}\r
+\r
+ internal FileWebResponse (Uri responseUri, WebException exception)\r
+ {\r
+ this.responseUri = responseUri;\r
+ this.exception = exception;\r
+ }\r
\r
+ [Obsolete ("Serialization is obsoleted for this type", false)]\r
protected FileWebResponse (SerializationInfo serializationInfo, StreamingContext streamingContext)\r
{\r
SerializationInfo info = serializationInfo;\r
}\r
\r
// Properties\r
+ internal bool HasError {\r
+ get { return exception != null; }\r
+ }\r
+\r
+ internal Exception Error {\r
+ get { return exception; }\r
+ }\r
\r
- public override long ContentLength { \r
+ public override long ContentLength {\r
get {\r
CheckDisposed ();\r
return this.contentLength;\r
}\r
}\r
\r
- public override string ContentType { \r
+ public override string ContentType {\r
get {\r
CheckDisposed ();\r
- return "binary/octet-stream";\r
+ return "application/octet-stream";\r
}\r
}\r
\r
- public override WebHeaderCollection Headers { \r
+ public override WebHeaderCollection Headers {\r
get {\r
CheckDisposed ();\r
return this.webHeaders;\r
}\r
}\r
\r
- public override Uri ResponseUri { \r
+ public override Uri ResponseUri {\r
get {\r
CheckDisposed ();\r
return this.responseUri;\r
}\r
- } \r
+ }\r
\r
// Methods\r
\r
void ISerializable.GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)\r
+ {\r
+ GetObjectData (serializationInfo, streamingContext);\r
+ }\r
+\r
+ protected override void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)\r
{\r
SerializationInfo info = serializationInfo;\r
\r
info.AddValue ("responseUri", responseUri, typeof (Uri));\r
info.AddValue ("contentLength", contentLength);\r
info.AddValue ("webHeaders", webHeaders, typeof (WebHeaderCollection));\r
- } \r
+ }\r
\r
public override Stream GetResponseStream()\r
{\r
((IDisposable) this).Dispose ();\r
}\r
\r
+#if TARGET_JVM //enable overrides for extenders\r
+ public override void Dispose()\r
+#else\r
void IDisposable.Dispose()\r
+#endif\r
{\r
Dispose (true);\r
\r
GC.SuppressFinalize (this); \r
}\r
\r
- protected virtual void Dispose (bool disposing)\r
+ void Dispose (bool disposing)\r
{\r
if (this.disposed)\r
return;\r