Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -46,9 +46,7 @@ namespace System.Web
HttpRuntimeClose = 12,
InitializationError = 13,
MaxRecompilationsReached = 14
#if NET_3_5
, BuildManagerChange = 15
#endif
}
}

View File

@@ -332,9 +332,6 @@ namespace System.Web
lock (lockobj) {
if (loaded)
return;
#if TARGET_J2EE
string filepath = "browscap.ini";
#else
string dir = HttpRuntime.MachineConfigurationDirectory;
string filepath = Path.Combine (dir, "browscap.ini");
if (!File.Exists (filepath)) {
@@ -342,7 +339,6 @@ namespace System.Web
dir = Path.GetDirectoryName (dir);
filepath = Path.Combine (dir, "browscap.ini");
}
#endif
try {
LoadFile (filepath);
} catch (Exception) {}
@@ -351,46 +347,13 @@ namespace System.Web
}
}
#if TARGET_J2EE
static TextReader GetJavaTextReader(string filename)
{
try
{
java.lang.ClassLoader cl = (java.lang.ClassLoader)
AppDomain.CurrentDomain.GetData("GH_ContextClassLoader");
if (cl == null)
return null;
string custom = String.Concat("browscap/", filename);
java.io.InputStream inputStream = cl.getResourceAsStream(custom);
if (inputStream == null)
inputStream = cl.getResourceAsStream(filename);
if (inputStream == null)
return null;
return new StreamReader (new System.Web.J2EE.J2EEUtils.InputStreamWrapper (inputStream));
}
catch (Exception e)
{
return null;
}
}
#endif
static void LoadFile (string filename)
{
#if TARGET_J2EE
TextReader input = GetJavaTextReader(filename);
if(input == null)
return;
#else
if (!File.Exists (filename))
return;
TextReader input = new StreamReader (File.OpenRead (filename));
#endif
using (input) {
string str;
Hashtable allhash = new Hashtable (StringComparer.OrdinalIgnoreCase);

View File

@@ -0,0 +1,62 @@
//
// System.Web.EventHandlerTaskAsyncHelper.cs
//
// Author:
// Kornel Pal (kornelpal@gmail.com)
//
// Copyright (C) 2014 Kornel Pal
//
// 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.
//
using System.Threading.Tasks;
namespace System.Web
{
public sealed class EventHandlerTaskAsyncHelper
{
readonly TaskEventHandler taskEventHandler;
readonly BeginEventHandler beginEventHandler;
static readonly EndEventHandler endEventHandler = TaskAsyncResult.Wait;
public BeginEventHandler BeginEventHandler {
get { return beginEventHandler; }
}
public EndEventHandler EndEventHandler {
get { return endEventHandler; }
}
public EventHandlerTaskAsyncHelper (TaskEventHandler handler)
{
if (handler == null)
throw new ArgumentNullException ("handler");
taskEventHandler = handler;
beginEventHandler = GetAsyncResult;
}
IAsyncResult GetAsyncResult (object sender, EventArgs e, AsyncCallback callback, object state)
{
Task task = taskEventHandler (sender, e);
return TaskAsyncResult.GetAsyncResult (task, callback, state);
}
}
}

View File

@@ -80,9 +80,6 @@ using System.Web.SessionState;
using System.Web.UI;
using System.Web.Util;
#if TARGET_J2EE
using Mainsoft.Web;
#endif
namespace System.Web
{
@@ -161,15 +158,7 @@ namespace System.Web
static string binDirectory;
#if TARGET_J2EE
const string initialization_exception_key = "System.Web.HttpApplication.initialization_exception";
static Exception initialization_exception {
get { return (Exception) AppDomain.CurrentDomain.GetData (initialization_exception_key); }
set { AppDomain.CurrentDomain.SetData (initialization_exception_key, value); }
}
#else
static volatile Exception initialization_exception;
#endif
bool removeConfigurationFromCache;
bool fullInitComplete = false;
@@ -854,13 +843,11 @@ namespace System.Web
{
}
#if NET_4_0
public virtual string GetOutputCacheProviderName (HttpContext context)
{
// LAMESPEC: doesn't throw ProviderException if context is null
return OutputCache.DefaultProviderName;
}
#endif
public virtual string GetVaryByCustomString (HttpContext context, string custom)
{
@@ -925,33 +912,10 @@ namespace System.Web
internal void Tick ()
{
try {
#if TARGET_J2EE
if (context.Error is UnifyRequestException) {
Exception ex = context.Error.InnerException;
context.ClearError ();
vmw.common.TypeUtils.Throw (ex);
}
try {
#endif
if (pipeline.MoveNext ()){
if ((bool)pipeline.Current)
PipelineDone ();
}
#if TARGET_J2EE
}
catch (Exception ex) {
if (ex is ThreadAbortException &&
((ThreadAbortException) ex).ExceptionState == FlagEnd.Value)
throw;
if (context.WorkerRequest is IHttpUnifyWorkerRequest) {
context.ClearError ();
context.AddError (new UnifyRequestException (ex));
return;
}
else
throw;
}
#endif
} catch (ThreadAbortException taex) {
object obj = taex.ExceptionState;
Thread.ResetAbort ();
@@ -1202,11 +1166,9 @@ namespace System.Web
Delegate eventHandler;
if (stop_processing)
yield return true;
#if NET_4_0
HttpRequest req = context.Request;
if (req != null)
req.Validate ();
#endif
context.MapRequestHandlerDone = false;
StartTimer ("BeginRequest");
eventHandler = Events [BeginRequestEvent];
@@ -1341,10 +1303,6 @@ namespace System.Web
StopTimer ();
#if TARGET_J2EE
processHandler:
bool doProcessHandler = false;
#endif
IHttpHandler ctxHandler = context.Handler;
if (ctxHandler != null && handler != ctxHandler) {
@@ -1366,10 +1324,6 @@ namespace System.Web
} else {
must_yield = false;
handler.ProcessRequest (context);
#if TARGET_J2EE
IHttpExtendedHandler extHandler=handler as IHttpExtendedHandler;
doProcessHandler = extHandler != null && !extHandler.IsCompleted;
#endif
}
} else
throw new InvalidOperationException ("No handler for the current request.");
@@ -1380,12 +1334,6 @@ namespace System.Web
context.EndTimeoutPossible ();
}
StopTimer ();
#if TARGET_J2EE
if (doProcessHandler) {
yield return false;
goto processHandler;
}
#endif
if (must_yield)
yield return stop_processing;
else if (stop_processing)
@@ -1492,9 +1440,7 @@ namespace System.Web
autoCulture = cfg.IsAutoCulture;
appui_culture = cfg.GetUICulture ();
autoUICulture = cfg.IsAutoUICulture;
#if !TARGET_J2EE
context.StartTimeoutTimer ();
#endif
Thread th = Thread.CurrentThread;
if (app_culture != null) {
prev_app_culture = th.CurrentCulture;
@@ -1528,11 +1474,9 @@ namespace System.Web
if (prev_app_culture != null && prev_app_culture != th.CurrentCulture)
th.CurrentCulture = prev_app_culture;
#if !TARGET_J2EE
if (context == null)
context = HttpContext.Current;
context.StopTimeoutTimer ();
#endif
context.Request.ReleaseResources ();
context.Response.ReleaseResources ();
context = null;
@@ -1685,10 +1629,6 @@ namespace System.Web
void IHttpAsyncHandler.EndProcessRequest (IAsyncResult result)
{
#if TARGET_J2EE
if (result == null)
result = begin_iar;
#endif
if (!result.IsCompleted)
result.AsyncWaitHandle.WaitOne ();
begin_iar = null;

View File

@@ -38,11 +38,7 @@ using System.Threading;
using System.Web.Util;
using System.Web.Compilation;
#if TARGET_J2EE
using vmw.common;
#else
using System.CodeDom.Compiler;
#endif
namespace System.Web
{
@@ -51,27 +47,7 @@ namespace System.Web
object this_lock = new object ();
// Initialized in InitType
#if TARGET_J2EE
static HttpApplicationFactory theFactory {
get
{
HttpApplicationFactory factory = (HttpApplicationFactory)AppDomain.CurrentDomain.GetData("HttpApplicationFactory");
if (factory == null) {
lock(typeof(HttpApplicationFactory)) {
factory = (HttpApplicationFactory)AppDomain.CurrentDomain.GetData("HttpApplicationFactory");
if (factory == null) {
factory = new HttpApplicationFactory();
System.Threading.Thread.Sleep(1);
AppDomain.CurrentDomain.SetData("HttpApplicationFactory", factory);
}
}
}
return factory;
}
}
#else
static HttpApplicationFactory theFactory = new HttpApplicationFactory();
#endif
object session_end; // This is a MethodInfo
bool needs_init = true;
bool app_start_needed = true;
@@ -362,14 +338,6 @@ namespace System.Web
}
internal static HttpApplicationState ApplicationState {
#if TARGET_J2EE
get {
HttpApplicationFactory factory = theFactory;
if (factory.app_state == null)
factory.app_state = new HttpApplicationState (null, null);
return factory.app_state;
}
#else
get {
if (theFactory.app_state == null) {
HttpStaticObjectsCollection app = MakeStaticCollection (GlobalAsaxCompiler.ApplicationObjects);
@@ -379,7 +347,6 @@ namespace System.Web
}
return theFactory.app_state;
}
#endif
}
internal static Type AppType {
@@ -404,11 +371,8 @@ namespace System.Web
if (!File.Exists (app_file))
app_file = null;
}
#if NET_4_0
BuildManager.CallPreStartMethods ();
BuildManager.CompilingTopLevelAssemblies = true;
#endif
#if !TARGET_J2EE
AppResourcesCompiler ac = new AppResourcesCompiler (context);
ac.Compile ();
@@ -447,18 +411,10 @@ namespace System.Web
if (Directory.Exists (app_browsers_path)) {
app_browsers_files = Directory.GetFiles (app_browsers_path, "*.browser");
}
#endif
#if NET_4_0
BuildManager.CompilingTopLevelAssemblies = false;
#endif
app_type = BuildManager.GetPrecompiledApplicationType ();
if (app_type == null && app_file != null) {
#if TARGET_J2EE
app_file = System.Web.Util.UrlUtils.ResolveVirtualPathFromAppAbsolute("~/" + Path.GetFileName(app_file));
app_type = System.Web.J2EE.PageMapper.GetObjectType(context, app_file);
#else
app_type = BuildManager.GetCompiledType ("~/" + Path.GetFileName (app_file));
#endif
if (app_type == null) {
string msg = String.Format ("Error compiling application file ({0}).", app_file);
throw new ApplicationException (msg);
@@ -507,10 +463,6 @@ namespace System.Web
//
internal static HttpApplication GetApplication (HttpContext context)
{
#if TARGET_J2EE
if (context.ApplicationInstance!=null)
return context.ApplicationInstance;
#endif
HttpApplicationFactory factory = theFactory;
HttpApplication app = null;
if (factory.app_start_needed){

View File

@@ -38,11 +38,7 @@ namespace System.Web
{
Dictionary <string, bool> encodings;
#if NET_4_0
public
#else
internal
#endif
HttpCacheVaryByContentEncodings ()
{
encodings = new Dictionary <string, bool> ();

View File

@@ -66,11 +66,7 @@ namespace System.Web
Hashtable fields;
#if NET_4_0
public
#else
internal
#endif
HttpCacheVaryByHeaders ()
{
/* the field names are meant to be case insensitive */

View File

@@ -42,11 +42,7 @@ namespace System.Web
bool ignore_parms;
Hashtable parms;
#if NET_4_0
public
#else
internal
#endif
HttpCacheVaryByParams ()
{
/* the parameter names are meant to be case insensitive */

View File

@@ -102,9 +102,7 @@ namespace System.Web
WorkerRequest = wr;
request = new HttpRequest (WorkerRequest, this);
response = new HttpResponse (WorkerRequest, this);
#if NET_4_0
SessionStateBehavior = SessionStateBehavior.Default;
#endif
}
public HttpContext (HttpRequest request, HttpResponse response)
@@ -113,9 +111,7 @@ namespace System.Web
this.response = response;
this.request.Context = this;
this.response.Context = this;
#if NET_4_0
SessionStateBehavior = SessionStateBehavior.Default;
#endif
}
internal bool IsProcessingInclude {
@@ -636,12 +632,10 @@ namespace System.Web
req.QueryStringRaw = queryString;
}
#if NET_4_0
public void SetSessionStateBehavior (SessionStateBehavior sessionStateBehavior)
{
SessionStateBehavior = sessionStateBehavior;
}
#endif
#region internals
internal void SetSession (HttpSessionState state)
@@ -670,7 +664,6 @@ namespace System.Web
set {
config_timeout = value;
#if !TARGET_J2EE
if (timer != null) {
TimeSpan remaining = value - (DateTime.UtcNow - time_stamp);
long remaining_ms = Math.Max ((long)remaining.TotalMilliseconds, 0);
@@ -681,18 +674,14 @@ namespace System.Web
timer.Change (remaining_ms, (long)Timeout.Infinite);
}
#endif
}
}
#if NET_4_0
internal SessionStateBehavior SessionStateBehavior {
get;
private set;
}
#endif
#if !TARGET_J2EE
void TimeoutReached(object state) {
HttpRuntime.QueuePendingRequest (false);
if (Interlocked.CompareExchange (ref timeout_possible, 0, 0) == 0) {
@@ -730,7 +719,6 @@ namespace System.Web
{
Interlocked.CompareExchange (ref timeout_possible, 0, 1);
}
#endif
#endregion
}

View File

@@ -42,10 +42,6 @@ namespace System.Web
// CAS - no InheritanceDemand here as the class is sealed
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
#if TARGET_J2EE
// Cookies must be serializable to be saved in the session for J2EE portal
[Serializable]
#endif
public sealed class HttpCookie {
string path = "/";

View File

@@ -63,11 +63,7 @@ namespace System.Web
return pageTemplate;
}
}
#if NET_4_0
public
#else
internal
#endif
int WebEventCode
{
get { return webEventCode; }
@@ -307,13 +303,8 @@ namespace System.Web
void FillHtmlizedErrorValues (ExceptionPageTemplateValues values, HtmlizedException exc, ref ExceptionPageTemplateType pageType)
{
#if TARGET_J2EE
bool isParseException = false;
bool isCompileException = false;
#else
bool isParseException = exc is ParseException;
bool isCompileException = (!isParseException && exc is CompilationException);
#endif
values.Add (ExceptionPageTemplate.Template_PageTitleName, HtmlEncode (exc.Title));
values.Add (ExceptionPageTemplate.Template_DescriptionName, HtmlEncode (exc.Description));
values.Add (ExceptionPageTemplate.Template_StackTraceName, HtmlEncode (exc.StackTrace));
@@ -360,7 +351,6 @@ namespace System.Web
} else
values.Add (ExceptionPageTemplate.Template_HtmlizedExceptionSourceFileName, FormatSourceFile (exc.FileName));
#if !TARGET_J2EE
if (isCompileException) {
CompilationException cex = exc as CompilationException;
StringCollection output = cex.CompilerOutput;
@@ -381,7 +371,6 @@ namespace System.Web
values.Add (ExceptionPageTemplate.Template_HtmlizedExceptionCompilerOutputName, sb.ToString ());
}
}
#endif
}
void FillDefaultCustomErrorValues (ExceptionPageTemplateValues values)
@@ -454,11 +443,9 @@ namespace System.Web
static void FormatSource (StringBuilder builder, StringBuilder longVersion, HtmlizedException e)
{
#if !TARGET_J2EE
if (e is CompilationException)
WriteCompilationSource (builder, longVersion, e);
else
#endif
WritePageSource (builder, e);
}

View File

@@ -64,11 +64,7 @@ namespace System.Web
string encName, encValue;
if (HeaderCheckingEnabled) {
#if NET_4_0
HttpEncoder.Current.HeaderNameValueEncode (name, value, out encName, out encValue);
#else
HttpEncoder.HeaderNameValueEncode (name, value, out encName, out encValue);
#endif
} else {
encName = name;
encValue = value;

View File

@@ -45,10 +45,8 @@ using System.Web.UI;
using System.Web.Util;
using System.Globalization;
#if NET_4_0
using System.Security.Authentication.ExtendedProtection;
using System.Web.Routing;
#endif
namespace System.Web
{
@@ -80,13 +78,17 @@ namespace System.Web
string unescaped_path;
string original_path;
string path_info;
string path_info_unvalidated;
string raw_url;
string raw_url_unvalidated;
WebROCollection all_params;
WebROCollection headers;
NameValueCollection headers;
WebROCollection headers_unvalidated;
Stream input_stream;
InputFilterStream input_filter;
Stream filter;
HttpCookieCollection cookies;
HttpCookieCollection cookies_unvalidated;
string http_method;
WebROCollection form;
@@ -108,7 +110,6 @@ namespace System.Web
bool checked_cookies, checked_query_string, checked_form;
static readonly UrlMappingCollection urlMappings;
readonly static char [] queryTrimChars = {'?'};
#if NET_4_0
bool lazyFormValidation;
bool lazyQueryStringValidation;
bool inputValidationEnabled;
@@ -150,7 +151,6 @@ namespace System.Web
return chars;
}
#endif
static HttpRequest ()
{
@@ -162,7 +162,6 @@ namespace System.Web
urlMappings = null;
}
#if NET_4_0
Version validationMode = HttpRuntime.Section.RequestValidationMode;
if (validationMode >= new Version (4, 0)) {
@@ -171,7 +170,6 @@ namespace System.Web
if (!String.IsNullOrEmpty (invalidChars))
RequestPathInvalidCharacters = CharsFromList (invalidChars);
}
#endif
} catch {
// unlikely to happen
}
@@ -314,12 +312,7 @@ namespace System.Web
public HttpBrowserCapabilities Browser {
get {
if (browser_capabilities == null)
#if NET_4_0
browser_capabilities = HttpCapabilitiesBase.BrowserCapabilitiesProvider.GetBrowserCapabilities (this);
#else
browser_capabilities = (HttpBrowserCapabilities)
HttpCapabilitiesBase.GetConfigCapabilities (null, this);
#endif
return browser_capabilities;
}
@@ -440,25 +433,29 @@ namespace System.Web
}
}
public HttpCookieCollection Cookies {
internal HttpCookieCollection CookiesNoValidation {
get {
if (cookies == null) {
if (cookies_unvalidated == null) {
if (worker_request == null) {
cookies = new HttpCookieCollection ();
cookies_unvalidated = new HttpCookieCollection ();
} else {
string cookie_hv = worker_request.GetKnownRequestHeader (HttpWorkerRequest.HeaderCookie);
cookies = new HttpCookieCollection (cookie_hv);
cookies_unvalidated = new HttpCookieCollection (cookie_hv);
}
}
#if TARGET_J2EE
// For J2EE portal support we emulate cookies using the session.
GetSessionCookiesForPortal (cookies);
#endif
return cookies_unvalidated;
}
}
public HttpCookieCollection Cookies {
get {
if (cookies == null) {
cookies = CookiesNoValidation;
}
bool needValidation = validate_cookies;
#if NET_4_0
needValidation |= validateRequestNewMode;
#endif
if (needValidation && !checked_cookies) {
// Setting this before calling the validator prevents
// possible endless recursion
@@ -479,11 +476,9 @@ namespace System.Web
return FilePath;
}
}
#if NET_4_0
public string CurrentExecutionFilePathExtension {
get { return global::System.IO.Path.GetExtension (CurrentExecutionFilePath); }
}
#endif
public string AppRelativeCurrentExecutionFilePath {
get {
return VirtualPathUtility.ToAppRelative (CurrentExecutionFilePath);
@@ -649,11 +644,7 @@ namespace System.Web
//
// Loads the form data from on a application/x-www-form-urlencoded post
//
#if TARGET_J2EE
void RawLoadWwwForm ()
#else
void LoadWwwForm ()
#endif
{
using (Stream input = GetSubStream (InputStream)) {
using (StreamReader s = new StreamReader (input, ContentEncoding)) {
@@ -718,7 +709,6 @@ namespace System.Web
public NameValueCollection Form {
get {
NameValueCollection form = FormUnvalidated;
#if NET_4_0
if (validateRequestNewMode && !checked_form) {
if (!lazyFormValidation) {
// Setting this before calling the validator prevents
@@ -727,7 +717,6 @@ namespace System.Web
ValidateNameValueCollection ("Form", form, RequestValidationSource.Form);
}
} else
#endif
if (validate_form && !checked_form){
checked_form = true;
ValidateNameValueCollection ("Form", form);
@@ -737,11 +726,20 @@ namespace System.Web
}
}
internal NameValueCollection HeadersNoValidation {
get {
if (headers_unvalidated == null) {
headers_unvalidated = new HeadersCollection (this);
}
return headers_unvalidated;
}
}
public NameValueCollection Headers {
get {
if (headers == null) {
headers = new HeadersCollection (this);
#if NET_4_0
headers = HeadersNoValidation;
if (validateRequestNewMode) {
RequestValidator validator = RequestValidator.Current;
int validationFailureIndex;
@@ -753,7 +751,6 @@ namespace System.Web
ThrowValidationException ("Headers", hkey, value);
}
}
#endif
}
return headers;
@@ -966,7 +963,6 @@ namespace System.Web
} catch {}
}
}
#if NET_4_0
public RequestContext RequestContext {
get {
if (requestContext == null)
@@ -1136,7 +1132,6 @@ namespace System.Web
// TODO: explicitly support the async methods if there is a convenient way of doing it
//
}
#endif
public Stream InputStream {
get {
if (input_stream == null)
@@ -1211,7 +1206,6 @@ namespace System.Web
get {
if (unescaped_path == null) {
unescaped_path = PathNoValidation;
#if NET_4_0
if (validateRequestNewMode) {
RequestValidator validator = RequestValidator.Current;
int validationFailureIndex;
@@ -1219,20 +1213,29 @@ namespace System.Web
if (!validator.IsValidRequestString (HttpContext.Current, unescaped_path, RequestValidationSource.Path, null, out validationFailureIndex))
ThrowValidationException ("Path", "Path", unescaped_path);
}
#endif
}
return unescaped_path;
}
}
internal string PathInfoNoValidation {
get {
if (path_info_unvalidated == null) {
if (worker_request == null)
return String.Empty;
path_info_unvalidated = worker_request.GetPathInfo () ?? String.Empty;
}
return path_info_unvalidated;
}
}
public string PathInfo {
get {
if (path_info == null) {
if (worker_request == null)
return String.Empty;
path_info = worker_request.GetPathInfo () ?? String.Empty;
#if NET_4_0
path_info = PathInfoNoValidation;
if (validateRequestNewMode) {
RequestValidator validator = RequestValidator.Current;
int validationFailureIndex;
@@ -1240,7 +1243,6 @@ namespace System.Web
if (!validator.IsValidRequestString (HttpContext.Current, path_info, RequestValidationSource.PathInfo, null, out validationFailureIndex))
ThrowValidationException ("PathInfo", "PathInfo", path_info);
}
#endif
}
return path_info;
@@ -1314,7 +1316,6 @@ namespace System.Web
public NameValueCollection QueryString {
get {
NameValueCollection query_string_nvc = QueryStringUnvalidated;
#if NET_4_0
if (validateRequestNewMode && !checked_query_string) {
if (!lazyQueryStringValidation) {
// Setting this before calling the validator prevents
@@ -1323,7 +1324,6 @@ namespace System.Web
ValidateNameValueCollection ("QueryString", query_string_nvc, RequestValidationSource.QueryString);
}
} else
#endif
if (validate_query_string && !checked_query_string) {
// Setting this before calling the validator prevents
// possible endless recursion
@@ -1335,17 +1335,26 @@ namespace System.Web
}
}
internal string RawUrlUnvalidated {
get {
if (raw_url_unvalidated == null) {
if (worker_request != null)
raw_url_unvalidated = worker_request.GetRawUrl ();
else
raw_url_unvalidated = UrlComponents.Path + UrlComponents.Query;
if (raw_url_unvalidated == null)
raw_url_unvalidated = String.Empty;
}
return raw_url_unvalidated;
}
}
public string RawUrl {
get {
if (raw_url == null) {
if (worker_request != null)
raw_url = worker_request.GetRawUrl ();
else
raw_url = UrlComponents.Path + UrlComponents.Query;
if (raw_url == null)
raw_url = String.Empty;
#if NET_4_0
raw_url = RawUrlUnvalidated;
if (validateRequestNewMode) {
RequestValidator validator = RequestValidator.Current;
int validationFailureIndex;
@@ -1353,7 +1362,6 @@ namespace System.Web
if (!validator.IsValidRequestString (HttpContext.Current, raw_url, RequestValidationSource.RawUrl, null, out validationFailureIndex))
ThrowValidationException ("RawUrl", "RawUrl", raw_url);
}
#endif
}
return raw_url;
@@ -1398,6 +1406,24 @@ namespace System.Web
}
}
public UnvalidatedRequestValues Unvalidated {
get {
var vals = new UnvalidatedRequestValues ();
vals.Cookies = CookiesNoValidation;
vals.Files = Files;
vals.Form = FormUnvalidated;
vals.Headers = HeadersNoValidation;
vals.Path = PathNoValidation;
vals.PathInfo = PathInfoNoValidation;
vals.QueryString = QueryStringUnvalidated;
vals.RawUrl = RawUrlUnvalidated;
vals.Url = Url;
return vals;
}
}
public Uri Url {
get {
if (cached_url == null) {
@@ -1614,11 +1640,8 @@ namespace System.Web
validate_cookies = true;
validate_query_string = true;
validate_form = true;
#if NET_4_0
inputValidationEnabled = true;
#endif
}
#if NET_4_0
internal void Validate ()
{
var cfg = HttpRuntime.Section;
@@ -1646,7 +1669,6 @@ namespace System.Web
if (validateRequestNewMode)
ValidateInput ();
}
#endif
#region internal routines
internal string ClientTarget {
get {
@@ -1709,7 +1731,6 @@ namespace System.Web
string path = UrlComponents.Path;
UrlComponents.Path = path + PathInfo;
}
#if NET_4_0
internal void SetFormCollection (WebROCollection coll, bool lazyValidation)
{
if (coll == null)
@@ -1725,7 +1746,6 @@ namespace System.Web
query_string_nvc = coll;
lazyQueryStringValidation = lazyValidation;
}
#endif
// Headers is ReadOnly, so we need this hack for cookie-less sessions.
internal void SetHeader (string name, string value)
{
@@ -1790,7 +1810,6 @@ namespace System.Web
ThrowValidationException (name, key, val);
}
}
#if NET_4_0
static void ValidateNameValueCollection (string name, NameValueCollection coll, RequestValidationSource source)
{
if (coll == null)
@@ -1818,7 +1837,6 @@ namespace System.Web
{
throw new PlatformNotSupportedException ("This method is not supported.");
}
#endif
static void ValidateCookieCollection (HttpCookieCollection cookies)
{
if (cookies == null)
@@ -1826,11 +1844,9 @@ namespace System.Web
int size = cookies.Count;
HttpCookie cookie;
#if NET_4_0
RequestValidator validator = RequestValidator.Current;
int validationFailureIndex;
HttpContext context = HttpContext.Current;
#endif
bool invalid;
for (int i = 0 ; i < size ; i++) {
@@ -1842,11 +1858,9 @@ namespace System.Web
string name = cookie.Name;
if (!String.IsNullOrEmpty (value)) {
#if NET_4_0
if (validateRequestNewMode)
invalid = !validator.IsValidRequestString (context, value, RequestValidationSource.Cookies, name, out validationFailureIndex);
else
#endif
invalid = IsInvalidString (value);
if (invalid)
@@ -1866,7 +1880,6 @@ namespace System.Web
throw new HttpRequestValidationException (msg);
}
#if NET_4_0
internal static void ValidateString (string key, string value, RequestValidationSource source)
{
if (String.IsNullOrEmpty (value))
@@ -1877,7 +1890,6 @@ namespace System.Web
if (IsInvalidString (value, out ignore))
ThrowValidationException (source.ToString (), key, value);
}
#endif
internal static bool IsInvalidString (string val)
{
#pragma warning disable 219

View File

@@ -43,9 +43,7 @@ using System.Security.Permissions;
using System.Web.Hosting;
using System.Web.SessionState;
#if NET_4_0
using System.Web.Routing;
#endif
namespace System.Web
{
@@ -126,7 +124,6 @@ namespace System.Web
WorkerRequest = worker_request;
this.context = context;
#if !TARGET_J2EE
if (worker_request != null && worker_request.GetHttpVersion () == "HTTP/1.1") {
string gi = worker_request.GetServerVariable ("GATEWAY_INTERFACE");
use_chunked = (String.IsNullOrEmpty (gi) ||
@@ -134,7 +131,6 @@ namespace System.Web
} else {
use_chunked = false;
}
#endif
writer = new HttpWriter (this);
}
@@ -354,9 +350,7 @@ namespace System.Web
get {
return writer;
}
#if NET_4_0
set { writer = value; }
#endif
}
public Stream OutputStream {
@@ -400,12 +394,10 @@ namespace System.Web
set;
}
#if NET_4_5
public bool SuppressFormsAuthenticationRedirect {
get;
set;
}
#endif
public bool TrySkipIisCustomErrors {
get;
@@ -516,26 +508,22 @@ namespace System.Web
{
if (headers_sent)
throw new HttpException ("Headers have been already sent");
#if !TARGET_J2EE
if (String.Compare (name, "content-length", StringComparison.OrdinalIgnoreCase) == 0){
content_length = (long) UInt64.Parse (value);
use_chunked = false;
return;
}
#endif
if (String.Compare (name, "content-type", StringComparison.OrdinalIgnoreCase) == 0){
ContentType = value;
return;
}
#if !TARGET_J2EE
if (String.Compare (name, "transfer-encoding", StringComparison.OrdinalIgnoreCase) == 0){
transfer_encoding = value;
use_chunked = false;
return;
}
#endif
if (String.Compare (name, "cache-control", StringComparison.OrdinalIgnoreCase) == 0){
user_cache_control = value;
@@ -664,7 +652,6 @@ namespace System.Web
// X-AspNet-Version
void AddHeadersNoCache (NameValueCollection write_headers, bool final_flush)
{
#if !TARGET_J2EE
//
// Transfer-Encoding
//
@@ -672,11 +659,9 @@ namespace System.Web
write_headers.Add ("Transfer-Encoding", "chunked");
else if (transfer_encoding != null)
write_headers.Add ("Transfer-Encoding", transfer_encoding);
#endif
if (redirect_location != null)
write_headers.Add ("Location", redirect_location);
#if !TARGET_J2EE
string vh = VersionHeader;
if (vh != null)
write_headers.Add ("X-AspNet-Version", vh);
@@ -714,7 +699,6 @@ namespace System.Web
write_headers.Add (HttpWorkerRequest.GetKnownResponseHeaderName (HttpWorkerRequest.HeaderConnection), "close");
}
}
#endif
//
// Cache Control, the cache policy takes precedence over the cache_control property.
@@ -743,10 +727,6 @@ namespace System.Web
int n = cookies.Count;
for (int i = 0; i < n; i++)
write_headers.Add ("Set-Cookie", cookies.Get (i).GetCookieHeaderValue ());
#if TARGET_J2EE
// For J2EE Portal support emulate cookies by storing them in the session.
context.Request.SetSessionCookiesForPortal (cookies);
#endif
}
}
@@ -926,7 +906,6 @@ namespace System.Web
{
Redirect (url, endResponse, 302);
}
#if NET_4_0
public void RedirectPermanent (string url)
{
RedirectPermanent (url, true);
@@ -1014,7 +993,6 @@ namespace System.Web
OutputCache.RemoveFromProvider (path, providerName);
}
#endif
public static void RemoveOutputCacheItem (string path)
{
if (path == null)
@@ -1026,19 +1004,7 @@ namespace System.Web
if (path [0] != '/')
throw new ArgumentException ("'" + path + "' is not an absolute virtual path.");
#if NET_4_0
RemoveOutputCacheItem (path, OutputCache.DefaultProviderName);
#else
HttpContext context = HttpContext.Current;
HttpApplication app_instance = context != null ? context.ApplicationInstance : null;
HttpModuleCollection modules = app_instance != null ? app_instance.Modules : null;
OutputCacheModule ocm = modules != null ? modules.Get ("OutputCache") as OutputCacheModule : null;
OutputCacheProvider internalProvider = ocm != null ? ocm.InternalProvider : null;
if (internalProvider == null)
return;
internalProvider.Remove (path);
#endif
}
public void SetCookie (HttpCookie cookie)
@@ -1049,22 +1015,18 @@ namespace System.Web
public void Write (char ch)
{
TextWriter writer = Output;
#if NET_4_0
// Emulating .NET
if (writer == null)
throw new NullReferenceException (".NET 4.0 emulation. A null value was found where an object was required.");
#endif
writer.Write (ch);
}
public void Write (object obj)
{
TextWriter writer = Output;
#if NET_4_0
// Emulating .NET
if (writer == null)
throw new NullReferenceException (".NET 4.0 emulation. A null value was found where an object was required.");
#endif
if (obj == null)
return;
@@ -1074,22 +1036,18 @@ namespace System.Web
public void Write (string s)
{
TextWriter writer = Output;
#if NET_4_0
// Emulating .NET
if (writer == null)
throw new NullReferenceException (".NET 4.0 emulation. A null value was found where an object was required.");
#endif
writer.Write (s);
}
public void Write (char [] buffer, int index, int count)
{
TextWriter writer = Output;
#if NET_4_0
// Emulating .NET
if (writer == null)
throw new NullReferenceException (".NET 4.0 emulation. A null value was found where an object was required.");
#endif
writer.Write (buffer, index, count);
}
@@ -1379,9 +1337,6 @@ namespace System.Web
}
}
#if TARGET_J2EE
public
#endif
static class FlagEnd
{
public static readonly object Value = new object ();

View File

@@ -43,11 +43,7 @@ namespace System.Web
get { return headerValue; }
set {
string hname, hvalue;
#if NET_4_0
HttpEncoder.Current.HeaderNameValueEncode (null, value, out hname, out hvalue);
#else
HttpEncoder.HeaderNameValueEncode (null, value, out hname, out hvalue);
#endif
headerValue = hvalue;
}
}
@@ -92,11 +88,7 @@ namespace System.Web
get { return headerName; }
set {
string hname, hvalue;
#if NET_4_0
HttpEncoder.Current.HeaderNameValueEncode (value, null, out hname, out hvalue);
#else
HttpEncoder.HeaderNameValueEncode (value, null, out hname, out hvalue);
#endif
headerName = hname;
}
}

View File

@@ -46,12 +46,8 @@ using System.Web.UI;
using System.Web.Util;
using Mono.Web.Util;
using System.Threading;
#if TARGET_J2EE
using Mainsoft.Web;
#else
using System.CodeDom.Compiler;
using System.Web.Compilation;
#endif
namespace System.Web
{
@@ -61,53 +57,6 @@ namespace System.Web
{
static bool domainUnloading;
static SplitOrderedList <string, string> registeredAssemblies;
#if TARGET_J2EE
static QueueManager queue_manager { get { return _runtime._queue_manager; } }
static TraceManager trace_manager { get { return _runtime._trace_manager; } }
static Cache cache { get { return _runtime._cache; } }
static Cache internalCache { get { return _runtime._internalCache; } }
static WaitCallback do_RealProcessRequest;
QueueManager _queue_manager;
TraceManager _trace_manager;
Cache _cache;
Cache _internalCache;
public HttpRuntime ()
{
WebConfigurationManager.Init ();
_queue_manager = new QueueManager ();
_trace_manager = new TraceManager ();
_cache = new Cache ();
_internalCache = new Cache();
_internalCache.DependencyCache = _cache;
}
static HttpRuntime _runtimeInstance {
get {
HttpRuntime runtime = (HttpRuntime) AppDomain.CurrentDomain.GetData ("HttpRuntime");
if (runtime == null)
lock (typeof (HttpRuntime)) {
runtime = (HttpRuntime) AppDomain.CurrentDomain.GetData ("HttpRuntime");
if (runtime == null) {
runtime = new HttpRuntime ();
AppDomain.CurrentDomain.SetData ("HttpRuntime", runtime);
}
}
return runtime;
}
}
static HttpRuntime _runtime
{
get
{
if (HttpContext.Current != null)
return HttpContext.Current.HttpRuntimeInstance;
else
return _runtimeInstance;
}
}
#else
static QueueManager queue_manager;
static TraceManager trace_manager;
static Cache cache;
@@ -125,11 +74,9 @@ namespace System.Web
{
}
#endif
static HttpRuntime ()
{
#if !TARGET_J2EE
firstRun = true;
try {
@@ -167,7 +114,6 @@ namespace System.Web
cache = new Cache ();
internalCache = new Cache ();
internalCache.DependencyCache = internalCache;
#endif
do_RealProcessRequest = new WaitCallback (state => {
try {
RealProcessRequest (state);
@@ -326,7 +272,6 @@ namespace System.Web
public static bool UsingIntegratedPipeline { get { return false; } }
#if NET_4_5
public static Version IISVersion {
get {
// Null means not hosted by IIS
@@ -339,7 +284,6 @@ namespace System.Web
return runtime_section.TargetFramework;
}
}
#endif
[SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
public static void Close ()
@@ -361,7 +305,6 @@ namespace System.Web
return next;
}
#if !TARGET_J2EE
static readonly string[] app_offline_files = {"app_offline.htm", "App_Offline.htm", "APP_OFFLINE.HTM"};
static string app_offline_file;
@@ -468,7 +411,6 @@ namespace System.Web
SetOfflineMode (true, offlineFile);
}
}
#endif
static void RealProcessRequest (object o)
{
@@ -488,13 +430,6 @@ namespace System.Web
static void Process (HttpWorkerRequest req)
{
bool error = false;
#if TARGET_J2EE
HttpContext context = HttpContext.Current;
if (context == null)
context = new HttpContext (req);
else
context.SetWorkerRequest (req);
#else
if (firstRun) {
firstRun = false;
if (initialException != null) {
@@ -504,12 +439,9 @@ namespace System.Web
SetupOfflineWatch ();
}
HttpContext context = new HttpContext (req);
#endif
HttpContext.Current = context;
#if !TARGET_J2EE
if (AppIsOffline (context))
return;
#endif
//
// Get application instance (create or reuse an instance of the correct class)
@@ -536,26 +468,10 @@ namespace System.Web
// Ask application to service the request
//
#if TARGET_J2EE
IHttpAsyncHandler ihah = app;
if (context.Handler == null)
ihah.BeginProcessRequest (context, new AsyncCallback (request_processed), context);
else
app.Tick ();
//ihh.ProcessRequest (context);
IHttpExtendedHandler extHandler = context.Handler as IHttpExtendedHandler;
if (extHandler != null && !extHandler.IsCompleted)
return;
if (context.Error is UnifyRequestException)
return;
ihah.EndProcessRequest (null);
#else
IHttpHandler ihh = app;
// IAsyncResult appiar = ihah.BeginProcessRequest (context, new AsyncCallback (request_processed), context);
// ihah.EndProcessRequest (appiar);
ihh.ProcessRequest (context);
#endif
HttpApplicationFactory.Recycle (app);
}
@@ -588,18 +504,6 @@ namespace System.Web
RealProcessRequest (request);
}
#if TARGET_J2EE
//
// Callback to be invoked by IHttpAsyncHandler.BeginProcessRequest
//
static void request_processed (IAsyncResult iar)
{
HttpContext context = (HttpContext) iar.AsyncState;
context.Request.ReleaseResources ();
context.Response.ReleaseResources ();
}
#endif
//
// Called when we are shutting down or we need to reload an application
@@ -640,11 +544,7 @@ namespace System.Web
static void DoUnload ()
{
#if TARGET_J2EE
// No unload support for appdomains under Grasshopper
#else
AppDomain.Unload (AppDomain.CurrentDomain);
#endif
}
static string content503 = "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n" +
@@ -694,7 +594,6 @@ namespace System.Web
return null;
}
#if !TARGET_J2EE
static internal void WritePreservationFile (Assembly asm, string genericNameBase)
{
if (asm == null)
@@ -767,7 +666,6 @@ namespace System.Web
assemblyMappingEnabled = enable;
}
}
#endif // #if !TARGET_J2EE
internal static TraceManager TraceManager {
get {

View File

@@ -128,13 +128,11 @@ namespace System.Web
internal void Execute (IHttpHandler handler, TextWriter writer, bool preserveForm, string exePath, string queryString, bool isTransfer, bool isInclude)
{
#if !TARGET_J2EE
// If the target handler is not Page, the transfer must not occur.
// InTransit == true means we're being called from Transfer
bool is_static = (handler is StaticFileHandler);
if (isTransfer && !(handler is Page) && !is_static)
throw new HttpException ("Transfer is only allowed to .aspx and static files");
#endif
HttpRequest request = context.Request;
string oldQuery = request.QueryStringRaw;

View File

@@ -0,0 +1,59 @@
//
// System.Web.HttpTaskAsyncHandler.cs
//
// Author:
// Kornel Pal (kornelpal@gmail.com)
//
// Copyright (C) 2014 Kornel Pal
//
// 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.
//
using System.ComponentModel;
using System.Threading.Tasks;
namespace System.Web
{
public abstract class HttpTaskAsyncHandler : IHttpAsyncHandler, IHttpHandler
{
public virtual bool IsReusable {
get { return false; }
}
[EditorBrowsable (EditorBrowsableState.Never)]
public virtual void ProcessRequest (HttpContext context)
{
throw new NotSupportedException ("This handler cannot be executed synchronously.");
}
public abstract Task ProcessRequestAsync (HttpContext context);
IAsyncResult IHttpAsyncHandler.BeginProcessRequest (HttpContext context, AsyncCallback cb, object extraData)
{
Task task = ProcessRequestAsync (context);
return TaskAsyncResult.GetAsyncResult (task, cb, extraData);
}
void IHttpAsyncHandler.EndProcessRequest (IAsyncResult result)
{
TaskAsyncResult.Wait (result);
}
}
}

View File

@@ -77,22 +77,13 @@ namespace System.Web {
public static void HtmlAttributeEncode (string s, TextWriter output)
{
if (output == null) {
#if NET_4_0
throw new ArgumentNullException ("output");
#else
throw new NullReferenceException (".NET emulation");
#endif
}
#if NET_4_0
HttpEncoder.Current.HtmlAttributeEncode (s, output);
#else
output.Write (HttpEncoder.HtmlAttributeEncode (s));
#endif
}
public static string HtmlAttributeEncode (string s)
{
#if NET_4_0
if (s == null)
return null;
@@ -100,9 +91,6 @@ namespace System.Web {
HttpEncoder.Current.HtmlAttributeEncode (s, sw);
return sw.ToString ();
}
#else
return HttpEncoder.HtmlAttributeEncode (s);
#endif
}
public static string UrlDecode (string str)
@@ -434,11 +422,7 @@ namespace System.Web {
{
if (bytes == null)
return null;
#if NET_4_0
return HttpEncoder.Current.UrlEncode (bytes, offset, count);
#else
return HttpEncoder.UrlEncodeToBytes (bytes, offset, count);
#endif
}
public static string UrlEncodeUnicode (string str)
@@ -471,7 +455,6 @@ namespace System.Web {
/// <returns>The decoded text.</returns>
public static string HtmlDecode (string s)
{
#if NET_4_0
if (s == null)
return null;
@@ -479,9 +462,6 @@ namespace System.Web {
HttpEncoder.Current.HtmlDecode (s, sw);
return sw.ToString ();
}
#else
return HttpEncoder.HtmlDecode (s);
#endif
}
/// <summary>
@@ -492,25 +472,16 @@ namespace System.Web {
public static void HtmlDecode(string s, TextWriter output)
{
if (output == null) {
#if NET_4_0
throw new ArgumentNullException ("output");
#else
throw new NullReferenceException (".NET emulation");
#endif
}
if (!String.IsNullOrEmpty (s)) {
#if NET_4_0
HttpEncoder.Current.HtmlDecode (s, output);
#else
output.Write (HttpEncoder.HtmlDecode (s));
#endif
}
}
public static string HtmlEncode (string s)
{
#if NET_4_0
if (s == null)
return null;
@@ -518,9 +489,6 @@ namespace System.Web {
HttpEncoder.Current.HtmlEncode (s, sw);
return sw.ToString ();
}
#else
return HttpEncoder.HtmlEncode (s);
#endif
}
/// <summary>
@@ -531,22 +499,13 @@ namespace System.Web {
public static void HtmlEncode(string s, TextWriter output)
{
if (output == null) {
#if NET_4_0
throw new ArgumentNullException ("output");
#else
throw new NullReferenceException (".NET emulation");
#endif
}
if (!String.IsNullOrEmpty (s)) {
#if NET_4_0
HttpEncoder.Current.HtmlEncode (s, output);
#else
output.Write (HttpEncoder.HtmlEncode (s));
#endif
}
}
#if NET_4_0
public static string HtmlEncode (object value)
{
if (value == null)
@@ -634,14 +593,9 @@ namespace System.Web {
return sb.ToString ();
}
#endif
public static string UrlPathEncode (string s)
{
#if NET_4_0
return HttpEncoder.Current.UrlPathEncode (s);
#else
return HttpEncoder.UrlPathEncode (s);
#endif
}
public static NameValueCollection ParseQueryString (string query)

View File

@@ -31,10 +31,6 @@ using System.Security.Permissions;
namespace System.Web
{
#if !NET_4_0
[AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal),
AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
#endif
public interface IPartitionResolver
{
void Initialize ();

Some files were not shown because too many files have changed in this diff Show More