File: HttpContextWrapper.cs

package info (click to toggle)
mono 6.8.0.105%2Bdfsg-3.3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,284,512 kB
  • sloc: cs: 11,172,132; xml: 2,850,069; ansic: 671,653; cpp: 122,091; perl: 59,366; javascript: 30,841; asm: 22,168; makefile: 20,093; sh: 15,020; python: 4,827; pascal: 925; sql: 859; sed: 16; php: 1
file content (327 lines) | stat: -rw-r--r-- 10,046 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
//------------------------------------------------------------------------------
// <copyright file="HttpContextWrapper2.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//------------------------------------------------------------------------------

namespace System.Web {
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Diagnostics.CodeAnalysis;
    using System.Globalization;
    using System.Runtime.CompilerServices;
    using System.Security.Principal;
    using System.Threading.Tasks;
    using System.Web.Caching;
    using System.Web.Configuration;
    using System.Web.Instrumentation;
    using System.Web.Profile;
    using System.Web.SessionState;
    using System.Web.WebSockets;

    [TypeForwardedFrom("System.Web.Abstractions, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
    public class HttpContextWrapper : HttpContextBase {
        private readonly HttpContext _context;

        public HttpContextWrapper(HttpContext httpContext) {
            if (httpContext == null) {
                throw new ArgumentNullException("httpContext");
            }
            _context = httpContext;
        }

        public override ISubscriptionToken AddOnRequestCompleted(Action<HttpContextBase> callback) {
            return _context.AddOnRequestCompleted(WrapCallback(callback));
        }

        public override Exception[] AllErrors {
            get {
                return _context.AllErrors;
            }
        }

        [EditorBrowsable(EditorBrowsableState.Advanced)]
        public override bool AllowAsyncDuringSyncStages {
            get {
                return _context.AllowAsyncDuringSyncStages;
            }
            set {
                _context.AllowAsyncDuringSyncStages = value;
            }
        }

        public override HttpApplicationStateBase Application {
            get {
                return new HttpApplicationStateWrapper(_context.Application);
            }
        }

        //
        public override HttpApplication ApplicationInstance {
            get {
                return _context.ApplicationInstance;
            }
            set {
                _context.ApplicationInstance = value;
            }
        }

        public override AsyncPreloadModeFlags AsyncPreloadMode {
            get {
                return _context.AsyncPreloadMode;
            }
            set {
                _context.AsyncPreloadMode = value;
            }
        }

        //
        public override Cache Cache {
            get {
                return _context.Cache;
            }
        }

        public override IHttpHandler CurrentHandler {
            get {
                return _context.CurrentHandler;
            }
        }

        public override RequestNotification CurrentNotification {
            get {
                return _context.CurrentNotification;
            }
        }

        public override Exception Error {
            get {
                return _context.Error;
            }
        }

        public override IHttpHandler Handler {
            get {
                return _context.Handler;
            }
            set {
                _context.Handler = value;
            }
        }

        public override bool IsCustomErrorEnabled {
            get {
                return _context.IsCustomErrorEnabled;
            }
        }

        public override bool IsDebuggingEnabled {
            get {
                return _context.IsDebuggingEnabled;
            }
        }

        public override bool IsPostNotification {
            get {
                return _context.IsPostNotification;
            }
        }

        public override bool IsWebSocketRequest {
            get {
                return _context.IsWebSocketRequest;
            }
        }

        public override bool IsWebSocketRequestUpgrading {
            get {
                return _context.IsWebSocketRequestUpgrading;
            }
        }

        public override IDictionary Items {
            get {
                return _context.Items;
            }
        }

        public override PageInstrumentationService PageInstrumentation {
            get {
                return _context.PageInstrumentation;
            }
        }

        public override IHttpHandler PreviousHandler {
            get {
                return _context.PreviousHandler;
            }
        }

        //
        public override ProfileBase Profile {
            get {
                return _context.Profile;
            }
        }

        public override HttpRequestBase Request {
            get {
                return new HttpRequestWrapper(_context.Request);
            }
        }

        public override HttpResponseBase Response {
            get {
                return new HttpResponseWrapper(_context.Response);
            }
        }

        public override HttpServerUtilityBase Server {
            get {
                return new HttpServerUtilityWrapper(_context.Server);
            }
        }

        public override HttpSessionStateBase Session {
            get {
                HttpSessionState session = _context.Session;
                return (session != null) ? new HttpSessionStateWrapper(session) : null;
            }
        }

        public override bool SkipAuthorization {
            get {
                return _context.SkipAuthorization;
            }
            set {
                _context.SkipAuthorization = value;
            }
        }

        public override DateTime Timestamp {
            get {
                return _context.Timestamp;
            }
        }

        public override bool ThreadAbortOnTimeout {
            get {
                return _context.ThreadAbortOnTimeout;
            }
            set {
                _context.ThreadAbortOnTimeout = value;
            }
        }

        //
        public override TraceContext Trace {
            get {
                return _context.Trace;
            }
        }

        public override IPrincipal User {
            get {
                return _context.User;
            }
            set {
                _context.User = value;
            }
        }

        public override string WebSocketNegotiatedProtocol {
            get {
                return _context.WebSocketNegotiatedProtocol;
            }
        }

        public override IList<string> WebSocketRequestedProtocols {
            get {
                return _context.WebSocketRequestedProtocols;
            }
        }

        public override void AcceptWebSocketRequest(Func<AspNetWebSocketContext, Task> userFunc) {
            _context.AcceptWebSocketRequest(userFunc);
        }

        public override void AcceptWebSocketRequest(Func<AspNetWebSocketContext, Task> userFunc, AspNetWebSocketOptions options) {
            _context.AcceptWebSocketRequest(userFunc, options);
        }    

        public override void AddError(Exception errorInfo) {
            _context.AddError(errorInfo);
        }

        public override void ClearError() {
            _context.ClearError();
        }

        public override ISubscriptionToken DisposeOnPipelineCompleted(IDisposable target) {
            return _context.DisposeOnPipelineCompleted(target);
        }

        [SuppressMessage("Microsoft.Globalization", "CA1304:SpecifyCultureInfo",
            Justification = "Matches HttpContext class")]
        public override object GetGlobalResourceObject(string classKey, string resourceKey) {
            return HttpContext.GetGlobalResourceObject(classKey, resourceKey);
        }

        public override object GetGlobalResourceObject(string classKey, string resourceKey, CultureInfo culture) {
            return HttpContext.GetGlobalResourceObject(classKey, resourceKey, culture);
        }

        [SuppressMessage("Microsoft.Globalization", "CA1304:SpecifyCultureInfo",
            Justification = "Matches HttpContext class")]
        public override object GetLocalResourceObject(string virtualPath, string resourceKey) {
            return HttpContext.GetLocalResourceObject(virtualPath, resourceKey);
        }

        public override object GetLocalResourceObject(string virtualPath, string resourceKey, CultureInfo culture) {
            return HttpContext.GetLocalResourceObject(virtualPath, resourceKey, culture);
        }

        public override object GetSection(string sectionName) {
            return _context.GetSection(sectionName);
        }

        public override void RemapHandler(IHttpHandler handler) {
            _context.RemapHandler(handler);
        }

        public override void RewritePath(string path) {
            _context.RewritePath(path);
        }

        public override void RewritePath(string path, bool rebaseClientPath) {
            _context.RewritePath(path, rebaseClientPath);
        }

        public override void RewritePath(string filePath, string pathInfo, string queryString) {
            _context.RewritePath(filePath, pathInfo, queryString);
        }

        public override void RewritePath(string filePath, string pathInfo, string queryString, bool setClientFilePath) {
            _context.RewritePath(filePath, pathInfo, queryString, setClientFilePath);
        }

        public override void SetSessionStateBehavior(SessionStateBehavior sessionStateBehavior) {
            _context.SetSessionStateBehavior(sessionStateBehavior);
        }

        public override object GetService(Type serviceType) {
            return ((IServiceProvider)_context).GetService(serviceType);
        }

        internal static Action<HttpContext> WrapCallback(Action<HttpContextBase> callback) {
            if (callback != null) {
                return context => callback(new HttpContextWrapper(context));
            }
            else {
                return null;
            }
        }
    }
}