Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HttpResponseMessage.cs
Go to the documentation of this file.
4using System.Text;
5
6namespace System.Net.Http;
7
9{
11
13
15
16 private string _reasonPhrase;
17
19
21
23
24 private bool _disposed;
25
27
29 {
30 get
31 {
32 return _version;
33 }
34 set
35 {
36 if (value == null)
37 {
38 throw new ArgumentNullException("value");
39 }
42 }
43 }
44
45 public HttpContent Content
46 {
47 get
48 {
49 return _content ?? (_content = new EmptyContent());
50 }
51 [param: AllowNull]
52 set
53 {
55 if (System.Net.NetEventSource.Log.IsEnabled())
56 {
57 if (value == null)
58 {
60 }
61 else
62 {
63 System.Net.NetEventSource.Associate(this, value, "Content");
64 }
65 }
67 }
68 }
69
71 {
72 get
73 {
74 return _statusCode;
75 }
76 set
77 {
78 if (value < (HttpStatusCode)0 || value > (HttpStatusCode)999)
79 {
80 throw new ArgumentOutOfRangeException("value");
81 }
84 }
85 }
86
87 public string? ReasonPhrase
88 {
89 get
90 {
91 if (_reasonPhrase != null)
92 {
93 return _reasonPhrase;
94 }
96 }
97 set
98 {
99 if (value != null && ContainsNewLineCharacter(value))
100 {
102 }
105 }
106 }
107
109
111
113 {
114 get
115 {
116 return _requestMessage;
117 }
118 set
119 {
121 if (value != null && System.Net.NetEventSource.Log.IsEnabled())
122 {
123 System.Net.NetEventSource.Associate(this, value, "RequestMessage");
124 }
126 }
127 }
128
130 {
131 get
132 {
133 if (_statusCode >= HttpStatusCode.OK)
134 {
135 return _statusCode <= (HttpStatusCode)299;
136 }
137 return false;
138 }
139 }
140
142 {
143 _version = value;
144 }
145
150
152 {
154 }
155
157 {
158 if (_trailingHeaders == null)
159 {
160 _trailingHeaders = headers;
161 }
162 else
163 {
165 }
166 }
167
169 : this(HttpStatusCode.OK)
170 {
171 }
172
174 {
175 if (statusCode < (HttpStatusCode)0 || statusCode > (HttpStatusCode)999)
176 {
177 throw new ArgumentOutOfRangeException("statusCode");
178 }
179 _statusCode = statusCode;
181 }
182
191
192 public override string ToString()
193 {
194 StringBuilder stringBuilder = new StringBuilder();
195 stringBuilder.Append("StatusCode: ");
196 stringBuilder.Append((int)_statusCode);
197 stringBuilder.Append(", ReasonPhrase: '");
198 stringBuilder.Append(ReasonPhrase ?? "<null>");
199 stringBuilder.Append("', Version: ");
200 stringBuilder.Append(_version);
201 stringBuilder.Append(", Content: ");
202 stringBuilder.Append((_content == null) ? "<null>" : _content.GetType().ToString());
203 stringBuilder.AppendLine(", Headers:");
204 HeaderUtilities.DumpHeaders(stringBuilder, _headers, _content?.Headers);
205 if (_trailingHeaders != null)
206 {
207 stringBuilder.AppendLine(", Trailing Headers:");
209 }
210 return stringBuilder.ToString();
211 }
212
213 private bool ContainsNewLineCharacter(string value)
214 {
215 foreach (char c in value)
216 {
217 if (c == '\r' || c == '\n')
218 {
219 return true;
220 }
221 }
222 return false;
223 }
224
225 protected virtual void Dispose(bool disposing)
226 {
227 if (disposing && !_disposed)
228 {
229 _disposed = true;
230 if (_content != null)
231 {
233 }
234 }
235 }
236
237 public void Dispose()
238 {
239 Dispose(disposing: true);
240 GC.SuppressFinalize(this);
241 }
242
243 private void CheckDisposed()
244 {
245 if (_disposed)
246 {
247 throw new ObjectDisposedException(GetType().ToString());
248 }
249 }
250}
static void SuppressFinalize(object obj)
Definition GC.cs:202
Definition GC.cs:8
static CultureInfo InvariantCulture
static string Get(HttpStatusCode code)
static readonly Version Version11
Definition HttpVersion.cs:9
static void DumpHeaders(StringBuilder sb, params HttpHeaders[] headers)
override void AddHeaders(HttpHeaders sourceHeaders)
virtual void Dispose(bool disposing)
void StoreReceivedTrailingHeaders(HttpResponseHeaders headers)
HttpResponseMessage(HttpStatusCode statusCode)
void SetStatusCodeWithoutValidation(HttpStatusCode value)
virtual void Dispose(bool disposing)
static readonly System.Net.NetEventSource Log
static void Associate(object first, object second, [CallerMemberName] string memberName=null)
static void ContentNull(object obj)
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string net_http_message_not_success_statuscode
Definition SR.cs:72
static string net_http_reasonphrase_format_error
Definition SR.cs:16
Definition SR.cs:7
override string ToString()
StringBuilder Append(char value, int repeatCount)