Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
FileWebResponse.cs
Go to the documentation of this file.
2using System.IO;
4
5namespace System.Net;
6
8{
9 private readonly long _contentLength;
10
11 private readonly FileAccess _fileAccess;
12
13 private readonly WebHeaderCollection _headers;
14
15 private readonly Uri _uri;
16
17 private Stream _stream;
18
19 private bool _closed;
20
21 public override long ContentLength
22 {
23 get
24 {
26 return _contentLength;
27 }
28 }
29
30 public override string ContentType
31 {
32 get
33 {
35 return "application/octet-stream";
36 }
37 }
38
39 public override WebHeaderCollection Headers
40 {
41 get
42 {
44 return _headers;
45 }
46 }
47
48 public override bool SupportsHeaders => true;
49
50 public override Uri ResponseUri
51 {
52 get
53 {
55 return _uri;
56 }
57 }
58
60 {
61 try
62 {
64 if (access == FileAccess.Write)
65 {
67 }
68 else
69 {
70 _stream = new WebFileStream(request, uri.LocalPath, FileMode.Open, FileAccess.Read, FileShare.Read, 8192, useAsync);
72 }
74 _headers["Content-Length"] = _contentLength.ToString(NumberFormatInfo.InvariantInfo);
75 _headers["Content-Type"] = "application/octet-stream";
76 _uri = uri;
77 }
78 catch (Exception ex)
79 {
80 throw new WebException(ex.Message, ex, WebExceptionStatus.ConnectFailure, null);
81 }
82 }
83
84 [Obsolete("Serialization has been deprecated for FileWebResponse.")]
90
95
100
101 private void CheckDisposed()
102 {
103 if (_closed)
104 {
105 throw new ObjectDisposedException(GetType().FullName);
106 }
107 }
108
109 public override void Close()
110 {
111 if (!_closed)
112 {
113 _closed = true;
115 if (stream != null)
116 {
117 stream.Close();
118 _stream = null;
119 }
120 }
121 }
122
123 public override Stream GetResponseStream()
124 {
126 return _stream;
127 }
128}
virtual void Close()
Definition Stream.cs:644
static readonly Stream Null
Definition Stream.cs:488
override Stream GetResponseStream()
FileWebResponse(SerializationInfo serializationInfo, StreamingContext streamingContext)
override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
FileWebResponse(FileWebRequest request, Uri uri, FileAccess access, bool useAsync)
readonly FileAccess _fileAccess
readonly WebHeaderCollection _headers
string LocalPath
Definition Uri.cs:280
void GetObjectData(SerializationInfo info, StreamingContext context)