mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 19:10:23 -10:00
Compare commits
31
Commits
xcode8
...
mono-1-1-8-3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9228135a7 | ||
|
|
08ebd4f51c | ||
|
|
199b47b201 | ||
|
|
0cb7daa3b3 | ||
|
|
cbe4d07f35 | ||
|
|
442bd78945 | ||
|
|
4b772bd8a9 | ||
|
|
97f8625d10 | ||
|
|
6117e7c88a | ||
|
|
5af44bea68 | ||
|
|
b3f1896578 | ||
|
|
d6de82f936 | ||
|
|
a0a5d6712c | ||
|
|
962d6a7045 | ||
|
|
926c733cfc | ||
|
|
9fb62d3e4a | ||
|
|
8a9308f385 | ||
|
|
e9750b6f7e | ||
|
|
e2474ba72b | ||
|
|
e097b8cbbf | ||
|
|
9e4af11a75 | ||
|
|
cfd654b338 | ||
|
|
6706852461 | ||
|
|
9d9961ad92 | ||
|
|
1db9a3a7c2 | ||
|
|
6f3a534e4a | ||
|
|
9db3450257 | ||
|
|
f79948e57e | ||
|
|
38ba17f8fb | ||
|
|
467094bf19 | ||
|
|
045f78538a |
No files matched your search
+14
-15
@@ -6,7 +6,7 @@ AC_CANONICAL_SYSTEM
|
||||
m4_ifdef([_A][M_PROG_TAR],[_A][M_SET_OPTION([tar-ustar])])
|
||||
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AM_INIT_AUTOMAKE(mono,1.1.8)
|
||||
AM_INIT_AUTOMAKE(mono,1.1.8.3)
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
AC_PROG_LN_S
|
||||
@@ -1535,24 +1535,23 @@ case "$host" in
|
||||
LIBC="libc.so"
|
||||
INTL="libintl.so"
|
||||
;;
|
||||
esac
|
||||
|
||||
if test "x$X11" = "xlibX11.so"; then
|
||||
*-*-*linux*)
|
||||
AC_PATH_X
|
||||
AC_PATH_PROG(OBJDUMP, objdump, no)
|
||||
if test "x$no_x" != "xyes"; then
|
||||
if test "x$OBJDUMP" != xno; then
|
||||
AC_MSG_CHECKING(for the soname of libX11.so)
|
||||
X11=$($OBJDUMP -p $x_libraries/libX11.so | $AWK '/SONAME/ {print $2}')
|
||||
AC_MSG_RESULT($X11)
|
||||
else
|
||||
AC_MSG_WARN([Could not find objdump. WinForms will not work if you install this mono on a box without the X -devel package.]);
|
||||
fi
|
||||
AC_MSG_CHECKING(for the soname of libX11.so)
|
||||
for i in $x_libraries /usr/lib /usr/lib64; do
|
||||
for r in 4 5 6; do
|
||||
if test -f $i/libX11.so.$r; then
|
||||
X11=libX11.so.$r
|
||||
AC_MSG_RESULT($X11)
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
else
|
||||
if test "x$X11" = "xlibX11.so"; then
|
||||
AC_MSG_WARN([Could not find X development libs. Do you have the -devel package installed? WinForms may not work...]);
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_SUBST(libsuffix)
|
||||
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
2005-07-05 Ben Maurer <[email protected]>
|
||||
|
||||
* pthread_stop_world.c (pthread_start_world, _GC_suspend_handler):
|
||||
Make sure that all threads have been started before releasing the
|
||||
GC_lock. Otherwise, the thread table can be corrupt in the restart
|
||||
handler, causing deadlocks and segfaults.
|
||||
|
||||
2005-06-21 Ben Maurer <[email protected]>
|
||||
|
||||
* configure.host: remove -fexceptions, messes up with nptl
|
||||
includes, as on fc4.
|
||||
|
||||
2005-06-17 Zoltan Varga <[email protected]>
|
||||
|
||||
* pthread_support.c: Workaround gcc-3.3 compiler bug.
|
||||
|
||||
2005-05-26 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* libgc.vcproj: Project file for libgc.
|
||||
|
||||
@@ -21,10 +21,7 @@
|
||||
|
||||
gc_cflags=""
|
||||
|
||||
# We should set -fexceptions if we are using gcc and might be used
|
||||
# inside something like gcj. This is the zeroth approximation:
|
||||
if test :"$GCC": = :yes: ; then
|
||||
gc_cflags="${gc_cflags} -fexceptions"
|
||||
else
|
||||
case "$host" in
|
||||
hppa*-*-hpux* )
|
||||
|
||||
@@ -163,6 +163,12 @@ static void _GC_suspend_handler(int sig)
|
||||
/* to accidentally leave a RESTART signal pending, thus causing us to */
|
||||
/* continue prematurely in a future round. */
|
||||
|
||||
/* Tell the thread that wants to start the world that this */
|
||||
/* thread has been started. Note that sem_post() is */
|
||||
/* the only async-signal-safe primitive in LinuxThreads. */
|
||||
sem_post(&GC_suspend_ack_sem);
|
||||
|
||||
|
||||
#if DEBUG_THREADS
|
||||
GC_printf1("Continuing 0x%lx\n", my_thread);
|
||||
#endif
|
||||
@@ -421,6 +427,7 @@ static void pthread_start_world()
|
||||
register GC_thread p;
|
||||
register int n_live_threads = 0;
|
||||
register int result;
|
||||
int code;
|
||||
|
||||
# if DEBUG_THREADS
|
||||
GC_printf0("World starting\n");
|
||||
@@ -450,6 +457,20 @@ static void pthread_start_world()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG_THREADS
|
||||
GC_printf0 ("All threads signaled");
|
||||
#endif
|
||||
|
||||
for (i = 0; i < n_live_threads; i++) {
|
||||
while (0 != (code = sem_wait(&GC_suspend_ack_sem))) {
|
||||
if (errno != EINTR) {
|
||||
GC_err_printf1("Sem_wait returned %ld\n", (unsigned long)code);
|
||||
ABORT("sem_wait for handler failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG_THREADS
|
||||
GC_printf0("World started\n");
|
||||
#endif
|
||||
|
||||
@@ -556,6 +556,27 @@ GC_bool GC_thr_initialized = FALSE;
|
||||
|
||||
volatile GC_thread GC_threads[THREAD_TABLE_SZ];
|
||||
|
||||
/*
|
||||
* gcc-3.3.6 miscompiles the &GC_thread_key+sizeof(&GC_thread_key) expression so
|
||||
* put it into a separate function.
|
||||
*/
|
||||
# ifdef __GNUC__
|
||||
static __attribute__((noinline)) unsigned char* get_gc_thread_key_addr GC_PROTO((void))
|
||||
{
|
||||
return (unsigned char*)&GC_thread_key;
|
||||
}
|
||||
|
||||
void GC_push_thread_structures GC_PROTO((void))
|
||||
{
|
||||
GC_push_all((ptr_t)(GC_threads), (ptr_t)(GC_threads)+sizeof(GC_threads));
|
||||
# if defined(THREAD_LOCAL_ALLOC) && !defined(DBG_HDRS_ALL)
|
||||
GC_push_all((ptr_t)get_gc_thread_key_addr(),
|
||||
(ptr_t)(get_gc_thread_key_addr())+sizeof(&GC_thread_key));
|
||||
# endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void GC_push_thread_structures GC_PROTO((void))
|
||||
{
|
||||
GC_push_all((ptr_t)(GC_threads), (ptr_t)(GC_threads)+sizeof(GC_threads));
|
||||
@@ -565,6 +586,8 @@ void GC_push_thread_structures GC_PROTO((void))
|
||||
# endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef THREAD_LOCAL_ALLOC
|
||||
/* We must explicitly mark ptrfree and gcj free lists, since the free */
|
||||
/* list links wouldn't otherwise be found. We also set them in the */
|
||||
|
||||
@@ -57,13 +57,6 @@ namespace System.Web.Caching {
|
||||
_objExpires = new CacheExpires (this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal method to create a enumerator and over all public
|
||||
/// items in the cache and is used by GetEnumerator method.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// Returns IDictionaryEnumerator that contains all public items in the cache
|
||||
/// </returns>
|
||||
private IDictionaryEnumerator CreateEnumerator () {
|
||||
Hashtable objTable;
|
||||
|
||||
@@ -101,42 +94,6 @@ namespace System.Web.Caching {
|
||||
GetEntry (strKey);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified item to the Cache object with
|
||||
/// dependencies, expiration and priority policies, and a
|
||||
/// delegate you can use to notify your application when the
|
||||
/// inserted item is removed from the Cache.
|
||||
/// </summary>
|
||||
/// <param name="strKey">The cache key used to reference the item.</param>
|
||||
/// <param name="objItem">The item to be added to the cache.</param>
|
||||
/// <param name="objDependency">
|
||||
/// The file or cache key dependencies for the item. When any
|
||||
/// dependency changes, the object becomes invalid and is removed
|
||||
/// from the cache. If there are no dependencies, this paramter
|
||||
/// contains a null reference.
|
||||
/// </param>
|
||||
/// <param name="absolutExpiration">
|
||||
/// The time at which the added object expires and is removed from the cache.
|
||||
/// </param>
|
||||
/// <param name="slidingExpiration">
|
||||
/// The interval between the time the added object was last
|
||||
/// accessed and when that object expires. If this value is the
|
||||
/// equivalent of 20 minutes, the object expires and is removed
|
||||
/// from the cache 20 minutes after it is last accessed.
|
||||
/// </param>
|
||||
/// <param name="enumPriority">
|
||||
/// The relative cost of the object, as expressed by the
|
||||
/// CacheItemPriority enumeration. The cache uses this value when
|
||||
/// it evicts objects; objects with a lower cost are removed from
|
||||
/// the cache before objects with a higher cost.
|
||||
/// </param>
|
||||
/// <param name="eventRemoveCallback">
|
||||
/// A delegate that, if provided, is called when an object is
|
||||
/// removed from the cache. You can use this to notify
|
||||
/// applications when their objects are deleted from the
|
||||
/// cache.
|
||||
/// </param>
|
||||
/// <returns>The Object item added to the Cache.</returns>
|
||||
public object Add (string strKey, object objItem, CacheDependency objDependency,
|
||||
DateTime absolutExpiration, TimeSpan slidingExpiration,
|
||||
CacheItemPriority enumPriority, CacheItemRemovedCallback eventRemoveCallback) {
|
||||
@@ -171,16 +128,16 @@ namespace System.Web.Caching {
|
||||
|
||||
// todo: check decay and make up the minHit range
|
||||
|
||||
objEntry = new CacheEntry (this,
|
||||
strKey,
|
||||
objItem,
|
||||
objDependency,
|
||||
eventRemoveCallback,
|
||||
absolutExpiration,
|
||||
slidingExpiration,
|
||||
longHitRange,
|
||||
pub,
|
||||
enumPriority);
|
||||
objEntry = new CacheEntry ( this,
|
||||
strKey,
|
||||
objItem,
|
||||
objDependency,
|
||||
eventRemoveCallback,
|
||||
absolutExpiration,
|
||||
slidingExpiration,
|
||||
longHitRange,
|
||||
pub,
|
||||
enumPriority);
|
||||
|
||||
_lockEntries.AcquireWriterLock (-1);
|
||||
try {
|
||||
@@ -218,54 +175,16 @@ namespace System.Web.Caching {
|
||||
return objEntry.Item;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an item into the Cache object with a cache key to
|
||||
/// reference its location and using default values provided by
|
||||
/// the CacheItemPriority enumeration.
|
||||
/// </summary>
|
||||
/// <param name="strKey">The cache key used to reference the item.</param>
|
||||
/// <param name="objItem">The item to be added to the cache.</param>
|
||||
public void Insert (string strKey, object objItem) {
|
||||
Add (strKey, objItem, null, NoAbsoluteExpiration, NoSlidingExpiration,
|
||||
CacheItemPriority.Default, null, true, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an object into the Cache that has file or key dependencies.
|
||||
/// </summary>
|
||||
/// <param name="strKey">The cache key used to reference the item.</param>
|
||||
/// <param name="objItem">The item to be added to the cache.</param>
|
||||
/// <param name="objDependency">
|
||||
/// The file or cache key dependencies for the item. When any
|
||||
/// dependency changes, the object becomes invalid and is removed
|
||||
/// from the cache. If there are no dependencies, this paramter
|
||||
/// contains a null reference.
|
||||
/// </param>
|
||||
public void Insert (string strKey, object objItem, CacheDependency objDependency) {
|
||||
Add (strKey, objItem, objDependency, NoAbsoluteExpiration, NoSlidingExpiration,
|
||||
CacheItemPriority.Default, null, true, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an object into the Cache with dependencies and expiration policies.
|
||||
/// </summary>
|
||||
/// <param name="strKey">The cache key used to reference the item.</param>
|
||||
/// <param name="objItem">The item to be added to the cache.</param>
|
||||
/// <param name="objDependency">
|
||||
/// The file or cache key dependencies for the item. When any
|
||||
/// dependency changes, the object becomes invalid and is removed
|
||||
/// from the cache. If there are no dependencies, this paramter
|
||||
/// contains a null reference.
|
||||
/// </param>
|
||||
/// <param name="absolutExpiration">
|
||||
/// The time at which the added object expires and is removed from the cache.
|
||||
/// </param>
|
||||
/// <param name="slidingExpiration">The interval between the
|
||||
/// time the added object was last accessed and when that object
|
||||
/// expires. If this value is the equivalent of 20 minutes, the
|
||||
/// object expires and is removed from the cache 20 minutes after
|
||||
/// it is last accessed.
|
||||
/// </param>
|
||||
public void Insert (string strKey, object objItem, CacheDependency objDependency,
|
||||
DateTime absolutExpiration, TimeSpan slidingExpiration) {
|
||||
|
||||
@@ -273,40 +192,6 @@ namespace System.Web.Caching {
|
||||
CacheItemPriority.Default, null, true, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an object into the Cache object with dependencies,
|
||||
/// expiration and priority policies, and a delegate you can use
|
||||
/// to notify your application when the inserted item is removed
|
||||
/// from the Cache.
|
||||
/// </summary>
|
||||
/// <param name="strKey">The cache key used to reference the item.</param>
|
||||
/// <param name="objItem">The item to be added to the cache.</param>
|
||||
/// <param name="objDependency">
|
||||
/// The file or cache key dependencies for the item. When any
|
||||
/// dependency changes, the object becomes invalid and is removed
|
||||
/// from the cache. If there are no dependencies, this paramter
|
||||
/// contains a null reference.
|
||||
/// </param>
|
||||
/// <param name="absolutExpiration">
|
||||
/// The time at which the added object expires and is removed from the cache.
|
||||
/// </param>
|
||||
/// <param name="slidingExpiration">
|
||||
/// The interval between the time the added object was last
|
||||
/// accessed and when that object expires. If this value is the
|
||||
/// equivalent of 20 minutes, the object expires and is removed
|
||||
/// from the cache 20 minutes after it is last accessed.
|
||||
/// </param>
|
||||
/// <param name="enumPriority">The relative cost of the object,
|
||||
/// as expressed by the CacheItemPriority enumeration. The cache
|
||||
/// uses this value when it evicts objects; objects with a lower
|
||||
/// cost are removed from the cache before objects with a higher
|
||||
/// cost.
|
||||
/// </param>
|
||||
/// <param name="eventRemoveCallback">A delegate that, if
|
||||
/// provided, is called when an object is removed from the cache.
|
||||
/// You can use this to notify applications when their objects
|
||||
/// are deleted from the cache.
|
||||
/// </param>
|
||||
public void Insert (string strKey, object objItem, CacheDependency objDependency,
|
||||
DateTime absolutExpiration, TimeSpan slidingExpiration,
|
||||
CacheItemPriority enumPriority, CacheItemRemovedCallback eventRemoveCallback) {
|
||||
@@ -318,37 +203,23 @@ namespace System.Web.Caching {
|
||||
// Called from other internal System.Web methods to add non-public objects into
|
||||
// cache, like output cache etc
|
||||
internal void InsertPrivate (string strKey, object objItem, CacheDependency objDependency,
|
||||
DateTime absolutExpiration, TimeSpan slidingExpiration,
|
||||
CacheItemPriority enumPriority, CacheItemRemovedCallback eventRemoveCallback) {
|
||||
|
||||
DateTime absolutExpiration, TimeSpan slidingExpiration,
|
||||
CacheItemPriority enumPriority, CacheItemRemovedCallback eventRemoveCallback)
|
||||
{
|
||||
Add (strKey, objItem, objDependency, absolutExpiration, slidingExpiration,
|
||||
enumPriority, eventRemoveCallback, false, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the specified item from the Cache object.
|
||||
/// </summary>
|
||||
/// <param name="strKey">The cache key for the cache item to remove.</param>
|
||||
/// <returns>
|
||||
/// The item removed from the Cache. If the value in the key
|
||||
/// parameter is not found, returns a null reference.
|
||||
/// </returns>
|
||||
internal void InsertPrivate (string strKey, object objItem, CacheDependency objDependency)
|
||||
{
|
||||
Add (strKey, objItem, objDependency, NoAbsoluteExpiration, NoSlidingExpiration,
|
||||
CacheItemPriority.Default, null, false, true);
|
||||
}
|
||||
|
||||
public object Remove (string strKey) {
|
||||
return Remove (strKey, CacheItemRemovedReason.Removed);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal method that updates the cache, decremenents the
|
||||
/// number of existing items and call close on the cache entry.
|
||||
/// This method is also used from the ExpiresBuckets class to
|
||||
/// remove an item during GC flush.
|
||||
/// </summary>
|
||||
/// <param name="strKey">The cache key for the cache item to remove.</param>
|
||||
/// <param name="enumReason">Reason why the item is removed.</param>
|
||||
/// <returns>
|
||||
/// The item removed from the Cache. If the value in the key
|
||||
/// parameter is not found, returns a null reference.
|
||||
/// </returns>
|
||||
internal object Remove (string strKey, CacheItemRemovedReason enumReason) {
|
||||
CacheEntry objEntry = null;
|
||||
|
||||
@@ -375,11 +246,6 @@ namespace System.Web.Caching {
|
||||
return objEntry.Item;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the specified item from the Cache object.
|
||||
/// </summary>
|
||||
/// <param name="strKey">The identifier for the cache item to retrieve.</param>
|
||||
/// <returns>The retrieved cache item, or a null reference.</returns>
|
||||
public object Get (string strKey) {
|
||||
CacheEntry objEntry = GetEntry (strKey);
|
||||
|
||||
@@ -421,16 +287,10 @@ namespace System.Web.Caching {
|
||||
return objEntry;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of items stored in the cache.
|
||||
/// </summary>
|
||||
public int Count {
|
||||
get { return _nItems; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the cache item at the specified key.
|
||||
/// </summary>
|
||||
public object this [string strKey] {
|
||||
get {
|
||||
return Get (strKey);
|
||||
|
||||
@@ -58,8 +58,12 @@ namespace System.Web.Caching
|
||||
bool disposed;
|
||||
CacheEntry [] entries;
|
||||
CacheItemRemovedCallback removedDelegate;
|
||||
|
||||
#if !TARGET_J2EE
|
||||
|
||||
FileSystemWatcher [] watchers;
|
||||
|
||||
#endif
|
||||
private CacheDependency ()
|
||||
{
|
||||
}
|
||||
@@ -157,13 +161,17 @@ namespace System.Web.Caching
|
||||
}
|
||||
}
|
||||
|
||||
#if !TARGET_J2EE
|
||||
|
||||
if (filenames.Length > 0) {
|
||||
watchers = new FileSystemWatcher [filenames.Length];
|
||||
for (int i=0; i<filenames.Length; i++)
|
||||
watchers [i] = CreateWatcher (filenames [i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !TARGET_J2EE
|
||||
private FileSystemWatcher CreateWatcher (string file)
|
||||
{
|
||||
FileSystemWatcher watcher = new FileSystemWatcher ();
|
||||
@@ -184,6 +192,7 @@ namespace System.Web.Caching
|
||||
{
|
||||
OnChanged (sender, e);
|
||||
}
|
||||
#endif
|
||||
|
||||
void CacheItemRemoved (string key, object value, CacheItemRemovedReason reason)
|
||||
{
|
||||
@@ -200,11 +209,17 @@ namespace System.Web.Caching
|
||||
Changed (this, new CacheDependencyChangedArgs (null));
|
||||
}
|
||||
|
||||
#if TARGET_J2EE
|
||||
public void Dispose ()
|
||||
{
|
||||
}
|
||||
#else
|
||||
public void Dispose ()
|
||||
{
|
||||
for (int i=0; i<watchers.Length; i++)
|
||||
watchers [i].Dispose ();
|
||||
}
|
||||
#endif
|
||||
|
||||
public bool HasChanged
|
||||
{
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
//
|
||||
// System.Web.Caching
|
||||
//
|
||||
// Author:
|
||||
// Patrik Torstensson
|
||||
// Daniel Cazzulino ([email protected])
|
||||
//
|
||||
//
|
||||
// System.Web.Caching
|
||||
//
|
||||
// Author:
|
||||
// Patrik Torstensson
|
||||
// Daniel Cazzulino ([email protected])
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
@@ -26,252 +26,187 @@
|
||||
// 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;
|
||||
using System.Threading;
|
||||
|
||||
namespace System.Web.Caching {
|
||||
/// <summary>
|
||||
/// Class responsible for representing a cache entry.
|
||||
/// </summary>
|
||||
internal class CacheEntry {
|
||||
internal enum Flags {
|
||||
Removed = 1,
|
||||
Public = 2
|
||||
}
|
||||
|
||||
private CacheItemPriority _enumPriority;
|
||||
|
||||
private long _longHits;
|
||||
|
||||
private byte _byteExpiresBucket;
|
||||
private int _intExpiresIndex;
|
||||
|
||||
private long _ticksExpires;
|
||||
private long _ticksSlidingExpiration;
|
||||
|
||||
private string _strKey;
|
||||
private object _objItem;
|
||||
|
||||
private long _longMinHits;
|
||||
|
||||
private Flags _enumFlags;
|
||||
|
||||
private CacheDependency _objDependency;
|
||||
private Cache _objCache;
|
||||
|
||||
internal static readonly byte NoBucketHash = byte.MaxValue;
|
||||
internal static readonly int NoIndexInBucket = int.MaxValue;
|
||||
|
||||
internal event CacheItemRemovedCallback _onRemoved;
|
||||
|
||||
private ReaderWriterLock _lock = new ReaderWriterLock();
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new cache entry
|
||||
/// </summary>
|
||||
/// <param name="strKey">The cache key used to reference the item.</param>
|
||||
/// <param name="objItem">The item to be added to the cache.</param>
|
||||
/// <param name="objDependency">The file or cache key dependencies for the item. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this paramter contains a null reference.</param>
|
||||
/// <param name="dtExpires">The time at which the added object expires and is removed from the cache. </param>
|
||||
/// <param name="tsSpan">The interval between the time the added object was last accessed and when that object expires. If this value is the equivalent of 20 minutes, the object expires and is removed from the cache 20 minutes after it is last accessed.</param>
|
||||
/// <param name="longMinHits">Used to detect and control if the item should be flushed due to under usage</param>
|
||||
/// <param name="boolPublic">Defines if the item is public or not</param>
|
||||
/// <param name="enumPriority">The relative cost of the object, as expressed by the CacheItemPriority enumeration. The cache uses this value when it evicts objects; objects with a lower cost are removed from the cache before objects with a higher cost.</param>
|
||||
internal CacheEntry (Cache objManager, string strKey, object objItem, CacheDependency objDependency, CacheItemRemovedCallback eventRemove,
|
||||
System.DateTime dtExpires, System.TimeSpan tsSpan, long longMinHits, bool boolPublic, CacheItemPriority enumPriority ) {
|
||||
if (boolPublic)
|
||||
_enumFlags |= Flags.Public;
|
||||
|
||||
_strKey = strKey;
|
||||
_objItem = objItem;
|
||||
_objCache = objManager;
|
||||
|
||||
_onRemoved += eventRemove;
|
||||
|
||||
_enumPriority = enumPriority;
|
||||
|
||||
_ticksExpires = dtExpires.ToUniversalTime ().Ticks;
|
||||
|
||||
_ticksSlidingExpiration = tsSpan.Ticks;
|
||||
|
||||
// If we have a sliding expiration it overrides the absolute expiration (MS behavior)
|
||||
// This is because sliding expiration causes the absolute expiration to be
|
||||
// moved after each period, and the absolute expiration is the value used
|
||||
// for all expiration calculations.
|
||||
if (tsSpan.Ticks != Cache.NoSlidingExpiration.Ticks)
|
||||
_ticksExpires = System.DateTime.UtcNow.AddTicks(_ticksSlidingExpiration).Ticks;
|
||||
|
||||
_objDependency = objDependency;
|
||||
if (_objDependency != null)
|
||||
// Add the entry to the cache dependency handler (we support multiple entries per handler)
|
||||
_objDependency.Changed += new CacheDependencyChangedHandler (OnChanged);
|
||||
|
||||
_longMinHits = longMinHits;
|
||||
}
|
||||
|
||||
|
||||
internal void OnChanged (object sender, CacheDependencyChangedArgs objDependency) {
|
||||
_objCache.Remove (_strKey, CacheItemRemovedReason.DependencyChanged);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans up the cache entry, removes the cache dependency and calls the remove delegate.
|
||||
/// </summary>
|
||||
/// <param name="enumReason">The reason why the cache entry are going to be removed</param>
|
||||
internal void Close(CacheItemRemovedReason enumReason) {
|
||||
Delegate [] removedEvents = null;
|
||||
|
||||
_lock.AcquireWriterLock(-1);
|
||||
try {
|
||||
// Check if the item already is removed
|
||||
if ((_enumFlags & Flags.Removed) != 0)
|
||||
return;
|
||||
|
||||
_enumFlags |= Flags.Removed;
|
||||
|
||||
if (_onRemoved != null)
|
||||
removedEvents = _onRemoved.GetInvocationList ();
|
||||
}
|
||||
finally {
|
||||
_lock.ReleaseWriterLock();
|
||||
}
|
||||
|
||||
if (removedEvents != null) {
|
||||
// Call the delegate to tell that we are now removing the entry
|
||||
if ((_enumFlags & Flags.Public) != 0) {
|
||||
foreach (Delegate del in removedEvents) {
|
||||
CacheItemRemovedCallback removed = (CacheItemRemovedCallback) del;
|
||||
try {
|
||||
removed (_strKey, _objItem, enumReason);
|
||||
}
|
||||
catch (System.Exception obj) {
|
||||
HttpApplicationFactory.SignalError (obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach (Delegate del in removedEvents) {
|
||||
CacheItemRemovedCallback removed = (CacheItemRemovedCallback) del;
|
||||
try {
|
||||
removed (_strKey, _objItem, enumReason);
|
||||
}
|
||||
catch (Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_lock.AcquireWriterLock(-1);
|
||||
try {
|
||||
// If we have a dependency, remove the entry
|
||||
if (_objDependency != null)
|
||||
_objDependency.Changed -= new CacheDependencyChangedHandler (OnChanged);
|
||||
}
|
||||
finally {
|
||||
_lock.ReleaseWriterLock();
|
||||
}
|
||||
}
|
||||
|
||||
internal bool HasUsage {
|
||||
get {
|
||||
if (_longMinHits == System.Int64.MaxValue)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool HasAbsoluteExpiration {
|
||||
get {
|
||||
if (_ticksExpires == Cache.NoAbsoluteExpiration.Ticks)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool HasSlidingExpiration {
|
||||
get {
|
||||
if (_ticksSlidingExpiration == Cache.NoSlidingExpiration.Ticks)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
internal byte ExpiresBucket {
|
||||
get {
|
||||
return _byteExpiresBucket;
|
||||
}
|
||||
set {
|
||||
_byteExpiresBucket = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal int ExpiresIndex {
|
||||
get {
|
||||
return _intExpiresIndex;
|
||||
}
|
||||
|
||||
set {
|
||||
_intExpiresIndex = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal long Expires {
|
||||
get {
|
||||
return _ticksExpires;
|
||||
}
|
||||
set {
|
||||
_ticksExpires = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal long SlidingExpiration {
|
||||
get {
|
||||
return _ticksSlidingExpiration;
|
||||
}
|
||||
}
|
||||
|
||||
internal object Item {
|
||||
get {
|
||||
return _objItem;
|
||||
}
|
||||
}
|
||||
|
||||
internal string Key {
|
||||
get {
|
||||
return _strKey;
|
||||
}
|
||||
}
|
||||
|
||||
internal long Hits {
|
||||
get {
|
||||
return _longHits;
|
||||
}
|
||||
}
|
||||
|
||||
internal long MinimumHits {
|
||||
get {
|
||||
return _longMinHits;
|
||||
}
|
||||
}
|
||||
|
||||
internal CacheItemPriority Priority {
|
||||
get {
|
||||
return _enumPriority;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsPublic {
|
||||
get {
|
||||
return (_enumFlags & Flags.Public) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
internal void Hit () {
|
||||
Interlocked.Increment (ref _longHits);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace System.Web.Caching {
|
||||
internal class CacheEntry {
|
||||
enum Flags {
|
||||
Removed = 1,
|
||||
Public = 2
|
||||
}
|
||||
|
||||
internal static readonly byte NoBucketHash = byte.MaxValue;
|
||||
internal static readonly int NoIndexInBucket = int.MaxValue;
|
||||
|
||||
CacheItemPriority _enumPriority;
|
||||
long _longHits;
|
||||
byte _byteExpiresBucket;
|
||||
int _intExpiresIndex;
|
||||
long _ticksExpires;
|
||||
long _ticksSlidingExpiration;
|
||||
string _strKey;
|
||||
object _objItem;
|
||||
long _longMinHits;
|
||||
Flags _enumFlags;
|
||||
CacheDependency _objDependency;
|
||||
Cache _objCache;
|
||||
ReaderWriterLock _lock = new ReaderWriterLock();
|
||||
|
||||
internal event CacheItemRemovedCallback _onRemoved;
|
||||
|
||||
internal CacheEntry (Cache objManager, string strKey, object objItem,CacheDependency objDependency,
|
||||
CacheItemRemovedCallback eventRemove, DateTime dtExpires, TimeSpan tsSpan,
|
||||
long longMinHits, bool boolPublic, CacheItemPriority enumPriority )
|
||||
{
|
||||
if (boolPublic)
|
||||
_enumFlags |= Flags.Public;
|
||||
|
||||
_strKey = strKey;
|
||||
_objItem = objItem;
|
||||
_objCache = objManager;
|
||||
_onRemoved += eventRemove;
|
||||
_enumPriority = enumPriority;
|
||||
_ticksExpires = dtExpires.ToUniversalTime ().Ticks;
|
||||
_ticksSlidingExpiration = tsSpan.Ticks;
|
||||
|
||||
// If we have a sliding expiration it overrides the absolute expiration (MS behavior)
|
||||
// This is because sliding expiration causes the absolute expiration to be
|
||||
// moved after each period, and the absolute expiration is the value used
|
||||
// for all expiration calculations.
|
||||
if (tsSpan.Ticks != Cache.NoSlidingExpiration.Ticks)
|
||||
_ticksExpires = DateTime.UtcNow.AddTicks (_ticksSlidingExpiration).Ticks;
|
||||
|
||||
_objDependency = objDependency;
|
||||
if (_objDependency != null)
|
||||
// Add the entry to the cache dependency handler (we support multiple entries per handler)
|
||||
_objDependency.Changed += new CacheDependencyChangedHandler (OnChanged);
|
||||
|
||||
_longMinHits = longMinHits;
|
||||
}
|
||||
|
||||
|
||||
internal void OnChanged (object sender, CacheDependencyChangedArgs objDependency)
|
||||
{
|
||||
_objCache.Remove (_strKey, CacheItemRemovedReason.DependencyChanged);
|
||||
}
|
||||
|
||||
internal void Close (CacheItemRemovedReason enumReason)
|
||||
{
|
||||
Delegate [] removedEvents = null;
|
||||
|
||||
_lock.AcquireWriterLock(-1);
|
||||
try {
|
||||
// Check if the item already is removed
|
||||
if ((_enumFlags & Flags.Removed) != 0)
|
||||
return;
|
||||
|
||||
_enumFlags |= Flags.Removed;
|
||||
|
||||
if (_onRemoved != null)
|
||||
removedEvents = _onRemoved.GetInvocationList ();
|
||||
} finally {
|
||||
_lock.ReleaseWriterLock();
|
||||
}
|
||||
|
||||
if (removedEvents != null) {
|
||||
// Call the delegate to tell that we are now removing the entry
|
||||
foreach (Delegate del in removedEvents) {
|
||||
CacheItemRemovedCallback removed = (CacheItemRemovedCallback) del;
|
||||
try {
|
||||
removed (_strKey, _objItem, enumReason);
|
||||
} catch (Exception obj) {
|
||||
if (IsPublic)
|
||||
HttpApplicationFactory.SignalError (obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_lock.AcquireWriterLock(-1);
|
||||
try {
|
||||
// If we have a dependency, remove the entry
|
||||
if (_objDependency != null)
|
||||
_objDependency.Changed -= new CacheDependencyChangedHandler (OnChanged);
|
||||
} finally {
|
||||
_lock.ReleaseWriterLock();
|
||||
}
|
||||
}
|
||||
|
||||
internal bool HasUsage {
|
||||
get {
|
||||
if (_longMinHits == System.Int64.MaxValue)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool HasAbsoluteExpiration {
|
||||
get {
|
||||
if (_ticksExpires == Cache.NoAbsoluteExpiration.Ticks)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool HasSlidingExpiration {
|
||||
get {
|
||||
if (_ticksSlidingExpiration == Cache.NoSlidingExpiration.Ticks)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
internal byte ExpiresBucket {
|
||||
get { return _byteExpiresBucket; }
|
||||
set { _byteExpiresBucket = value; }
|
||||
}
|
||||
|
||||
internal int ExpiresIndex {
|
||||
get { return _intExpiresIndex; }
|
||||
set { _intExpiresIndex = value; }
|
||||
}
|
||||
|
||||
internal long Expires {
|
||||
get { return _ticksExpires; }
|
||||
set { _ticksExpires = value; }
|
||||
}
|
||||
|
||||
internal long SlidingExpiration {
|
||||
get { return _ticksSlidingExpiration; }
|
||||
}
|
||||
|
||||
internal object Item {
|
||||
get { return _objItem; }
|
||||
}
|
||||
|
||||
internal string Key {
|
||||
get { return _strKey; }
|
||||
}
|
||||
|
||||
internal long Hits {
|
||||
get { return _longHits; }
|
||||
}
|
||||
|
||||
internal long MinimumHits {
|
||||
get { return _longMinHits; }
|
||||
}
|
||||
|
||||
internal CacheItemPriority Priority {
|
||||
get { return _enumPriority; }
|
||||
}
|
||||
|
||||
internal bool IsPublic {
|
||||
get { return (_enumFlags & Flags.Public) != 0; }
|
||||
}
|
||||
|
||||
internal void Hit ()
|
||||
{
|
||||
Interlocked.Increment (ref _longHits);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
2005-06-25 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* Cache.cs: added new InsertPrivate overload.
|
||||
|
||||
2005-06-25 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* Cache.cs:
|
||||
* CacheEntry.cs: style. Removed doc. comments.
|
||||
|
||||
2005-06-08 Ilya Kharmatsky <ilyak-at-mainsoft.com>
|
||||
|
||||
* CacheDependency.cs - added TARGET_JVM directives in places,
|
||||
where file watching is using (Mainsoft's implementation currently
|
||||
doesn't support the feature).
|
||||
|
||||
2005-05-09 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* CacheEntry.cs: credits for this patch should go to mcs. it catched
|
||||
|
||||
@@ -187,7 +187,6 @@ namespace System.Web.Compilation
|
||||
public AspGenerator (TemplateParser tparser)
|
||||
{
|
||||
this.tparser = tparser;
|
||||
tparser.AddDependency (tparser.InputFile);
|
||||
text = new StringBuilder ();
|
||||
stack = new BuilderLocationStack ();
|
||||
rootBuilder = new RootBuilder (tparser);
|
||||
@@ -270,7 +269,7 @@ namespace System.Web.Compilation
|
||||
CacheDependency cd = new CacheDependency ((string[])
|
||||
tparser.Dependencies.ToArray (typeof (string)));
|
||||
|
||||
HttpRuntime.Cache.Insert ("@@Type" + tparser.InputFile, type, cd);
|
||||
HttpRuntime.Cache.InsertPrivate ("@@Type" + tparser.InputFile, type, cd);
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ using System.Collections;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Web.Util;
|
||||
|
||||
namespace System.Web.Compilation
|
||||
{
|
||||
@@ -188,12 +189,12 @@ namespace System.Web.Compilation
|
||||
if (len < 10 || lastQuote != len - 1)
|
||||
return false;
|
||||
|
||||
if (!str.ToLower (CultureInfo.InvariantCulture).StartsWith ("#include "))
|
||||
if (!StrUtils.StartsWith (str, "#include ", true))
|
||||
return false;
|
||||
|
||||
str = str.Substring (9).Trim ();
|
||||
bool isfile = (str.ToLower (CultureInfo.InvariantCulture).StartsWith ("file"));
|
||||
if (!isfile && !str.ToLower (CultureInfo.InvariantCulture).StartsWith ("virtual"))
|
||||
bool isfile = (StrUtils.StartsWith (str ,"file", true));
|
||||
if (!isfile && !StrUtils.StartsWith (str, "virtual", true))
|
||||
return false;
|
||||
|
||||
pathType = (isfile) ? "file" : "virtual";
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace System.Web.Compilation
|
||||
{
|
||||
class CachingCompiler
|
||||
{
|
||||
static string dynamicBase = AppDomain.CurrentDomain.SetupInformation.DynamicBase;
|
||||
static object compilationLock = new object ();
|
||||
const string cachePrefix = "@@Assembly";
|
||||
const string cacheTypePrefix = "@@@Type";
|
||||
@@ -50,7 +51,7 @@ namespace System.Web.Compilation
|
||||
{
|
||||
string [] cacheKeys = new string [] { cachePrefix + filename };
|
||||
CacheDependency dep = new CacheDependency (null, cacheKeys);
|
||||
HttpRuntime.Cache.Insert (cacheTypePrefix + filename, type, dep);
|
||||
HttpRuntime.Cache.InsertPrivate (cacheTypePrefix + filename, type, dep);
|
||||
}
|
||||
|
||||
public static Type GetTypeFromCache (string filename)
|
||||
@@ -74,7 +75,7 @@ namespace System.Web.Compilation
|
||||
ICodeCompiler comp = compiler.Compiler;
|
||||
results = comp.CompileAssemblyFromDom (compiler.CompilerParameters, compiler.Unit);
|
||||
string [] deps = (string []) compiler.Parser.Dependencies.ToArray (typeof (string));
|
||||
cache.Insert (key, results, new CacheDependency (deps));
|
||||
cache.InsertPrivate (key, results, new CacheDependency (deps));
|
||||
}
|
||||
|
||||
return results;
|
||||
@@ -98,7 +99,7 @@ namespace System.Web.Compilation
|
||||
options.IncludeDebugInformation = parser.Debug;
|
||||
results = compiler.Compiler.CompileAssemblyFromFile (options, compiler.InputFile);
|
||||
string [] deps = (string []) parser.Dependencies.ToArray (typeof (string));
|
||||
cache.Insert (key, results, new CacheDependency (deps));
|
||||
cache.InsertPrivate (key, results, new CacheDependency (deps));
|
||||
}
|
||||
|
||||
return results;
|
||||
@@ -124,6 +125,9 @@ namespace System.Web.Compilation
|
||||
if (results != null)
|
||||
return results;
|
||||
|
||||
if (!Directory.Exists (dynamicBase))
|
||||
Directory.CreateDirectory (dynamicBase);
|
||||
|
||||
lock (compilationLock) {
|
||||
results = (CompilerResults) cache [cachePrefix + key];
|
||||
if (results != null)
|
||||
@@ -138,6 +142,9 @@ namespace System.Web.Compilation
|
||||
|
||||
ICodeCompiler compiler = provider.CreateCompiler ();
|
||||
CompilerParameters options = GetOptions (assemblies);
|
||||
TempFileCollection tempcoll = new TempFileCollection (config.TempDirectory, true);
|
||||
string dllfilename = Path.GetFileName (tempcoll.AddExtension ("dll", true));
|
||||
options.OutputAssembly = Path.Combine (dynamicBase, dllfilename);
|
||||
results = compiler.CompileAssemblyFromFile (options, file);
|
||||
ArrayList realdeps = new ArrayList (assemblies.Count + 1);
|
||||
realdeps.Add (file);
|
||||
@@ -148,7 +155,7 @@ namespace System.Web.Compilation
|
||||
}
|
||||
|
||||
string [] deps = (string []) realdeps.ToArray (typeof (string));
|
||||
cache.Insert (cachePrefix + key, results, new CacheDependency (deps));
|
||||
cache.InsertPrivate (cachePrefix + key, results, new CacheDependency (deps));
|
||||
}
|
||||
|
||||
return results;
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
2005-06-26 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* TagAttributes.cs:
|
||||
* AspParser.cs:
|
||||
* TemplateControlCompiler.cs: use invariant culture versions of starts/
|
||||
endswith.
|
||||
|
||||
2005-06-25 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* TemplateControlCompiler.cs: comparison between member name and the
|
||||
first part of the id provided by the user should also be
|
||||
case-insensitive. Fixes bug #75379.
|
||||
|
||||
2005-06-25 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* CachingCompiler.cs: use cache.InsertPrivate.
|
||||
* AspGenerator.cs: use cache.InsertPrivate. Removed extra call to
|
||||
AddDependency.
|
||||
|
||||
2005-06-24 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* CachingCompiler.cs: create the assemly in the DynamicBase directory,
|
||||
as all the others, when compiling an assembly from a Src file. Fixes
|
||||
bug #75371.
|
||||
|
||||
2005-06-15 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* TemplateControlCompiler.cs: if the property is not found, don't forget
|
||||
about trying the field.
|
||||
|
||||
2005-06-13 Lluis Sanchez Gual <[email protected]>
|
||||
|
||||
* Directive.cs: Register the MasterType directive.
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
using System.Web.Util;
|
||||
|
||||
namespace System.Web.Compilation
|
||||
{
|
||||
@@ -149,7 +150,7 @@ namespace System.Web.Compilation
|
||||
if (att == null || !got_hashed)
|
||||
return false;
|
||||
|
||||
return (att.StartsWith ("<%#") && att.EndsWith ("%>"));
|
||||
return (StrUtils.StartsWith (att, "<%#") && StrUtils.EndsWith (att, "%>"));
|
||||
}
|
||||
|
||||
public Hashtable GetDictionary (string key)
|
||||
|
||||
@@ -37,6 +37,7 @@ using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.Util;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
#if NET_2_0
|
||||
using System.Collections.Specialized;
|
||||
@@ -294,7 +295,7 @@ namespace System.Web.Compilation
|
||||
return false;
|
||||
|
||||
string str = value.Trim ();
|
||||
return (str.StartsWith ("<%#") && str.EndsWith ("%>"));
|
||||
return (StrUtils.StartsWith (str, "<%#") && StrUtils.EndsWith (str, "%>"));
|
||||
}
|
||||
|
||||
#if NET_2_0
|
||||
@@ -302,7 +303,7 @@ namespace System.Web.Compilation
|
||||
{
|
||||
string str = value.Trim ();
|
||||
str = str.Substring (3).Trim (); // eats "<%#"
|
||||
if (str.StartsWith ("Bind")) {
|
||||
if (StrUtils.StartsWith (str, "Bind")) {
|
||||
Match match = bindRegex.Match (str);
|
||||
if (match.Success) {
|
||||
string bindingName = match.Groups [1].Value;
|
||||
@@ -334,15 +335,19 @@ namespace System.Web.Compilation
|
||||
|
||||
static MemberInfo GetFieldOrProperty (Type type, string name)
|
||||
{
|
||||
MemberInfo member = null;
|
||||
try {
|
||||
return type.GetProperty (name, noCaseFlags);
|
||||
member = type.GetProperty (name, noCaseFlags);
|
||||
} catch {}
|
||||
|
||||
if (member != null)
|
||||
return member;
|
||||
|
||||
try {
|
||||
return type.GetField (name, noCaseFlags);
|
||||
member = type.GetField (name, noCaseFlags);
|
||||
} catch {}
|
||||
|
||||
return null;
|
||||
return member;
|
||||
}
|
||||
|
||||
bool ProcessPropertiesAndFields (ControlBuilder builder, MemberInfo member, string id,
|
||||
@@ -375,7 +380,7 @@ namespace System.Web.Compilation
|
||||
string prop_field = id.Replace ("-", ".");
|
||||
string [] parts = prop_field.Split (new char [] {'.'});
|
||||
int length = parts.Length;
|
||||
if (length < 2 || !InvariantCompare (member.Name, parts [0]))
|
||||
if (length < 2 || !InvariantCompareNoCase (member.Name, parts [0]))
|
||||
return false;
|
||||
|
||||
if (length > 2) {
|
||||
|
||||
@@ -1,3 +1,44 @@
|
||||
2005-07-25 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* MachineKeyConfigHandler.cs: removed unused code. Use
|
||||
MachineKeyValidation.
|
||||
* MachineKeyValidation.cs: made internal for 1.1 and added AES.
|
||||
* MachineKeyConfig.cs: new property to return 24 bits needed for 3DES.
|
||||
fix typo from last patch ('AutoGenerate'). Made the keys different when
|
||||
both are autogenerated.
|
||||
|
||||
2005-07-24 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* MachineKeyConfigHandler.cs:
|
||||
* MachineKeyConfig.cs: patch from Miguel that moves code from
|
||||
MachineKeyConfigHandler to MachineKeyConfig.
|
||||
|
||||
2005-06-25 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* HandlerItem.cs: the path matches 'path\z', as the previous '\Apath\z'
|
||||
failed for 'dir/*.ext'.
|
||||
|
||||
2005-06-23 Lluis Sanchez Gual <[email protected]>
|
||||
|
||||
* VirtualDirectoryMapping.cs: Implemented.
|
||||
* WebConfigurationManager.cs: Initial implementation.
|
||||
* VirtualDirectoryMappingCollection.cs: Implemented.
|
||||
* WebConfigurationFileMap.cs: Implemented.
|
||||
* WebConfigurationHost.cs: Initial implementation of class
|
||||
that supports IInternalConfigHost.
|
||||
|
||||
2005-06-19 Ilya Kharmatsky <ilyak-at-mainsoft.com>
|
||||
|
||||
* HttpRuntimeConfig.cs: Added TARGET_JVM directive in "using clause"
|
||||
in order to exclude in J2EE configuration usage of unsupported
|
||||
CodeDome API.
|
||||
|
||||
2005-06-13 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* GlobalizationConfigurationHandler.cs: when an attribute is not
|
||||
provided, don't assing Encoding.Default to it, as we might override
|
||||
parent's settings.
|
||||
|
||||
2005-05-04 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* CompilationConfiguration.cs: throw if we cannot load the type given
|
||||
|
||||
@@ -48,21 +48,15 @@ namespace System.Web.Configuration
|
||||
ThrowException ("No child nodes allowed here.", section);
|
||||
|
||||
string attvalue = AttValue ("requestEncoding", section, true);
|
||||
if (attvalue == null)
|
||||
config.RequestEncoding = Encoding.Default;
|
||||
else
|
||||
if (attvalue != null)
|
||||
config.RequestEncoding = GetEncoding (section, "requestEncoding", attvalue);
|
||||
|
||||
attvalue = AttValue ("responseEncoding", section, true);
|
||||
if (attvalue == null)
|
||||
config.ResponseEncoding = Encoding.Default;
|
||||
else
|
||||
if (attvalue != null)
|
||||
config.ResponseEncoding = GetEncoding (section, "responseEncoding", attvalue);
|
||||
|
||||
attvalue = AttValue ("fileEncoding", section, true);
|
||||
if (attvalue == null)
|
||||
config.FileEncoding = Encoding.Default;
|
||||
else
|
||||
if (attvalue != null)
|
||||
config.FileEncoding = GetEncoding (section, "fileEncoding", attvalue);
|
||||
|
||||
attvalue = AttValue ("culture", section, true);
|
||||
|
||||
@@ -53,8 +53,8 @@ namespace System.Web.Configuration
|
||||
_typeName = type;
|
||||
_path = path;
|
||||
_requestType = requestType.Replace (" ", "");
|
||||
requestRegex = GetRegex (_requestType);
|
||||
pathRegex = GetRegex (_path);
|
||||
requestRegex = GetRegex (_requestType, true);
|
||||
pathRegex = GetRegex (_path, false);
|
||||
if (validate)
|
||||
DoValidation ();
|
||||
}
|
||||
@@ -132,13 +132,13 @@ namespace System.Web.Configuration
|
||||
return result;
|
||||
}
|
||||
|
||||
static Regex GetRegex (string verb)
|
||||
static Regex GetRegex (string verb, bool match_all)
|
||||
{
|
||||
EnsureCache ();
|
||||
if (regexCache.ContainsKey (verb))
|
||||
return (Regex) regexCache [verb];
|
||||
|
||||
StringBuilder result = new StringBuilder ("\\A");
|
||||
StringBuilder result = new StringBuilder ((match_all) ? "\\A" : "");
|
||||
string [] expressions = verb.Split (',');
|
||||
int end = expressions.Length;
|
||||
for (int i = 0; i < end; i++) {
|
||||
|
||||
@@ -29,7 +29,9 @@
|
||||
//
|
||||
|
||||
using System;
|
||||
#if !TARGET_J2EE
|
||||
using System.CodeDom.Compiler;
|
||||
#endif
|
||||
using System.Collections;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// Gonzalo Paniagua Javier ([email protected])
|
||||
//
|
||||
// (C) 2002 Ximian, Inc (http://www.ximian.com)
|
||||
// Copyright (c) 2005 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
|
||||
//
|
||||
@@ -32,54 +33,126 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Configuration;
|
||||
using System.Xml;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace System.Web.Configuration
|
||||
{
|
||||
class MachineKeyConfig
|
||||
{
|
||||
static MachineKeyConfig machineKey;
|
||||
byte [] validationKey;
|
||||
byte [] decryptionKey;
|
||||
string validationType;
|
||||
static MachineKeyConfig machine_key;
|
||||
byte [] validation_key;
|
||||
bool isolate_validation;
|
||||
byte [] decryption_key;
|
||||
byte [] decryption_key_192bits;
|
||||
bool isolate_decryption; // For us, this is always true by now.
|
||||
MachineKeyValidation validation_type;
|
||||
|
||||
static byte [] autogenerated;
|
||||
static byte [] autogenerated_decrypt;
|
||||
|
||||
static MachineKeyConfig ()
|
||||
{
|
||||
autogenerated = new byte [64];
|
||||
RNGCryptoServiceProvider cp = new RNGCryptoServiceProvider ();
|
||||
cp.GetBytes (autogenerated);
|
||||
autogenerated_decrypt = new byte [64];
|
||||
cp.GetBytes (autogenerated_decrypt);
|
||||
}
|
||||
|
||||
internal MachineKeyConfig (object parent)
|
||||
{
|
||||
if (parent is MachineKeyConfig) {
|
||||
MachineKeyConfig p = (MachineKeyConfig) parent;
|
||||
validationKey = p.validationKey;
|
||||
decryptionKey = p.decryptionKey;
|
||||
validationType = p.validationType;
|
||||
validation_key = p.validation_key;
|
||||
decryption_key = p.decryption_key;
|
||||
validation_type = p.validation_type;
|
||||
}
|
||||
}
|
||||
|
||||
static byte ToHexValue (char c, bool high)
|
||||
{
|
||||
byte v;
|
||||
if (c >= '0' && c <= '9')
|
||||
v = (byte) (c - '0');
|
||||
else if (c >= 'a' && c <= 'f')
|
||||
v = (byte) (c - 'a' + 10);
|
||||
else if (c >= 'A' && c <= 'F')
|
||||
v = (byte) (c - 'A' + 10);
|
||||
else
|
||||
throw new ArgumentException ("Invalid hex character");
|
||||
|
||||
if (high)
|
||||
v <<= 4;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
internal static byte [] GetBytes (string key, int len)
|
||||
{
|
||||
byte [] result = new byte [len / 2];
|
||||
for (int i = 0; i < len; i += 2)
|
||||
result [i / 2] = (byte) (ToHexValue (key [i], true) + ToHexValue (key [i + 1], false));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static byte [] MakeKey (string key, bool decryption, out bool isolate)
|
||||
{
|
||||
if (key == null || key.StartsWith ("AutoGenerate")){
|
||||
isolate = key.IndexOf ("IsolateApps") != 1;
|
||||
|
||||
// Same key for validation and decryption when both are autogenerated.
|
||||
return (decryption) ? autogenerated_decrypt : autogenerated;
|
||||
}
|
||||
|
||||
isolate = false;
|
||||
|
||||
int len = key.Length;
|
||||
if (len < 40 || len > 128 || (len % 2) == 1)
|
||||
throw new ArgumentException ("Invalid key length");
|
||||
|
||||
return GetBytes (key, len);
|
||||
}
|
||||
|
||||
internal void SetValidationKey (string n)
|
||||
{
|
||||
validation_key = MakeKey (n, false, out isolate_validation);
|
||||
}
|
||||
|
||||
internal byte [] ValidationKey {
|
||||
get { return validationKey; }
|
||||
set { validationKey = value; }
|
||||
get { return validation_key; }
|
||||
}
|
||||
|
||||
internal void SetDecryptionKey (string n)
|
||||
{
|
||||
decryption_key = MakeKey (n, true, out isolate_decryption);
|
||||
decryption_key_192bits = new byte [24];
|
||||
int count = 24;
|
||||
if (decryption_key.Length < 24)
|
||||
count = decryption_key.Length;
|
||||
Buffer.BlockCopy (decryption_key, 0, decryption_key_192bits, 0, count);
|
||||
}
|
||||
|
||||
internal byte [] DecryptionKey {
|
||||
get { return decryptionKey; }
|
||||
set { decryptionKey = value; }
|
||||
get { return decryption_key; }
|
||||
}
|
||||
|
||||
internal string ValidationType {
|
||||
get {
|
||||
if (validationType == null)
|
||||
validationType = "SHA1";
|
||||
internal byte [] DecryptionKey192Bits {
|
||||
get { return decryption_key_192bits; }
|
||||
}
|
||||
|
||||
return validationType;
|
||||
internal MachineKeyValidation ValidationType {
|
||||
get {
|
||||
return validation_type;
|
||||
}
|
||||
set {
|
||||
if (value == null)
|
||||
return;
|
||||
|
||||
validationType = value;
|
||||
validation_type = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal static MachineKeyConfig MachineKey {
|
||||
get { return machineKey; }
|
||||
set { machineKey = value; }
|
||||
get { return machine_key; }
|
||||
set { machine_key = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,60 +31,12 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Configuration;
|
||||
using System.Security.Cryptography;
|
||||
using System.Xml;
|
||||
|
||||
namespace System.Web.Configuration
|
||||
{
|
||||
class MachineKeyConfigHandler : IConfigurationSectionHandler
|
||||
{
|
||||
static byte [] autogenerated;
|
||||
static MachineKeyConfigHandler ()
|
||||
{
|
||||
autogenerated = new byte [64];
|
||||
RNGCryptoServiceProvider cp = new RNGCryptoServiceProvider ();
|
||||
cp.GetBytes (autogenerated);
|
||||
}
|
||||
|
||||
static byte ToHexValue (char c, bool high)
|
||||
{
|
||||
byte v;
|
||||
if (c >= '0' && c <= '9')
|
||||
v = (byte) (c - '0');
|
||||
else if (c >= 'a' && c <= 'f')
|
||||
v = (byte) (c - 'a' + 10);
|
||||
else if (c >= 'A' && c <= 'F')
|
||||
v = (byte) (c - 'A' + 10);
|
||||
else
|
||||
throw new ArgumentException ("Invalid hex character");
|
||||
|
||||
if (high)
|
||||
v <<= 4;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
internal static byte [] GetBytes (string key, int len)
|
||||
{
|
||||
byte [] result = new byte [len / 2];
|
||||
for (int i = 0; i < len; i += 2)
|
||||
result [i / 2] = (byte) (ToHexValue (key [i], true) + ToHexValue (key [i + 1], false));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static byte [] MakeKey (string key)
|
||||
{
|
||||
if (key == null || key == "AutoGenerated")
|
||||
return autogenerated;
|
||||
|
||||
int len = key.Length;
|
||||
if (len < 40 || len > 128 || (len % 2) == 1)
|
||||
throw new ArgumentException ("Invalid key length");
|
||||
|
||||
return GetBytes (key, len);
|
||||
}
|
||||
|
||||
public object Create (object parent, object context, XmlNode section)
|
||||
{
|
||||
if (section.HasChildNodes)
|
||||
@@ -92,25 +44,30 @@ namespace System.Web.Configuration
|
||||
|
||||
MachineKeyConfig config = new MachineKeyConfig (parent);
|
||||
|
||||
string validationKey = AttValue ("validationKey", section);
|
||||
try {
|
||||
config.ValidationKey = MakeKey (validationKey);
|
||||
config.SetValidationKey (AttValue ("validationKey", section));
|
||||
} catch (ArgumentException e) {
|
||||
ThrowException (e.Message, section);
|
||||
}
|
||||
|
||||
string decryptionKey = AttValue ("decryptionKey", section);
|
||||
try {
|
||||
config.DecryptionKey = MakeKey (decryptionKey);
|
||||
config.SetDecryptionKey (AttValue ("decryptionKey", section));
|
||||
} catch (ArgumentException e) {
|
||||
ThrowException (e.Message, section);
|
||||
}
|
||||
|
||||
string validation = AttValue ("validation", section);
|
||||
if (validation != "SHA1" && validation != "MD5" && validation != "3DES")
|
||||
MachineKeyValidation valid = 0;
|
||||
if (validation == "SHA1")
|
||||
valid = MachineKeyValidation.SHA1;
|
||||
else if (validation == "MD5")
|
||||
valid = MachineKeyValidation.MD5;
|
||||
else if (validation == "TripleDES")
|
||||
valid = MachineKeyValidation.TripleDES;
|
||||
else
|
||||
ThrowException ("Invalid 'validation' value", section);
|
||||
|
||||
config.ValidationType = validation;
|
||||
config.ValidationType = valid;
|
||||
|
||||
if (section.Attributes != null && section.Attributes.Count != 0)
|
||||
ThrowException ("Unrecognized attribute", section);
|
||||
|
||||
@@ -28,14 +28,19 @@
|
||||
|
||||
using System.Resources;
|
||||
|
||||
#if NET_2_0
|
||||
namespace System.Web.Configuration
|
||||
{
|
||||
public enum MachineKeyValidation
|
||||
{
|
||||
MD5 = 0,
|
||||
SHA1 = 1,
|
||||
TripleDES = 2,
|
||||
}
|
||||
}
|
||||
#if NET_2_0
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum MachineKeyValidation
|
||||
{
|
||||
MD5 = 0,
|
||||
SHA1 = 1,
|
||||
TripleDES = 2,
|
||||
AES = 3
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
//
|
||||
// System.Configuration.VirtualDirectoryMapping.cs
|
||||
//
|
||||
// Authors:
|
||||
// Lluis Sanchez Gual ([email protected])
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
|
||||
#if NET_2_0
|
||||
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace System.Web.Configuration
|
||||
{
|
||||
public sealed class VirtualDirectoryMapping
|
||||
{
|
||||
string physicalDirectory;
|
||||
bool isAppRoot;
|
||||
string configFileBaseName;
|
||||
string virtualDirectory;
|
||||
|
||||
public VirtualDirectoryMapping (string physicalDirectory, bool isAppRoot)
|
||||
{
|
||||
this.physicalDirectory = physicalDirectory;
|
||||
this.isAppRoot = isAppRoot;
|
||||
}
|
||||
|
||||
public VirtualDirectoryMapping (string physicalDirectory, bool isAppRoot, string configFileBaseName)
|
||||
{
|
||||
this.physicalDirectory = physicalDirectory;
|
||||
this.isAppRoot = isAppRoot;
|
||||
this.configFileBaseName = configFileBaseName;
|
||||
}
|
||||
|
||||
internal void SetVirtualDirectory (string dir)
|
||||
{
|
||||
virtualDirectory = dir;
|
||||
}
|
||||
|
||||
[MonoTODO ("Do something with this")]
|
||||
public string ConfigFileBaseName {
|
||||
get { return configFileBaseName; }
|
||||
set { configFileBaseName = value; }
|
||||
}
|
||||
|
||||
[MonoTODO ("Do something with this")]
|
||||
public bool IsAppRoot {
|
||||
get { return isAppRoot; }
|
||||
set { isAppRoot = value; }
|
||||
}
|
||||
|
||||
public string PhysicalDirectory {
|
||||
get { return physicalDirectory; }
|
||||
set { physicalDirectory = value; }
|
||||
}
|
||||
|
||||
public string VirtualDirectory {
|
||||
get { return virtualDirectory; }
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,92 @@
|
||||
//
|
||||
// System.Configuration.VirtualDirectoryMappingCollection.cs
|
||||
//
|
||||
// Authors:
|
||||
// Lluis Sanchez Gual ([email protected])
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
|
||||
#if NET_2_0
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace System.Web.Configuration
|
||||
{
|
||||
public sealed class VirtualDirectoryMappingCollection: NameObjectCollectionBase
|
||||
{
|
||||
public void Add (string virtualDirectory, VirtualDirectoryMapping mapping)
|
||||
{
|
||||
mapping.SetVirtualDirectory (virtualDirectory);
|
||||
BaseAdd (virtualDirectory, mapping);
|
||||
}
|
||||
|
||||
public void Clear ()
|
||||
{
|
||||
BaseClear ();
|
||||
}
|
||||
|
||||
public void CopyTo (VirtualDirectoryMapping[] array, int index)
|
||||
{
|
||||
((ICollection)this).CopyTo (array, index);
|
||||
}
|
||||
|
||||
public VirtualDirectoryMapping Get (int index)
|
||||
{
|
||||
return (VirtualDirectoryMapping) BaseGet (index);
|
||||
}
|
||||
|
||||
public VirtualDirectoryMapping Get (string virtualDirectory)
|
||||
{
|
||||
return (VirtualDirectoryMapping) BaseGet (virtualDirectory);
|
||||
}
|
||||
|
||||
public string GetKey (int index)
|
||||
{
|
||||
return BaseGetKey (index);
|
||||
}
|
||||
|
||||
public void Remove (string virtualDirectory)
|
||||
{
|
||||
BaseRemove (virtualDirectory);
|
||||
}
|
||||
|
||||
public void RemoveAt (int index)
|
||||
{
|
||||
BaseRemoveAt (index);
|
||||
}
|
||||
|
||||
public ICollection AllKeys {
|
||||
get { return BaseGetAllKeys (); }
|
||||
}
|
||||
|
||||
public VirtualDirectoryMapping this [int index] {
|
||||
get { return (VirtualDirectoryMapping) BaseGet (index); }
|
||||
}
|
||||
|
||||
public VirtualDirectoryMapping this [string virtualDirectory] {
|
||||
get { return (VirtualDirectoryMapping) BaseGet (virtualDirectory); }
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// System.Configuration.ExeConfigurationFileMap.cs
|
||||
//
|
||||
// Authors:
|
||||
// Lluis Sanchez Gual ([email protected])
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
|
||||
#if NET_2_0
|
||||
|
||||
using System;
|
||||
using System.Configuration;
|
||||
|
||||
namespace System.Web.Configuration
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class WebConfigurationFileMap: ConfigurationFileMap
|
||||
{
|
||||
VirtualDirectoryMappingCollection virtualDirectories;
|
||||
|
||||
public WebConfigurationFileMap ()
|
||||
{
|
||||
virtualDirectories = new VirtualDirectoryMappingCollection ();
|
||||
}
|
||||
|
||||
public VirtualDirectoryMappingCollection VirtualDirectories {
|
||||
get { return virtualDirectories; }
|
||||
}
|
||||
|
||||
public override object Clone ()
|
||||
{
|
||||
WebConfigurationFileMap map = new WebConfigurationFileMap ();
|
||||
map.MachineConfigFilename = MachineConfigFilename;
|
||||
|
||||
map.virtualDirectories = new VirtualDirectoryMappingCollection ();
|
||||
foreach (VirtualDirectoryMapping vmap in virtualDirectories) {
|
||||
VirtualDirectoryMapping nvmap = new VirtualDirectoryMapping (vmap.PhysicalDirectory, vmap.IsAppRoot, vmap.ConfigFileBaseName);
|
||||
map.virtualDirectories.Add (vmap.VirtualDirectory, nvmap);
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,317 @@
|
||||
//
|
||||
// System.Web.Configuration.WebConfigurationHost.cs
|
||||
//
|
||||
// Authors:
|
||||
// Lluis Sanchez Gual ([email protected])
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
|
||||
#if NET_2_0
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security;
|
||||
using System.Configuration;
|
||||
using System.Configuration.Internal;
|
||||
using System.Web.Util;
|
||||
|
||||
namespace System.Web.Configuration
|
||||
{
|
||||
class WebConfigurationHost: IInternalConfigHost
|
||||
{
|
||||
WebConfigurationFileMap map;
|
||||
const string MachinePath = "machine:";
|
||||
|
||||
public virtual object CreateConfigurationContext (string configPath, string locationSubPath)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual object CreateDeprecatedConfigContext (string configPath)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public virtual string DecryptSection (string encryptedXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedSection)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public virtual void DeleteStream (string streamName)
|
||||
{
|
||||
File.Delete (streamName);
|
||||
}
|
||||
|
||||
public virtual string EncryptSection (string encryptedXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedSection)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public virtual string GetConfigPathFromLocationSubPath (string configPath, string locatinSubPath)
|
||||
{
|
||||
return configPath + "/" + locatinSubPath;
|
||||
}
|
||||
|
||||
public virtual Type GetConfigType (string typeName, bool throwOnError)
|
||||
{
|
||||
Type type = Type.GetType (typeName);
|
||||
if (type == null && throwOnError)
|
||||
throw new ConfigurationErrorsException ("Type not found: '" + typeName + "'");
|
||||
return type;
|
||||
}
|
||||
|
||||
public virtual string GetConfigTypeName (Type t)
|
||||
{
|
||||
return t.AssemblyQualifiedName;
|
||||
}
|
||||
|
||||
public virtual void GetRestrictedPermissions (IInternalConfigRecord configRecord, out PermissionSet permissionSet, out bool isHostReady)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public virtual string GetStreamName (string configPath)
|
||||
{
|
||||
if (configPath == MachinePath) {
|
||||
if (map == null)
|
||||
return System.Runtime.InteropServices.RuntimeEnvironment.SystemConfigurationFile;
|
||||
else
|
||||
return map.MachineConfigFilename;
|
||||
}
|
||||
|
||||
string dir = MapPath (configPath);
|
||||
return GetWebConfigFileName (dir);
|
||||
}
|
||||
|
||||
public virtual string GetStreamNameForConfigSource (string streamName, string configSource)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public virtual object GetStreamVersion (string streamName)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public virtual IDisposable Impersonate ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public virtual void Init (IInternalConfigRoot root, params object[] hostInitParams)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void InitForConfiguration (ref string locationSubPath, out string configPath, out string locationConfigPath, IInternalConfigRoot root, params object[] hostInitConfigurationParams)
|
||||
{
|
||||
string fullPath = (string) hostInitConfigurationParams [1];
|
||||
|
||||
map = (WebConfigurationFileMap) hostInitConfigurationParams [0];
|
||||
|
||||
if (locationSubPath == MachinePath) {
|
||||
locationSubPath = null;
|
||||
configPath = MachinePath;
|
||||
locationConfigPath = null;
|
||||
return;
|
||||
}
|
||||
|
||||
int i;
|
||||
if (locationSubPath == null) {
|
||||
configPath = fullPath;
|
||||
i = fullPath.LastIndexOf ("/");
|
||||
} else {
|
||||
configPath = locationSubPath;
|
||||
if (locationSubPath != "/")
|
||||
i = locationSubPath.LastIndexOf ('/');
|
||||
else
|
||||
i = -1;
|
||||
}
|
||||
|
||||
if (i != -1) {
|
||||
locationConfigPath = configPath.Substring (i+1);
|
||||
|
||||
if (i == 0)
|
||||
locationSubPath = "/";
|
||||
else
|
||||
locationSubPath = fullPath.Substring (0, i);
|
||||
|
||||
string dir = MapPath (configPath);
|
||||
if (GetWebConfigFileName (dir) == null) {
|
||||
InitForConfiguration (ref locationSubPath, out configPath, out locationConfigPath, root, hostInitConfigurationParams);
|
||||
}
|
||||
} else {
|
||||
locationSubPath = MachinePath;
|
||||
locationConfigPath = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public string MapPath (string virtualPath)
|
||||
{
|
||||
if (map != null)
|
||||
return MapPathFromMapper (virtualPath);
|
||||
else
|
||||
return HttpContext.Current.Request.MapPath (virtualPath);
|
||||
}
|
||||
|
||||
public string NormalizeVirtualPath (string virtualPath)
|
||||
{
|
||||
if (virtualPath == null || virtualPath.Length == 0)
|
||||
virtualPath = ".";
|
||||
else
|
||||
virtualPath = virtualPath.Trim ();
|
||||
|
||||
if (virtualPath [0] == '~' && virtualPath.Length > 2 && virtualPath [1] == '/')
|
||||
virtualPath = virtualPath.Substring (1);
|
||||
|
||||
if (System.IO.Path.DirectorySeparatorChar != '/')
|
||||
virtualPath = virtualPath.Replace (System.IO.Path.DirectorySeparatorChar, '/');
|
||||
|
||||
if (UrlUtils.IsRooted (virtualPath)) {
|
||||
virtualPath = UrlUtils.Reduce (virtualPath);
|
||||
} else {
|
||||
if (map.VirtualDirectories.Count > 0) {
|
||||
string root = map.VirtualDirectories [0].VirtualDirectory;
|
||||
virtualPath = UrlUtils.Combine (root, virtualPath);
|
||||
virtualPath = UrlUtils.Reduce (virtualPath);
|
||||
}
|
||||
}
|
||||
return virtualPath;
|
||||
}
|
||||
|
||||
public string MapPathFromMapper (string virtualPath)
|
||||
{
|
||||
string path = NormalizeVirtualPath (virtualPath);
|
||||
|
||||
foreach (VirtualDirectoryMapping mapping in map.VirtualDirectories) {
|
||||
if (path.StartsWith (mapping.VirtualDirectory)) {
|
||||
int i = mapping.VirtualDirectory.Length;
|
||||
if (path.Length == i) {
|
||||
return mapping.PhysicalDirectory;
|
||||
}
|
||||
else if (path [i] == '/') {
|
||||
string pathPart = path.Substring (i + 1).Replace ('/', Path.DirectorySeparatorChar);
|
||||
return Path.Combine (mapping.PhysicalDirectory, pathPart);
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new HttpException ("Invalid virtual directory: " + virtualPath);
|
||||
}
|
||||
|
||||
string GetWebConfigFileName (string dir)
|
||||
{
|
||||
string file = Path.Combine (dir, "Web.config");
|
||||
if (File.Exists (file))
|
||||
return file;
|
||||
file = Path.Combine (dir, "web.config");
|
||||
if (File.Exists (file))
|
||||
return file;
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual bool IsAboveApplication (string configPath)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public virtual bool IsConfigRecordRequired (string configPath)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public virtual bool IsDefinitionAllowed (string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public virtual bool IsFile (string streamName)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public virtual bool IsLocationApplicable (string configPath)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public virtual Stream OpenStreamForRead (string streamName)
|
||||
{
|
||||
if (!File.Exists (streamName))
|
||||
throw new ConfigurationException ("File '" + streamName + "' not found");
|
||||
|
||||
return new FileStream (streamName, FileMode.Open, FileAccess.Read);
|
||||
}
|
||||
|
||||
public virtual Stream OpenStreamForWrite (string streamName, string templateStreamName, ref object writeContext)
|
||||
{
|
||||
return new FileStream (streamName, FileMode.Create, FileAccess.Write);
|
||||
}
|
||||
|
||||
public virtual bool PrefetchAll (string configPath, string streamName)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public virtual bool PrefetchSection (string sectionGroupName, string sectionName)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public virtual object StartMonitoringStreamForChanges (string streamName, StreamChangeCallback callback)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public virtual void StopMonitoringStreamForChanges (string streamName, StreamChangeCallback callback)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public virtual void VerifyDefinitionAllowed (string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, IConfigErrorInfo errorInfo)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public virtual void WriteCompleted (string streamName, bool success, object writeContext)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual bool SupportsChangeNotifications {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public virtual bool SupportsLocation {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public virtual bool SupportsPath {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public virtual bool SupportsRefresh {
|
||||
get { return false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,155 @@
|
||||
//
|
||||
// System.Web.Configuration.WebConfigurationManager.cs
|
||||
//
|
||||
// Authors:
|
||||
// Lluis Sanchez Gual ([email protected])
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
|
||||
#if NET_2_0
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Reflection;
|
||||
using System.Xml;
|
||||
using System.Configuration;
|
||||
using System.Configuration.Internal;
|
||||
using _Configuration = System.Configuration.Configuration;
|
||||
|
||||
namespace System.Web.Configuration {
|
||||
|
||||
public abstract class WebConfigurationManager
|
||||
{
|
||||
static IInternalConfigConfigurationFactory configFactory;
|
||||
static Hashtable configurations = new Hashtable ();
|
||||
|
||||
static WebConfigurationManager ()
|
||||
{
|
||||
PropertyInfo prop = typeof(ConfigurationManager).GetProperty ("ConfigurationFactory", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
if (prop != null)
|
||||
configFactory = prop.GetValue (null, null) as IInternalConfigConfigurationFactory;
|
||||
}
|
||||
|
||||
WebConfigurationManager ()
|
||||
{
|
||||
}
|
||||
|
||||
public static _Configuration OpenWebConfiguration (string path)
|
||||
{
|
||||
return OpenWebConfiguration (path, null, null, null, IntPtr.Zero, null);
|
||||
}
|
||||
|
||||
public static _Configuration OpenWebConfiguration (string path, string site)
|
||||
{
|
||||
return OpenWebConfiguration (path, site, null, null, IntPtr.Zero, null);
|
||||
}
|
||||
|
||||
public static _Configuration OpenWebConfiguration (string path, string site, string locationSubPath)
|
||||
{
|
||||
return OpenWebConfiguration (path, site, locationSubPath, null, IntPtr.Zero, null);
|
||||
}
|
||||
|
||||
public static _Configuration OpenWebConfiguration (string path, string site, string locationSubPath, string server, IntPtr userToken)
|
||||
{
|
||||
return OpenWebConfiguration (path, site, locationSubPath, server, userToken, null);
|
||||
}
|
||||
|
||||
[MonoTODO ("Do something with the extra parameters")]
|
||||
public static _Configuration OpenWebConfiguration (string path, string site, string locationSubPath, string server, IntPtr userToken, string password)
|
||||
{
|
||||
string basePath = GetBasePath (path);
|
||||
_Configuration conf;
|
||||
|
||||
lock (configurations) {
|
||||
conf = (_Configuration) configurations [basePath];
|
||||
if (conf == null) {
|
||||
conf = ConfigurationFactory.Create (typeof(WebConfigurationHost), null, path, site, locationSubPath, server, userToken, password);
|
||||
configurations [basePath] = conf;
|
||||
}
|
||||
}
|
||||
if (basePath.Length < path.Length) {
|
||||
|
||||
// If the path has a file name, look for a location specific configuration
|
||||
|
||||
int dif = path.Length - basePath.Length;
|
||||
string file = path.Substring (path.Length - dif);
|
||||
int i=0;
|
||||
while (i < file.Length && file [i] == '/')
|
||||
i++;
|
||||
if (i != 0)
|
||||
file = file.Substring (i);
|
||||
|
||||
if (file.Length != 0) {
|
||||
foreach (ConfigurationLocation loc in conf.Locations) {
|
||||
if (loc.Path == file)
|
||||
return loc.OpenConfiguration ();
|
||||
}
|
||||
}
|
||||
}
|
||||
return conf;
|
||||
}
|
||||
|
||||
public static _Configuration OpenMappedWebConfiguration (WebConfigurationFileMap fileMap, string path)
|
||||
{
|
||||
return ConfigurationFactory.Create (typeof(WebConfigurationHost), fileMap, path);
|
||||
}
|
||||
|
||||
[MonoTODO ("Do something with the extra parameters")]
|
||||
public static _Configuration OpenMappedWebConfiguration (WebConfigurationFileMap fileMap, string path, string site)
|
||||
{
|
||||
return ConfigurationFactory.Create (typeof(WebConfigurationHost), fileMap, path, site);
|
||||
}
|
||||
|
||||
[MonoTODO ("Do something with the extra parameters")]
|
||||
public static _Configuration OpenMappedWebConfiguration (WebConfigurationFileMap fileMap, string path, string site, string locationSubPath)
|
||||
{
|
||||
return ConfigurationFactory.Create (typeof(WebConfigurationHost), fileMap, path, site, locationSubPath);
|
||||
}
|
||||
|
||||
public static _Configuration OpenMappedMachineConfiguration (ConfigurationFileMap fileMap)
|
||||
{
|
||||
return ConfigurationFactory.Create (typeof(WebConfigurationHost), fileMap);
|
||||
}
|
||||
|
||||
internal static IInternalConfigConfigurationFactory ConfigurationFactory {
|
||||
get { return configFactory; }
|
||||
}
|
||||
|
||||
static string GetBasePath (string path)
|
||||
{
|
||||
string pd = HttpContext.Current.Request.MapPath (path);
|
||||
|
||||
if (!Directory.Exists (pd)) {
|
||||
int i = path.LastIndexOf ('/');
|
||||
path = path.Substring (0, i);
|
||||
}
|
||||
|
||||
while (path [path.Length - 1] == '/')
|
||||
path = path.Substring (0, path.Length - 1);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,3 +1,26 @@
|
||||
2005-07-26 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* FormsAuthentication.cs: the init_vector must be the same accross
|
||||
restarts, otherwise the cookie does not work even when a decryption
|
||||
key is provided. Initialize it to the bytes of the cookie name. Fixes
|
||||
bug #75635.
|
||||
|
||||
2005-07-25 Eyal Alaluf <[email protected]>
|
||||
|
||||
* FormsAuthenticationModule.cs: Check for null config
|
||||
|
||||
2005-07-25 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* FormsAuthentication.cs: my previous patch missed a "small" detail: it
|
||||
didn't include the verification key when computing/checking the
|
||||
validation hash. Now this is really a MAC or HMAC or...
|
||||
|
||||
2005-07-25 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* FormsAuthentication.cs:
|
||||
* FormsAuthenticationTicket.cs: added support for validation and
|
||||
encryption of the auth. cookie and improved serialization of the ticket.
|
||||
|
||||
2005-06-10 Lluis Sanchez Gual <[email protected]>
|
||||
|
||||
* MembershipUserCollection.cs:
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// Gonzalo Paniagua Javier ([email protected])
|
||||
//
|
||||
// (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
|
||||
// Copyright (c) 2005 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
|
||||
//
|
||||
@@ -41,13 +42,17 @@ namespace System.Web.Security
|
||||
{
|
||||
public sealed class FormsAuthentication
|
||||
{
|
||||
const int MD5_hash_size = 16;
|
||||
const int SHA1_hash_size = 20;
|
||||
|
||||
static string authConfigPath = "system.web/authentication";
|
||||
static bool initialized;
|
||||
static string cookieName;
|
||||
static string cookiePath;
|
||||
static int timeout;
|
||||
//static FormsProtectionEnum protection;
|
||||
static FormsProtectionEnum protection;
|
||||
static object locker = new object ();
|
||||
static byte [] init_vector; // initialization vector used for 3DES
|
||||
#if NET_1_1
|
||||
static bool requireSSL;
|
||||
static bool slidingExpiration;
|
||||
@@ -91,28 +96,71 @@ namespace System.Web.Security
|
||||
return (password == stored);
|
||||
}
|
||||
|
||||
static FormsAuthenticationTicket Decrypt2 (byte [] bytes)
|
||||
{
|
||||
if (protection == FormsProtectionEnum.None)
|
||||
return FormsAuthenticationTicket.FromByteArray (bytes);
|
||||
|
||||
MachineKeyConfig config = HttpContext.GetAppConfig ("system.web/machineKey") as MachineKeyConfig;
|
||||
bool all = (protection == FormsProtectionEnum.All);
|
||||
|
||||
byte [] result = bytes;
|
||||
if (all || protection == FormsProtectionEnum.Encryption) {
|
||||
ICryptoTransform decryptor;
|
||||
decryptor = new TripleDESCryptoServiceProvider().CreateDecryptor (config.DecryptionKey192Bits, init_vector);
|
||||
result = decryptor.TransformFinalBlock (bytes, 0, bytes.Length);
|
||||
bytes = null;
|
||||
}
|
||||
|
||||
if (all || protection == FormsProtectionEnum.Validation) {
|
||||
int count;
|
||||
|
||||
if (config.ValidationType == MachineKeyValidation.MD5)
|
||||
count = MD5_hash_size;
|
||||
else
|
||||
count = SHA1_hash_size; // 3DES and SHA1
|
||||
|
||||
byte [] vk = config.ValidationKey;
|
||||
byte [] mix = new byte [result.Length - count + vk.Length];
|
||||
Buffer.BlockCopy (result, 0, mix, 0, result.Length - count);
|
||||
Buffer.BlockCopy (vk, 0, mix, result.Length - count, vk.Length);
|
||||
|
||||
byte [] hash = null;
|
||||
switch (config.ValidationType) {
|
||||
case MachineKeyValidation.MD5:
|
||||
hash = MD5.Create ().ComputeHash (mix);
|
||||
break;
|
||||
// From MS docs: "When 3DES is specified, forms authentication defaults to SHA1"
|
||||
case MachineKeyValidation.TripleDES:
|
||||
case MachineKeyValidation.SHA1:
|
||||
hash = SHA1.Create ().ComputeHash (mix);
|
||||
break;
|
||||
}
|
||||
|
||||
if (result.Length < count)
|
||||
throw new ArgumentException ("Error validating ticket (length).", "encryptedTicket");
|
||||
|
||||
int i, k;
|
||||
for (i = result.Length - count, k = 0; k < count; i++, k++) {
|
||||
if (result [i] != hash [k])
|
||||
throw new ArgumentException ("Error validating ticket.", "encryptedTicket");
|
||||
}
|
||||
}
|
||||
|
||||
return FormsAuthenticationTicket.FromByteArray (result);
|
||||
}
|
||||
|
||||
public static FormsAuthenticationTicket Decrypt (string encryptedTicket)
|
||||
{
|
||||
if (encryptedTicket == null || encryptedTicket == String.Empty)
|
||||
throw new ArgumentException ("Invalid encrypted ticket", "encryptedTicket");
|
||||
|
||||
Initialize ();
|
||||
byte [] bytes = MachineKeyConfigHandler.GetBytes (encryptedTicket, encryptedTicket.Length);
|
||||
string decrypted = Encoding.ASCII.GetString (bytes);
|
||||
FormsAuthenticationTicket ticket = null;
|
||||
|
||||
FormsAuthenticationTicket ticket;
|
||||
byte [] bytes = MachineKeyConfig.GetBytes (encryptedTicket, encryptedTicket.Length);
|
||||
try {
|
||||
string [] values = decrypted.Split ((char) 1, (char) 2, (char) 3, (char) 4, (char) 5, (char) 6, (char) 7);
|
||||
if (values.Length != 8)
|
||||
throw new Exception (values.Length + " " + encryptedTicket);
|
||||
|
||||
|
||||
ticket = new FormsAuthenticationTicket (Int32.Parse (values [0]),
|
||||
values [1],
|
||||
new DateTime (Int64.Parse (values [2])),
|
||||
new DateTime (Int64.Parse (values [3])),
|
||||
(values [4] == "1"),
|
||||
values [5],
|
||||
values [6]);
|
||||
ticket = Decrypt2 (bytes);
|
||||
} catch (Exception) {
|
||||
ticket = null;
|
||||
}
|
||||
@@ -126,24 +174,45 @@ namespace System.Web.Security
|
||||
throw new ArgumentNullException ("ticket");
|
||||
|
||||
Initialize ();
|
||||
StringBuilder allTicket = new StringBuilder ();
|
||||
allTicket.Append (ticket.Version);
|
||||
allTicket.Append ('\u0001');
|
||||
allTicket.Append (ticket.Name);
|
||||
allTicket.Append ('\u0002');
|
||||
allTicket.Append (ticket.IssueDate.Ticks);
|
||||
allTicket.Append ('\u0003');
|
||||
allTicket.Append (ticket.Expiration.Ticks);
|
||||
allTicket.Append ('\u0004');
|
||||
allTicket.Append (ticket.IsPersistent ? '1' : '0');
|
||||
allTicket.Append ('\u0005');
|
||||
allTicket.Append (ticket.UserData);
|
||||
allTicket.Append ('\u0006');
|
||||
allTicket.Append (ticket.CookiePath);
|
||||
allTicket.Append ('\u0007');
|
||||
//if (protection == FormsProtectionEnum.None)
|
||||
return GetHexString (allTicket.ToString ());
|
||||
//TODO: encrypt and validate
|
||||
byte [] ticket_bytes = ticket.ToByteArray ();
|
||||
if (protection == FormsProtectionEnum.None)
|
||||
return GetHexString (ticket_bytes);
|
||||
|
||||
byte [] result = ticket_bytes;
|
||||
MachineKeyConfig config = HttpContext.GetAppConfig ("system.web/machineKey") as MachineKeyConfig;
|
||||
bool all = (protection == FormsProtectionEnum.All);
|
||||
if (all || protection == FormsProtectionEnum.Validation) {
|
||||
byte [] valid_bytes = null;
|
||||
byte [] vk = config.ValidationKey;
|
||||
byte [] mix = new byte [ticket_bytes.Length + vk.Length];
|
||||
Buffer.BlockCopy (ticket_bytes, 0, mix, 0, ticket_bytes.Length);
|
||||
Buffer.BlockCopy (vk, 0, mix, result.Length, vk.Length);
|
||||
|
||||
switch (config.ValidationType) {
|
||||
case MachineKeyValidation.MD5:
|
||||
valid_bytes = MD5.Create ().ComputeHash (mix);
|
||||
break;
|
||||
// From MS docs: "When 3DES is specified, forms authentication defaults to SHA1"
|
||||
case MachineKeyValidation.TripleDES:
|
||||
case MachineKeyValidation.SHA1:
|
||||
valid_bytes = SHA1.Create ().ComputeHash (mix);
|
||||
break;
|
||||
}
|
||||
|
||||
int tlen = ticket_bytes.Length;
|
||||
int vlen = valid_bytes.Length;
|
||||
result = new byte [tlen + vlen];
|
||||
Buffer.BlockCopy (ticket_bytes, 0, result, 0, tlen);
|
||||
Buffer.BlockCopy (valid_bytes, 0, result, tlen, vlen);
|
||||
}
|
||||
|
||||
if (all || protection == FormsProtectionEnum.Encryption) {
|
||||
ICryptoTransform encryptor;
|
||||
encryptor = new TripleDESCryptoServiceProvider().CreateEncryptor (config.DecryptionKey192Bits, init_vector);
|
||||
result = encryptor.TransformFinalBlock (result, 0, result.Length);
|
||||
}
|
||||
|
||||
return GetHexString (result);
|
||||
}
|
||||
|
||||
public static HttpCookie GetAuthCookie (string userName, bool createPersistentCookie)
|
||||
@@ -187,7 +256,6 @@ namespace System.Web.Security
|
||||
if (userName == null)
|
||||
return null;
|
||||
|
||||
//TODO: what's createPersistentCookie used for?
|
||||
Initialize ();
|
||||
HttpRequest request = HttpContext.Current.Request;
|
||||
string returnUrl = request ["RETURNURL"];
|
||||
@@ -215,7 +283,7 @@ namespace System.Web.Security
|
||||
|
||||
static string GetHexString (string str)
|
||||
{
|
||||
return GetHexString (Encoding.ASCII.GetBytes (str));
|
||||
return GetHexString (Encoding.UTF8.GetBytes (str));
|
||||
}
|
||||
|
||||
static string GetHexString (byte [] bytes)
|
||||
@@ -265,7 +333,7 @@ namespace System.Web.Security
|
||||
cookieName = authConfig.CookieName;
|
||||
timeout = authConfig.Timeout;
|
||||
cookiePath = authConfig.CookiePath;
|
||||
//protection = authConfig.Protection;
|
||||
protection = authConfig.Protection;
|
||||
#if NET_1_1
|
||||
requireSSL = authConfig.RequireSSL;
|
||||
slidingExpiration = authConfig.SlidingExpiration;
|
||||
@@ -274,12 +342,22 @@ namespace System.Web.Security
|
||||
cookieName = ".MONOAUTH";
|
||||
timeout = 30;
|
||||
cookiePath = "/";
|
||||
//protection = FormsProtectionEnum.All;
|
||||
protection = FormsProtectionEnum.All;
|
||||
#if NET_1_1
|
||||
slidingExpiration = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
// IV is 8 bytes long for 3DES
|
||||
init_vector = new byte [8];
|
||||
int len = cookieName.Length;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (i >= len)
|
||||
break;
|
||||
|
||||
init_vector [i] = (byte) cookieName [i];
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace System.Web.Security
|
||||
HttpApplication app = (HttpApplication) sender;
|
||||
HttpContext context = app.Context;
|
||||
AuthConfig config = (AuthConfig) context.GetConfig ("system.web/authentication");
|
||||
if (config.Mode != AuthenticationMode.Forms) {
|
||||
if (config == null || config.Mode != AuthenticationMode.Forms) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// Gonzalo Paniagua Javier ([email protected])
|
||||
//
|
||||
// (C) 2002 Ximian, Inc (http://www.ximian.com)
|
||||
// Copyright (c) 2005 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
|
||||
//
|
||||
@@ -29,6 +30,7 @@
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace System.Web.Security
|
||||
{
|
||||
@@ -36,12 +38,74 @@ namespace System.Web.Security
|
||||
public sealed class FormsAuthenticationTicket
|
||||
{
|
||||
int version;
|
||||
string name;
|
||||
DateTime issueDate;
|
||||
bool persistent;
|
||||
DateTime issue_date;
|
||||
DateTime expiration;
|
||||
bool isPersistent;
|
||||
string userData;
|
||||
string cookiePath;
|
||||
string name;
|
||||
string cookie_path;
|
||||
string user_data;
|
||||
|
||||
/*
|
||||
internal void ToStr ()
|
||||
{
|
||||
Console.WriteLine ("version: {0}", version);
|
||||
Console.WriteLine ("persistent: {0}", persistent);
|
||||
Console.WriteLine ("issue_date: {0}", issue_date);
|
||||
Console.WriteLine ("expiration: {0}", expiration);
|
||||
Console.WriteLine ("name: {0}", name);
|
||||
Console.WriteLine ("cookie_path: {0}", cookie_path);
|
||||
Console.WriteLine ("user_data: {0}", user_data);
|
||||
}
|
||||
*/
|
||||
|
||||
internal byte [] ToByteArray ()
|
||||
{
|
||||
MemoryStream ms = new MemoryStream ();
|
||||
BinaryWriter writer = new BinaryWriter (ms);
|
||||
writer.Write (version);
|
||||
writer.Write (persistent);
|
||||
writer.Write (issue_date.Ticks);
|
||||
writer.Write (expiration.Ticks);
|
||||
writer.Write (name != null);
|
||||
if (name != null)
|
||||
writer.Write (name);
|
||||
|
||||
writer.Write (cookie_path != null);
|
||||
if (cookie_path != null)
|
||||
writer.Write (cookie_path);
|
||||
|
||||
writer.Write (user_data != null);
|
||||
if (user_data != null)
|
||||
writer.Write (user_data);
|
||||
|
||||
writer.Flush ();
|
||||
return ms.ToArray ();
|
||||
}
|
||||
|
||||
internal static FormsAuthenticationTicket FromByteArray (byte [] bytes)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream (bytes);
|
||||
BinaryReader reader = new BinaryReader (ms);
|
||||
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket ();
|
||||
ticket.version = reader.ReadInt32 ();
|
||||
ticket.persistent = reader.ReadBoolean ();
|
||||
ticket.issue_date = new DateTime (reader.ReadInt64 ());
|
||||
ticket.expiration = new DateTime (reader.ReadInt64 ());
|
||||
if (reader.ReadBoolean ())
|
||||
ticket.name = reader.ReadString ();
|
||||
|
||||
if (reader.ReadBoolean ())
|
||||
ticket.cookie_path = reader.ReadString ();
|
||||
|
||||
if (reader.ReadBoolean ())
|
||||
ticket.user_data = reader.ReadString ();
|
||||
|
||||
return ticket;
|
||||
}
|
||||
|
||||
private FormsAuthenticationTicket ()
|
||||
{
|
||||
}
|
||||
|
||||
public FormsAuthenticationTicket (int version,
|
||||
string name,
|
||||
@@ -52,11 +116,11 @@ namespace System.Web.Security
|
||||
{
|
||||
this.version = version;
|
||||
this.name = name;
|
||||
this.issueDate = issueDate;
|
||||
this.issue_date = issueDate;
|
||||
this.expiration = expiration;
|
||||
this.isPersistent = isPersistent;
|
||||
this.userData = userData;
|
||||
this.cookiePath = "/";
|
||||
this.persistent = isPersistent;
|
||||
this.user_data = userData;
|
||||
this.cookie_path = "/";
|
||||
}
|
||||
|
||||
public FormsAuthenticationTicket (int version,
|
||||
@@ -69,31 +133,31 @@ namespace System.Web.Security
|
||||
{
|
||||
this.version = version;
|
||||
this.name = name;
|
||||
this.issueDate = issueDate;
|
||||
this.issue_date = issueDate;
|
||||
this.expiration = expiration;
|
||||
this.isPersistent = isPersistent;
|
||||
this.userData = userData;
|
||||
this.cookiePath = cookiePath;
|
||||
this.persistent = isPersistent;
|
||||
this.user_data = userData;
|
||||
this.cookie_path = cookiePath;
|
||||
}
|
||||
|
||||
public FormsAuthenticationTicket (string name, bool isPersistent, int timeout)
|
||||
{
|
||||
this.version = 1;
|
||||
this.name = name;
|
||||
this.issueDate = DateTime.Now;
|
||||
this.isPersistent = isPersistent;
|
||||
if (isPersistent)
|
||||
expiration = issueDate.AddYears (50);
|
||||
this.issue_date = DateTime.Now;
|
||||
this.persistent = isPersistent;
|
||||
if (persistent)
|
||||
expiration = issue_date.AddYears (50);
|
||||
else
|
||||
expiration = issueDate.AddMinutes ((double) timeout);
|
||||
expiration = issue_date.AddMinutes ((double) timeout);
|
||||
|
||||
this.userData = String.Empty;
|
||||
this.cookiePath = "/";
|
||||
this.user_data = "";
|
||||
this.cookie_path = "/";
|
||||
}
|
||||
|
||||
internal void SetDates (DateTime issueDate, DateTime expiration)
|
||||
internal void SetDates (DateTime issue_date, DateTime expiration)
|
||||
{
|
||||
this.issueDate = issueDate;
|
||||
this.issue_date = issue_date;
|
||||
this.expiration = expiration;
|
||||
}
|
||||
|
||||
@@ -101,67 +165,43 @@ namespace System.Web.Security
|
||||
{
|
||||
return new FormsAuthenticationTicket (version,
|
||||
name,
|
||||
issueDate,
|
||||
issue_date,
|
||||
expiration,
|
||||
isPersistent,
|
||||
userData,
|
||||
cookiePath);
|
||||
persistent,
|
||||
user_data,
|
||||
cookie_path);
|
||||
}
|
||||
|
||||
public string CookiePath
|
||||
{
|
||||
get {
|
||||
return cookiePath;
|
||||
}
|
||||
public string CookiePath {
|
||||
get { return cookie_path; }
|
||||
}
|
||||
|
||||
public DateTime Expiration
|
||||
{
|
||||
get {
|
||||
return expiration;
|
||||
}
|
||||
public DateTime Expiration {
|
||||
get { return expiration; }
|
||||
}
|
||||
|
||||
public bool Expired
|
||||
{
|
||||
get {
|
||||
return DateTime.Now > expiration;
|
||||
}
|
||||
public bool Expired {
|
||||
get { return DateTime.Now > expiration; }
|
||||
}
|
||||
|
||||
public bool IsPersistent
|
||||
{
|
||||
get {
|
||||
return isPersistent;
|
||||
}
|
||||
public bool IsPersistent {
|
||||
get { return persistent; }
|
||||
}
|
||||
|
||||
public DateTime IssueDate
|
||||
{
|
||||
get {
|
||||
return issueDate;
|
||||
}
|
||||
public DateTime IssueDate {
|
||||
get { return issue_date; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get {
|
||||
return name;
|
||||
}
|
||||
public string Name {
|
||||
get { return name; }
|
||||
}
|
||||
|
||||
public string UserData
|
||||
{
|
||||
get {
|
||||
return userData;
|
||||
}
|
||||
public string UserData {
|
||||
get { return user_data; }
|
||||
}
|
||||
|
||||
public int Version
|
||||
{
|
||||
get {
|
||||
return version;
|
||||
}
|
||||
public int Version {
|
||||
get { return version; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
2005-06-25 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* SessionInProcHandler.cs: use cache.InsertPrivate.
|
||||
* SessionDictionary.cs: fix typo that made Clone useless.
|
||||
|
||||
2005-06-08 Ilya Kharmatsky <ilyak-at-mainsoft.com>
|
||||
|
||||
* SessionStateMode.cs: Added TARGET_J2EE directive in order
|
||||
to provide in J2EE configuration additional mode - J2EE
|
||||
* SessionStateModule.cs: Added TARGET_JVM directives in order
|
||||
to resolve unsupported in Ghrasshopper "static variables" issue
|
||||
(When static variable are stored in general place, instead of
|
||||
storing such variables per AppDomain).
|
||||
|
||||
2005-05-27 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* RemoteStateServer.cs:
|
||||
|
||||
@@ -45,7 +45,7 @@ internal class SessionDictionary : NameObjectCollectionBase
|
||||
internal SessionDictionary Clone ()
|
||||
{
|
||||
SessionDictionary sess = new SessionDictionary ();
|
||||
int last = sess.Count;
|
||||
int last = Count;
|
||||
for (int i = 0; i < last; i++) {
|
||||
string key = GetKey (i);
|
||||
sess [key] = this [key];
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace System.Web.SessionState
|
||||
read_only); //readonly
|
||||
|
||||
TimeSpan timeout = new TimeSpan (0, config.Timeout, 0);
|
||||
cache.Insert ("@@@InProc@" + sessionID, state, null, DateTime.Now + timeout,
|
||||
cache.InsertPrivate ("@@@InProc@" + sessionID, state, null, DateTime.Now + timeout,
|
||||
timeout, CacheItemPriority.AboveNormal, removedCB);
|
||||
|
||||
isNew = true;
|
||||
|
||||
@@ -35,6 +35,9 @@ public enum SessionStateMode
|
||||
InProc = 1,
|
||||
StateServer = 2,
|
||||
SQLServer = 3
|
||||
#if TARGET_J2EE
|
||||
,J2ee = 1024
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,8 +42,27 @@ namespace System.Web.SessionState
|
||||
internal static readonly string CookieName = "ASPSESSION";
|
||||
internal static readonly string HeaderName = "AspFilterSessionId";
|
||||
|
||||
#if !TARGET_J2EE
|
||||
static SessionConfig config;
|
||||
static Type handlerType;
|
||||
#else
|
||||
static private SessionConfig config {
|
||||
get {
|
||||
return (SessionConfig)AppDomain.CurrentDomain.GetData("SessionStateModule.config");
|
||||
}
|
||||
set {
|
||||
AppDomain.CurrentDomain.SetData("SessionStateModule.config", value);
|
||||
}
|
||||
}
|
||||
static private Type handlerType {
|
||||
get {
|
||||
return (Type)AppDomain.CurrentDomain.GetData("SessionStateModule.handlerType");
|
||||
}
|
||||
set {
|
||||
AppDomain.CurrentDomain.SetData("SessionStateModule.handlerType", value);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
ISessionHandler handler;
|
||||
bool sessionForStaticFiles;
|
||||
|
||||
@@ -197,8 +216,10 @@ namespace System.Web.SessionState
|
||||
|
||||
internal void OnEnd ()
|
||||
{
|
||||
#if !TARGET_J2EE
|
||||
if (End != null)
|
||||
End (this, EventArgs.Empty);
|
||||
#endif
|
||||
}
|
||||
|
||||
public event EventHandler Start;
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
2005-06-25 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* Page.cs:
|
||||
* Control.cs: avoid the creation of the EventHandlerList and accessing
|
||||
to it whenever possible. Fix ENABLE_THEMING constant.
|
||||
|
||||
2005-06-25 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* TemplateParser.cs:
|
||||
* TemplateControlParser.cs:
|
||||
* UserControlParser.cs: detect circular references when a control tries
|
||||
to register itself as a tag. Fixes bug #75376.
|
||||
|
||||
2005-06-14 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* PageParser.cs: don't try to compile the master page if it wan't
|
||||
provided. Use MapPath from the base classes instead of the long
|
||||
version. Fixes bug #75269 that prevented xsp2 from working properly.
|
||||
|
||||
2005-06-13 Lluis Sanchez Gual <[email protected]>
|
||||
|
||||
* MasterPage.cs: Clear the default content of placeholders before
|
||||
|
||||
@@ -60,6 +60,15 @@ namespace System.Web.UI
|
||||
static readonly object PreRenderEvent = new object();
|
||||
static readonly object UnloadEvent = new object();
|
||||
static string[] defaultNameArray;
|
||||
/* */
|
||||
int event_mask;
|
||||
const int databinding_mask = 1;
|
||||
const int disposed_mask = 1 << 1;
|
||||
const int init_mask = 1 << 2;
|
||||
const int load_mask = 1 << 3;
|
||||
const int prerender_mask = 1 << 4;
|
||||
const int unload_mask = 1 << 5;
|
||||
/* */
|
||||
|
||||
string uniqueID;
|
||||
string _userId;
|
||||
@@ -98,7 +107,7 @@ namespace System.Web.UI
|
||||
const int LOADED = 1 << 14;
|
||||
const int PRERENDERED = 1 << 15;
|
||||
#if NET_2_0
|
||||
const int ENABLE_THEMING = 1 << 15;
|
||||
const int ENABLE_THEMING = 1 << 16;
|
||||
#endif
|
||||
/*************/
|
||||
|
||||
@@ -594,47 +603,47 @@ namespace System.Web.UI
|
||||
{
|
||||
return false;
|
||||
}
|
||||
protected virtual void OnDataBinding(EventArgs e) //DIT
|
||||
{
|
||||
if (_events != null)
|
||||
{
|
||||
EventHandler eh = (EventHandler)(_events[DataBindingEvent]);
|
||||
if (eh != null) eh(this, e);
|
||||
}
|
||||
}
|
||||
protected virtual void OnInit(EventArgs e) //DIT
|
||||
{
|
||||
if (_events != null)
|
||||
{
|
||||
EventHandler eh = (EventHandler)(_events[InitEvent]);
|
||||
if (eh != null) eh(this, e);
|
||||
}
|
||||
}
|
||||
protected virtual void OnLoad(EventArgs e) //DIT
|
||||
{
|
||||
if (_events != null)
|
||||
{
|
||||
EventHandler eh = (EventHandler)(_events[LoadEvent]);
|
||||
if (eh != null) eh(this, e);
|
||||
}
|
||||
}
|
||||
protected virtual void OnPreRender(EventArgs e) //DIT
|
||||
{
|
||||
if (_events != null)
|
||||
{
|
||||
EventHandler eh = (EventHandler)(_events[PreRenderEvent]);
|
||||
if (eh != null) eh(this, e);
|
||||
}
|
||||
}
|
||||
protected virtual void OnUnload(EventArgs e) //DIT
|
||||
{
|
||||
if (_events != null)
|
||||
{
|
||||
EventHandler eh = (EventHandler)(_events[UnloadEvent]);
|
||||
if (eh != null) eh(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected virtual void OnDataBinding (EventArgs e)
|
||||
{
|
||||
if ((event_mask & databinding_mask) != 0) {
|
||||
EventHandler eh = (EventHandler)(_events [DataBindingEvent]);
|
||||
if (eh != null) eh (this, e);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnInit (EventArgs e)
|
||||
{
|
||||
if ((event_mask & init_mask) != 0) {
|
||||
EventHandler eh = (EventHandler)(_events [InitEvent]);
|
||||
if (eh != null) eh (this, e);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnLoad (EventArgs e)
|
||||
{
|
||||
if ((event_mask & load_mask) != 0) {
|
||||
EventHandler eh = (EventHandler)(_events [LoadEvent]);
|
||||
if (eh != null) eh (this, e);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnPreRender (EventArgs e)
|
||||
{
|
||||
if ((event_mask & prerender_mask) != 0) {
|
||||
EventHandler eh = (EventHandler)(_events [PreRenderEvent]);
|
||||
if (eh != null) eh (this, e);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnUnload(EventArgs e)
|
||||
{
|
||||
if ((event_mask & unload_mask) != 0) {
|
||||
EventHandler eh = (EventHandler)(_events [UnloadEvent]);
|
||||
if (eh != null) eh (this, e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void RaiseBubbleEvent(object source, EventArgs args)
|
||||
{
|
||||
Control c = Parent;
|
||||
@@ -681,96 +690,70 @@ namespace System.Web.UI
|
||||
|
||||
stateMask |= TRACK_VIEWSTATE;
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
if (_events != null)
|
||||
{
|
||||
EventHandler eh = (EventHandler) _events [DisposedEvent];
|
||||
if (eh != null)
|
||||
eh(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Dispose ()
|
||||
{
|
||||
if ((event_mask & disposed_mask) != 0) {
|
||||
EventHandler eh = (EventHandler)(_events [DisposedEvent]);
|
||||
if (eh != null) eh (this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
[WebCategory ("FIXME")]
|
||||
[WebSysDescription ("Raised when the contols databound properties are evaluated.")]
|
||||
public event EventHandler DataBinding //DIT
|
||||
{
|
||||
add
|
||||
{
|
||||
Events.AddHandler(DataBindingEvent, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
Events.RemoveHandler(DataBindingEvent, value);
|
||||
}
|
||||
[WebSysDescription ("Raised when the contols databound properties are evaluated.")]
|
||||
public event EventHandler DataBinding {
|
||||
add {
|
||||
event_mask |= databinding_mask;
|
||||
Events.AddHandler (DataBindingEvent, value);
|
||||
}
|
||||
remove { Events.RemoveHandler (DataBindingEvent, value); }
|
||||
}
|
||||
|
||||
[WebSysDescription ("Raised when the contol is disposed.")]
|
||||
public event EventHandler Disposed //DIT
|
||||
{
|
||||
add
|
||||
{
|
||||
Events.AddHandler(DisposedEvent, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
Events.RemoveHandler(DisposedEvent, value);
|
||||
}
|
||||
[WebSysDescription ("Raised when the contol is disposed.")]
|
||||
public event EventHandler Disposed {
|
||||
add {
|
||||
event_mask |= disposed_mask;
|
||||
Events.AddHandler (DisposedEvent, value);
|
||||
}
|
||||
remove { Events.RemoveHandler (DisposedEvent, value); }
|
||||
}
|
||||
|
||||
[WebSysDescription ("Raised when the page containing the control is initialized.")]
|
||||
public event EventHandler Init //DIT
|
||||
{
|
||||
add
|
||||
{
|
||||
Events.AddHandler(InitEvent, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
Events.RemoveHandler(InitEvent, value);
|
||||
}
|
||||
[WebSysDescription ("Raised when the page containing the control is initialized.")]
|
||||
public event EventHandler Init {
|
||||
add {
|
||||
event_mask |= init_mask;
|
||||
Events.AddHandler (InitEvent, value);
|
||||
}
|
||||
remove { Events.RemoveHandler (InitEvent, value); }
|
||||
}
|
||||
|
||||
[WebSysDescription ("Raised after the page containing the control has been loaded.")]
|
||||
public event EventHandler Load //DIT
|
||||
{
|
||||
add
|
||||
{
|
||||
Events.AddHandler(LoadEvent, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
Events.RemoveHandler(LoadEvent, value);
|
||||
}
|
||||
[WebSysDescription ("Raised after the page containing the control has been loaded.")]
|
||||
public event EventHandler Load {
|
||||
add {
|
||||
event_mask |= load_mask;
|
||||
Events.AddHandler (LoadEvent, value);
|
||||
}
|
||||
remove { Events.RemoveHandler (LoadEvent, value); }
|
||||
}
|
||||
|
||||
[WebSysDescription ("Raised before the page containing the control is rendered.")]
|
||||
public event EventHandler PreRender //DIT
|
||||
{
|
||||
add
|
||||
{
|
||||
Events.AddHandler(PreRenderEvent, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
Events.RemoveHandler(PreRenderEvent, value);
|
||||
}
|
||||
[WebSysDescription ("Raised before the page containing the control is rendered.")]
|
||||
public event EventHandler PreRender {
|
||||
add {
|
||||
event_mask |= prerender_mask;
|
||||
Events.AddHandler (PreRenderEvent, value);
|
||||
}
|
||||
remove { Events.RemoveHandler (PreRenderEvent, value); }
|
||||
}
|
||||
|
||||
[WebSysDescription ("Raised when the page containing the control is unloaded.")]
|
||||
public event EventHandler Unload {
|
||||
add {
|
||||
event_mask |= unload_mask;
|
||||
Events.AddHandler (UnloadEvent, value);
|
||||
}
|
||||
remove { Events.RemoveHandler (UnloadEvent, value); }
|
||||
}
|
||||
|
||||
[WebSysDescription ("Raised when the page containing the control is unloaded.")]
|
||||
public event EventHandler Unload //DIT
|
||||
{
|
||||
add
|
||||
{
|
||||
Events.AddHandler(UnloadEvent, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
Events.RemoveHandler(UnloadEvent, value);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void DataBind() //DIT
|
||||
{
|
||||
#if NET_2_0
|
||||
|
||||
@@ -1192,40 +1192,65 @@ public class Page : TemplateControl, IHttpHandler
|
||||
static readonly object PreLoadEvent = new object ();
|
||||
static readonly object PreRenderCompleteEvent = new object ();
|
||||
static readonly object SaveStateCompleteEvent = new object ();
|
||||
int event_mask;
|
||||
const int initcomplete_mask = 1;
|
||||
const int loadcomplete_mask = 1 << 1;
|
||||
const int preinit_mask = 1 << 2;
|
||||
const int preload_mask = 1 << 3;
|
||||
const int prerendercomplete_mask = 1 << 4;
|
||||
const int savestatecomplete_mask = 1 << 5;
|
||||
|
||||
public event EventHandler InitComplete {
|
||||
add { Events.AddHandler (InitCompleteEvent, value); }
|
||||
add {
|
||||
event_mask |= initcomplete_mask;
|
||||
Events.AddHandler (InitCompleteEvent, value);
|
||||
}
|
||||
remove { Events.RemoveHandler (InitCompleteEvent, value); }
|
||||
}
|
||||
|
||||
public event EventHandler LoadComplete {
|
||||
add { Events.AddHandler (LoadCompleteEvent, value); }
|
||||
add {
|
||||
event_mask |= loadcomplete_mask;
|
||||
Events.AddHandler (LoadCompleteEvent, value);
|
||||
}
|
||||
remove { Events.RemoveHandler (LoadCompleteEvent, value); }
|
||||
}
|
||||
|
||||
public event EventHandler PreInit {
|
||||
add { Events.AddHandler (PreInitEvent, value); }
|
||||
add {
|
||||
event_mask |= preinit_mask;
|
||||
Events.AddHandler (PreInitEvent, value);
|
||||
}
|
||||
remove { Events.RemoveHandler (PreInitEvent, value); }
|
||||
}
|
||||
|
||||
public event EventHandler PreLoad {
|
||||
add { Events.AddHandler (PreLoadEvent, value); }
|
||||
add {
|
||||
event_mask |= preload_mask;
|
||||
Events.AddHandler (PreLoadEvent, value);
|
||||
}
|
||||
remove { Events.RemoveHandler (PreLoadEvent, value); }
|
||||
}
|
||||
|
||||
public event EventHandler PreRenderComplete {
|
||||
add { Events.AddHandler (PreRenderCompleteEvent, value); }
|
||||
add {
|
||||
event_mask |= prerendercomplete_mask;
|
||||
Events.AddHandler (PreRenderCompleteEvent, value);
|
||||
}
|
||||
remove { Events.RemoveHandler (PreRenderCompleteEvent, value); }
|
||||
}
|
||||
|
||||
public event EventHandler SaveStateComplete {
|
||||
add { Events.AddHandler (SaveStateCompleteEvent, value); }
|
||||
add {
|
||||
event_mask |= savestatecomplete_mask;
|
||||
Events.AddHandler (SaveStateCompleteEvent, value);
|
||||
}
|
||||
remove { Events.RemoveHandler (SaveStateCompleteEvent, value); }
|
||||
}
|
||||
|
||||
protected virtual void OnInitComplete (EventArgs e)
|
||||
{
|
||||
if (Events != null) {
|
||||
if ((event_mask & initcomplete_mask) != 0) {
|
||||
EventHandler eh = (EventHandler) (Events [InitCompleteEvent]);
|
||||
if (eh != null) eh (this, e);
|
||||
}
|
||||
@@ -1233,7 +1258,7 @@ public class Page : TemplateControl, IHttpHandler
|
||||
|
||||
protected virtual void OnLoadComplete (EventArgs e)
|
||||
{
|
||||
if (Events != null) {
|
||||
if ((event_mask & loadcomplete_mask) != 0) {
|
||||
EventHandler eh = (EventHandler) (Events [LoadCompleteEvent]);
|
||||
if (eh != null) eh (this, e);
|
||||
}
|
||||
@@ -1241,7 +1266,7 @@ public class Page : TemplateControl, IHttpHandler
|
||||
|
||||
protected virtual void OnPreInit (EventArgs e)
|
||||
{
|
||||
if (Events != null) {
|
||||
if ((event_mask & preinit_mask) != 0) {
|
||||
EventHandler eh = (EventHandler) (Events [PreInitEvent]);
|
||||
if (eh != null) eh (this, e);
|
||||
}
|
||||
@@ -1249,7 +1274,7 @@ public class Page : TemplateControl, IHttpHandler
|
||||
|
||||
protected virtual void OnPreLoad (EventArgs e)
|
||||
{
|
||||
if (Events != null) {
|
||||
if ((event_mask & preload_mask) != 0) {
|
||||
EventHandler eh = (EventHandler) (Events [PreLoadEvent]);
|
||||
if (eh != null) eh (this, e);
|
||||
}
|
||||
@@ -1257,7 +1282,7 @@ public class Page : TemplateControl, IHttpHandler
|
||||
|
||||
protected virtual void OnPreRenderComplete (EventArgs e)
|
||||
{
|
||||
if (Events != null) {
|
||||
if ((event_mask & prerendercomplete_mask) != 0) {
|
||||
EventHandler eh = (EventHandler) (Events [PreRenderCompleteEvent]);
|
||||
if (eh != null) eh (this, e);
|
||||
}
|
||||
@@ -1265,7 +1290,7 @@ public class Page : TemplateControl, IHttpHandler
|
||||
|
||||
protected virtual void OnSaveStateComplete (EventArgs e)
|
||||
{
|
||||
if (Events != null) {
|
||||
if ((event_mask & savestatecomplete_mask) != 0) {
|
||||
EventHandler eh = (EventHandler) (Events [SaveStateCompleteEvent]);
|
||||
if (eh != null) eh (this, e);
|
||||
}
|
||||
|
||||
@@ -246,7 +246,8 @@ namespace System.Web.UI
|
||||
masterPage = GetString (atts, "MasterPageFile", null);
|
||||
|
||||
// Make sure the page exists
|
||||
MasterPageParser.GetCompiledMasterType (masterPage, HttpContext.Current.Request.MapPath (masterPage), HttpContext.Current);
|
||||
if (masterPage != null)
|
||||
MasterPageParser.GetCompiledMasterType (masterPage, MapPath (masterPage), HttpContext.Current);
|
||||
#endif
|
||||
// Ignored by now
|
||||
GetString (atts, "EnableViewStateMac", null);
|
||||
@@ -267,7 +268,7 @@ namespace System.Web.UI
|
||||
} else {
|
||||
string path = GetString (atts, "VirtualPath", null);
|
||||
if (path != null)
|
||||
masterType = MasterPageParser.GetCompiledMasterType (path, HttpContext.Current.Request.MapPath (path), HttpContext.Current);
|
||||
masterType = MasterPageParser.GetCompiledMasterType (path, MapPath (path), HttpContext.Current);
|
||||
else
|
||||
ThrowParseException ("The MasterType directive must have either a TypeName or a VirtualPath attribute.");
|
||||
}
|
||||
|
||||
@@ -114,14 +114,16 @@ namespace System.Web.UI
|
||||
throw new ParseException (Location, "Could not find file \""
|
||||
+ realpath + "\".");
|
||||
|
||||
string vpath = UrlUtils.Combine (BaseVirtualDir, src);
|
||||
Type type = null;
|
||||
try {
|
||||
AddDependency (realpath);
|
||||
} catch (Exception e) {
|
||||
throw new ParseException (Location, e.Message);
|
||||
type = UserControlParser.GetCompiledType (vpath, realpath, Dependencies, Context);
|
||||
} catch (ParseException pe) {
|
||||
if (this is UserControlParser)
|
||||
throw new ParseException (Location, pe.Message, pe);
|
||||
throw;
|
||||
}
|
||||
|
||||
string vpath = UrlUtils.Combine (BaseVirtualDir, src);
|
||||
Type type = UserControlParser.GetCompiledType (vpath, realpath, Context);
|
||||
AddAssembly (type.Assembly, true);
|
||||
RootBuilder.Foundry.RegisterFoundry (tagprefix, tagname, type);
|
||||
return;
|
||||
@@ -147,7 +149,7 @@ namespace System.Web.UI
|
||||
PageParser pp = new PageParser (page, filepath, Context);
|
||||
ctype = pp.CompileIntoType ();
|
||||
} else {
|
||||
ctype = UserControlParser.GetCompiledType (control, filepath, Context);
|
||||
ctype = UserControlParser.GetCompiledType (control, filepath, Dependencies, Context);
|
||||
}
|
||||
|
||||
AddAssembly (ctype.Assembly, true);
|
||||
|
||||
@@ -324,7 +324,16 @@ namespace System.Web.UI
|
||||
if (!imports.Contains (namesp))
|
||||
imports.Add (namesp);
|
||||
}
|
||||
|
||||
|
||||
internal virtual void AddSourceDependency (string filename)
|
||||
{
|
||||
if (dependencies != null && dependencies.Contains (filename)) {
|
||||
ThrowParseException ("Circular file references are not allowed. File: " + filename);
|
||||
}
|
||||
|
||||
AddDependency (filename);
|
||||
}
|
||||
|
||||
internal virtual void AddDependency (string filename)
|
||||
{
|
||||
if (filename == "")
|
||||
@@ -453,7 +462,7 @@ namespace System.Web.UI
|
||||
if (!File.Exists (realPath))
|
||||
ThrowParseException ("File " + vpath + " not found");
|
||||
|
||||
AddDependency (realPath);
|
||||
AddSourceDependency (realPath);
|
||||
|
||||
CompilerResults result = CachingCompiler.Compile (language, realPath, realPath, assemblies);
|
||||
if (result.NativeCompilerReturnValue != 0) {
|
||||
@@ -557,6 +566,7 @@ namespace System.Web.UI
|
||||
|
||||
internal ArrayList Dependencies {
|
||||
get { return dependencies; }
|
||||
set { dependencies = value; }
|
||||
}
|
||||
|
||||
internal string CompilerOptions {
|
||||
|
||||
@@ -39,9 +39,15 @@ namespace System.Web.UI
|
||||
internal class UserControlParser : TemplateControlParser
|
||||
{
|
||||
internal UserControlParser (string virtualPath, string inputFile, HttpContext context)
|
||||
: this (virtualPath, inputFile, context, null)
|
||||
: this (virtualPath, inputFile, context, null)
|
||||
{
|
||||
}
|
||||
|
||||
internal UserControlParser (string virtualPath, string inputFile, ArrayList deps, HttpContext context)
|
||||
: this (virtualPath, inputFile, context, null)
|
||||
{
|
||||
this.Dependencies = deps;
|
||||
}
|
||||
|
||||
internal UserControlParser (string virtualPath, string inputFile, HttpContext context, string type)
|
||||
{
|
||||
@@ -53,6 +59,12 @@ namespace System.Web.UI
|
||||
AddApplicationAssembly ();
|
||||
}
|
||||
|
||||
internal static Type GetCompiledType (string virtualPath, string inputFile, ArrayList deps, HttpContext context)
|
||||
{
|
||||
UserControlParser ucp = new UserControlParser (virtualPath, inputFile, deps, context);
|
||||
return ucp.CompileIntoType ();
|
||||
}
|
||||
|
||||
public static Type GetCompiledType (string virtualPath, string inputFile, HttpContext context)
|
||||
{
|
||||
UserControlParser ucp = new UserControlParser (virtualPath, inputFile, context);
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
2005-06-26 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* UrlUtils.cs: (Combine) if the base path is "~", expand it.
|
||||
|
||||
2005-06-26 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* StrUtils.cs: new string utilities.
|
||||
|
||||
2005-05-09 Ben Maurer <[email protected]>
|
||||
|
||||
* UrlUtils.cs (Reduce): a more efficient impl that avoids an
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// System.Web.Util.StrUtils
|
||||
//
|
||||
// Author(s):
|
||||
// Gonzalo Paniagua Javier ([email protected])
|
||||
//
|
||||
// (C) 2005 Novell, Inc, (http://www.novell.com)
|
||||
//
|
||||
|
||||
//
|
||||
// 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;
|
||||
using System.Globalization;
|
||||
|
||||
namespace System.Web.Util {
|
||||
internal sealed class StrUtils {
|
||||
static CultureInfo invariant = CultureInfo.InvariantCulture;
|
||||
private StrUtils () { }
|
||||
|
||||
public static bool StartsWith (string str1, string str2)
|
||||
{
|
||||
return StartsWith (str1, str2, false);
|
||||
}
|
||||
|
||||
public static bool StartsWith (string str1, string str2, bool ignore_case)
|
||||
{
|
||||
int l2 = str2.Length;
|
||||
if (l2 == 0)
|
||||
return true;
|
||||
|
||||
int l1 = str1.Length;
|
||||
if (l2 > l1)
|
||||
return false;
|
||||
|
||||
return (0 == String.Compare (str1, 0, str2, 0, l2, ignore_case, invariant));
|
||||
}
|
||||
|
||||
public static bool EndsWith (string str1, string str2)
|
||||
{
|
||||
return EndsWith (str1, str2, false);
|
||||
}
|
||||
|
||||
public static bool EndsWith (string str1, string str2, bool ignore_case)
|
||||
{
|
||||
int l2 = str2.Length;
|
||||
if (l2 == 0)
|
||||
return true;
|
||||
|
||||
int l1 = str1.Length;
|
||||
if (l2 > l1)
|
||||
return false;
|
||||
|
||||
return (0 == String.Compare (str1, l1 - l2, str2, 0, l2, ignore_case, invariant));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace System.Web.Util
|
||||
return Reduce (basePath + slash + relPath);
|
||||
}
|
||||
|
||||
if (basePath == null || basePath == "")
|
||||
if (basePath == null || basePath == "" || basePath [0] == '~')
|
||||
basePath = HttpRuntime.AppDomainAppVirtualPath;
|
||||
|
||||
if (basePath.Length <= 1)
|
||||
|
||||
@@ -812,6 +812,7 @@ System.Web.Util/AltSerialization.cs
|
||||
System.Web.Util/DataSourceHelper.cs
|
||||
System.Web.Util/ICalls.cs
|
||||
System.Web.Util/NativeFileChangeEventHandler.cs
|
||||
System.Web.Util/StrUtils.cs
|
||||
System.Web.Util/TimeUtil.cs
|
||||
System.Web.Util/TransactedCallback.cs
|
||||
System.Web.Util/Transactions.cs
|
||||
|
||||
@@ -181,7 +181,9 @@ namespace System.Web
|
||||
lock (lockobj) {
|
||||
if (loaded)
|
||||
return;
|
||||
|
||||
#if TARGET_J2EE
|
||||
string filepath = "browscap.ini"
|
||||
#else
|
||||
string dir = Path.GetDirectoryName (WebConfigurationSettings.MachineConfigPath);
|
||||
string filepath = Path.Combine (dir, "browscap.ini");
|
||||
if (!File.Exists (filepath)) {
|
||||
@@ -189,7 +191,7 @@ namespace System.Web
|
||||
dir = Path.GetDirectoryName (dir);
|
||||
filepath = Path.Combine (dir, "browscap.ini");
|
||||
}
|
||||
|
||||
#endif
|
||||
try {
|
||||
LoadFile (filepath);
|
||||
} catch (Exception) { }
|
||||
@@ -197,13 +199,38 @@ namespace System.Web
|
||||
loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
#if TARGET_J2EE
|
||||
private static TextReader GetJavaTextReader(string filename)
|
||||
{
|
||||
Stream s;
|
||||
try
|
||||
{
|
||||
java.lang.ClassLoader cl = (java.lang.ClassLoader)
|
||||
AppDomain.CurrentDomain.GetData("GH_ContextClassLoader");
|
||||
if (cl == null)
|
||||
return null;
|
||||
java.io.InputStream inputStream = cl.getResourceAsStream(filename);
|
||||
s = (Stream)vmw.common.IOUtils.getStream(inputStream);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return = new StreamReader (s);
|
||||
}
|
||||
#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
|
||||
string str;
|
||||
Hashtable allhash = new Hashtable ();
|
||||
int aux = 0;
|
||||
|
||||
@@ -1,3 +1,68 @@
|
||||
2005-06-27 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* HttpResponseHeader.cs: URL encode \r and \n in header values. Fixes
|
||||
bug #75392.
|
||||
|
||||
2005-06-26 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* HttpUtility.cs: fix another stupid buglet in htmldecode.
|
||||
|
||||
2005-06-26 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* HttpContext.cs:
|
||||
* HttpResponse.cs:
|
||||
* HttpRequest.cs: use StrUtils (invariant culture).
|
||||
|
||||
2005-06-26 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* HttpRequest.cs: use StartsWith when looking for 'multipart/form-data'.
|
||||
File uploading was broken since a few commits ago.
|
||||
|
||||
2005-06-26 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* HttpResponse.cs: ensure that the last chunk ('0\r\n\r\n') is sent
|
||||
even if response.Close is called before a final flush. MS/IIS fails to
|
||||
do this.
|
||||
|
||||
2005-06-25 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* HttpRequest.cs: don't print anything for unknown content types in
|
||||
ParseFormData. Use lowercase compare.
|
||||
|
||||
2005-06-25 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* HttpResponse.cs: invariant love.
|
||||
|
||||
2005-06-25 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* HttpResponse.cs: avoid 1 string concat.
|
||||
* HttpRequest.cs: fix BinaryRead. It was totally wrong.
|
||||
|
||||
2005-06-23 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* HttpUtility.cs: don't append an extra 0 when no digits seen. Fixes
|
||||
bug #75370.
|
||||
|
||||
2005-06-23 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* HttpUtility.cs: the lower limit for using &#xx; encoding is 160, not
|
||||
128. Reset number back to 0 after use. Fixes bug #75365.
|
||||
|
||||
2005-06-19 Svetlana Zholkovsky <svetlanaz-at-mainsoft.com>
|
||||
* In following classes added TARGET_J2EE or/and TARGET_JVM
|
||||
directives:
|
||||
- HttpResponse.cs
|
||||
- HttpRuntime.cs
|
||||
- HttpUtility.cs
|
||||
- CapabilitiesLoader.cs
|
||||
- HttpApplication.cs
|
||||
- HttpApplicationFactory.cs
|
||||
- HttpContext.cs
|
||||
- HttpException.cs
|
||||
- HttpRequest.cs
|
||||
* Added Mainsoft's specific files :
|
||||
- GhHttpAsyncResult.jvm.cs
|
||||
|
||||
2005-06-10 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* HttpRequest.cs: avoid one intermediate buffer when reading the request
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// System.Web.HttpAsyncResult
|
||||
//
|
||||
// Author:
|
||||
// Patrik Torstensson ([email protected])
|
||||
//
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace System.Web
|
||||
{
|
||||
internal class GhHttpAsyncResult : IAsyncResult
|
||||
{
|
||||
private object _result;
|
||||
private object _asyncState;
|
||||
private AsyncCallback _callback;
|
||||
private Exception _error;
|
||||
|
||||
private bool _ready;
|
||||
private bool _readySync;
|
||||
|
||||
internal GhHttpAsyncResult(AsyncCallback callback, object state) {
|
||||
_callback = callback;
|
||||
_asyncState = state;
|
||||
}
|
||||
|
||||
internal void Complete(bool sync, object result, Exception error) {
|
||||
_ready = true;
|
||||
_readySync = sync;
|
||||
_result = result;
|
||||
_error = error;
|
||||
if (null != _callback) {
|
||||
_callback(this);
|
||||
}
|
||||
}
|
||||
|
||||
internal Exception Error {
|
||||
get {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public object AsyncState {
|
||||
get {
|
||||
return _asyncState;
|
||||
}
|
||||
}
|
||||
|
||||
public object AsyncObject {
|
||||
get {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public WaitHandle AsyncWaitHandle {
|
||||
get {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CompletedSynchronously {
|
||||
get {
|
||||
return _readySync;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsCompleted {
|
||||
get {
|
||||
return _ready;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1056,7 +1056,11 @@ namespace System.Web
|
||||
internal void Start ()
|
||||
{
|
||||
Reset ();
|
||||
#if !TARGET_J2EE
|
||||
ExecuteNextAsync (null);
|
||||
#else
|
||||
ExecuteNext(null);
|
||||
#endif
|
||||
}
|
||||
|
||||
internal void ExecuteNextAsync (Exception lasterror)
|
||||
@@ -1131,6 +1135,37 @@ namespace System.Web
|
||||
ExecuteNext ((Exception) obj);
|
||||
}
|
||||
|
||||
#if TARGET_J2EE
|
||||
private Exception HandleJavaException(Exception obj)
|
||||
{
|
||||
Exception lasterror = null;
|
||||
|
||||
if (obj is System.Reflection.TargetInvocationException )
|
||||
{
|
||||
lasterror = obj.InnerException;
|
||||
#if DEBUG
|
||||
if (lasterror is java.lang.reflect.InvocationTargetException) {
|
||||
Console.WriteLine("Got java.lang.reflect.InvocationTargetException caused by");
|
||||
java.lang.reflect.InvocationTargetException e1 = (java.lang.reflect.InvocationTargetException)lasterror;
|
||||
Console.WriteLine("{0},{1}", e1.getTargetException().GetType(), e1.getTargetException().Message);
|
||||
Console.WriteLine(e1.getTargetException().StackTrace);
|
||||
} else
|
||||
#endif
|
||||
if (lasterror is vmw.@internal.j2ee.StopExecutionException)
|
||||
{
|
||||
lasterror = null;
|
||||
_app.CompleteRequest ();
|
||||
}
|
||||
#if DEBUG
|
||||
else {
|
||||
Console.WriteLine("Error 1!!! {0}:{1}", lasterror.GetType(), lasterror.Message);
|
||||
Console.WriteLine(lasterror.StackTrace);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return lasterror;
|
||||
}
|
||||
#endif
|
||||
private Exception ExecuteState (IStateHandler state, ref bool readysync)
|
||||
{
|
||||
Exception lasterror = null;
|
||||
@@ -1146,13 +1181,23 @@ namespace System.Web
|
||||
_app.Context.EndTimeoutPossible ();
|
||||
}
|
||||
}
|
||||
|
||||
#if TARGET_J2EE //Catch case of aborting by timeout
|
||||
if (_app.Context.TimedOut) {
|
||||
_app.CompleteRequest ();
|
||||
return null;
|
||||
}
|
||||
#endif
|
||||
if (state.PossibleToTimeout) {
|
||||
// Async Execute
|
||||
_app.Context.TryWaitForTimeout ();
|
||||
}
|
||||
|
||||
readysync = state.CompletedSynchronously;
|
||||
#if TARGET_J2EE // Finishing execution for End without error
|
||||
}catch (vmw.@internal.j2ee.StopExecutionException){
|
||||
lasterror = null;
|
||||
_app.CompleteRequest ();
|
||||
#endif
|
||||
} catch (ThreadAbortException obj) {
|
||||
object o = obj.ExceptionState;
|
||||
Type type = (o != null) ? o.GetType () : null;
|
||||
@@ -1165,7 +1210,11 @@ namespace System.Web
|
||||
_app.CompleteRequest ();
|
||||
}
|
||||
} catch (Exception obj) {
|
||||
#if TARGET_J2EE
|
||||
lasterror = HandleJavaException(obj);
|
||||
#else
|
||||
lasterror = obj;
|
||||
#endif
|
||||
}
|
||||
|
||||
return lasterror;
|
||||
@@ -1203,10 +1252,16 @@ namespace System.Web
|
||||
|
||||
#region Constructor
|
||||
|
||||
#if TARGET_J2EE
|
||||
public HttpApplication ()
|
||||
{
|
||||
}
|
||||
#else
|
||||
public HttpApplication ()
|
||||
{
|
||||
assemblyLocation = GetType ().Assembly.Location;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1341,7 +1396,14 @@ namespace System.Web
|
||||
HttpContext.Context = _savedContext;
|
||||
RestorePrincipal ();
|
||||
}
|
||||
|
||||
#if TARGET_J2EE
|
||||
internal void SetPrincipal (IPrincipal principal)
|
||||
{
|
||||
}
|
||||
internal void RestorePrincipal ()
|
||||
{
|
||||
}
|
||||
#else
|
||||
internal void SetPrincipal (IPrincipal principal)
|
||||
{
|
||||
// Don't overwrite _savedUser if called from inside a step
|
||||
@@ -1359,7 +1421,7 @@ namespace System.Web
|
||||
Thread.CurrentPrincipal = _savedUser;
|
||||
_savedUser = null;
|
||||
}
|
||||
|
||||
#endif
|
||||
internal void ClearError ()
|
||||
{
|
||||
_lastError = null;
|
||||
@@ -1583,6 +1645,14 @@ namespace System.Web
|
||||
[Browsable (false)]
|
||||
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
|
||||
public HttpSessionState Session {
|
||||
#if TARGET_J2EE
|
||||
get {
|
||||
if (null != _Context && null != _Context.Session)
|
||||
return _Context.Session;
|
||||
|
||||
throw new HttpException ("Failed to get session object");
|
||||
}
|
||||
#else
|
||||
get {
|
||||
if (null != _Session)
|
||||
return _Session;
|
||||
@@ -1592,6 +1662,7 @@ namespace System.Web
|
||||
|
||||
throw new HttpException ("Failed to get session object");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
[Browsable (false)]
|
||||
|
||||
@@ -34,8 +34,13 @@ using System.Collections;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Web.UI;
|
||||
using System.Web.Compilation;
|
||||
using System.Web.SessionState;
|
||||
#if !TARGET_J2EE
|
||||
using System.Web.Compilation;
|
||||
#else
|
||||
using System.Web.Configuration;
|
||||
using vmw.common;
|
||||
#endif
|
||||
|
||||
namespace System.Web {
|
||||
class HttpApplicationFactory {
|
||||
@@ -53,30 +58,60 @@ namespace System.Web {
|
||||
|
||||
static private int _appMaxFreePublicInstances = 32;
|
||||
|
||||
private HttpApplicationState _state;
|
||||
|
||||
static IHttpHandler custApplication;
|
||||
|
||||
static private HttpApplicationFactory s_Factory = new HttpApplicationFactory();
|
||||
|
||||
public HttpApplicationFactory() {
|
||||
_appInitialized = false;
|
||||
_appFiredEnd = false;
|
||||
|
||||
_appFreePublicList = new Stack();
|
||||
_appFreePublicInstances = 0;
|
||||
}
|
||||
|
||||
static private string GetAppFilename (HttpContext context)
|
||||
{
|
||||
string physicalAppPath = context.Request.PhysicalApplicationPath;
|
||||
string appFilePath = Path.Combine (physicalAppPath, "Global.asax");
|
||||
if (File.Exists (appFilePath))
|
||||
return appFilePath;
|
||||
|
||||
return Path.Combine (physicalAppPath, "global.asax");
|
||||
}
|
||||
private HttpApplicationState _state;
|
||||
|
||||
static IHttpHandler custApplication;
|
||||
|
||||
#if TARGET_J2EE
|
||||
static private HttpApplicationFactory s_Factory {
|
||||
get {
|
||||
HttpApplicationFactory factory = (HttpApplicationFactory)AppDomain.CurrentDomain.GetData("HttpApplicationFactory");
|
||||
if (factory == null) {
|
||||
factory = new HttpApplicationFactory();
|
||||
AppDomain.CurrentDomain.SetData("HttpApplicationFactory", factory);
|
||||
}
|
||||
return factory;
|
||||
}
|
||||
}
|
||||
#else
|
||||
static private HttpApplicationFactory s_Factory = new HttpApplicationFactory();
|
||||
#endif
|
||||
public HttpApplicationFactory() {
|
||||
_appInitialized = false;
|
||||
_appFiredEnd = false;
|
||||
|
||||
_appFreePublicList = new Stack();
|
||||
_appFreePublicInstances = 0;
|
||||
}
|
||||
|
||||
static private string GetAppFilename (HttpContext context)
|
||||
{
|
||||
string physicalAppPath = context.Request.PhysicalApplicationPath;
|
||||
string appFilePath = Path.Combine (physicalAppPath, "Global.asax");
|
||||
if (File.Exists (appFilePath))
|
||||
return appFilePath;
|
||||
|
||||
return Path.Combine (physicalAppPath, "global.asax");
|
||||
}
|
||||
#if TARGET_J2EE
|
||||
void CompileApp(HttpContext context)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
String url = IAppDomainConfig.WAR_ROOT_SYMBOL+"/global.asax";
|
||||
_appType = System.Web.GH.PageMapper.GetObjectType(url);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_appType = typeof (System.Web.HttpApplication);
|
||||
}
|
||||
_state = new HttpApplicationState ();
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !TARGET_J2EE
|
||||
void CompileApp (HttpContext context)
|
||||
{
|
||||
if (File.Exists (_appFilename)) {
|
||||
@@ -92,61 +127,62 @@ namespace System.Web {
|
||||
_state = new HttpApplicationState ();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool IsEventHandler (MethodInfo m)
|
||||
{
|
||||
if (m.ReturnType != typeof (void))
|
||||
return false;
|
||||
|
||||
ParameterInfo [] pi = m.GetParameters ();
|
||||
int length = pi.Length;
|
||||
if (length == 0)
|
||||
return true;
|
||||
|
||||
if (length != 2)
|
||||
return false;
|
||||
|
||||
if (pi [0].ParameterType != typeof (object) ||
|
||||
pi [1].ParameterType != typeof (EventArgs))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void AddEvent (MethodInfo method, Hashtable appTypeEventHandlers)
|
||||
{
|
||||
string name = method.Name.Replace ("_On", "_");
|
||||
if (appTypeEventHandlers [name] == null) {
|
||||
appTypeEventHandlers [name] = method;
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList list;
|
||||
if (appTypeEventHandlers [name] is MethodInfo)
|
||||
list = new ArrayList ();
|
||||
else
|
||||
list = appTypeEventHandlers [name] as ArrayList;
|
||||
|
||||
list.Add (method);
|
||||
}
|
||||
|
||||
static Hashtable GetApplicationTypeEvents (HttpApplication app)
|
||||
{
|
||||
Type appType = app.GetType ();
|
||||
Hashtable appTypeEventHandlers = new Hashtable ();
|
||||
BindingFlags flags = BindingFlags.Public |
|
||||
BindingFlags.NonPublic |
|
||||
BindingFlags.Instance |
|
||||
BindingFlags.Static;
|
||||
|
||||
MethodInfo [] methods = appType.GetMethods (flags);
|
||||
foreach (MethodInfo m in methods) {
|
||||
if (IsEventHandler (m))
|
||||
AddEvent (m, appTypeEventHandlers);
|
||||
}
|
||||
|
||||
return appTypeEventHandlers;
|
||||
}
|
||||
static bool IsEventHandler (MethodInfo m)
|
||||
{
|
||||
if (m.ReturnType != typeof (void))
|
||||
return false;
|
||||
|
||||
ParameterInfo [] pi = m.GetParameters ();
|
||||
int length = pi.Length;
|
||||
if (length == 0)
|
||||
return true;
|
||||
|
||||
if (length != 2)
|
||||
return false;
|
||||
|
||||
if (pi [0].ParameterType != typeof (object) ||
|
||||
pi [1].ParameterType != typeof (EventArgs))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void AddEvent (MethodInfo method, Hashtable appTypeEventHandlers)
|
||||
{
|
||||
string name = method.Name.Replace ("_On", "_");
|
||||
if (appTypeEventHandlers [name] == null) {
|
||||
appTypeEventHandlers [name] = method;
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList list;
|
||||
if (appTypeEventHandlers [name] is MethodInfo)
|
||||
list = new ArrayList ();
|
||||
else
|
||||
list = appTypeEventHandlers [name] as ArrayList;
|
||||
|
||||
list.Add (method);
|
||||
}
|
||||
|
||||
static Hashtable GetApplicationTypeEvents (HttpApplication app)
|
||||
{
|
||||
Type appType = app.GetType ();
|
||||
Hashtable appTypeEventHandlers = new Hashtable ();
|
||||
BindingFlags flags = BindingFlags.Public |
|
||||
BindingFlags.NonPublic |
|
||||
BindingFlags.Instance |
|
||||
BindingFlags.Static;
|
||||
|
||||
MethodInfo [] methods = appType.GetMethods (flags);
|
||||
foreach (MethodInfo m in methods) {
|
||||
if (IsEventHandler (m))
|
||||
AddEvent (m, appTypeEventHandlers);
|
||||
}
|
||||
|
||||
return appTypeEventHandlers;
|
||||
}
|
||||
|
||||
static bool FireEvent (string method_name, object target, object [] args)
|
||||
{
|
||||
@@ -166,10 +202,10 @@ namespace System.Web {
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static void FireOnAppStart (HttpApplication app)
|
||||
internal static void FireOnAppStart (HttpApplication app)
|
||||
{
|
||||
object [] args = new object [] {app, EventArgs.Empty};
|
||||
FireEvent ("Application_Start", app, args);
|
||||
object [] args = new object [] {app, EventArgs.Empty};
|
||||
FireEvent ("Application_Start", app, args);
|
||||
}
|
||||
|
||||
void FireOnAppEnd ()
|
||||
@@ -206,17 +242,17 @@ namespace System.Web {
|
||||
HttpRuntime.UnloadAppDomain ();
|
||||
}
|
||||
|
||||
private void InitializeFactory (HttpContext context)
|
||||
{
|
||||
_appFilename = GetAppFilename (context);
|
||||
|
||||
CompileApp (context);
|
||||
|
||||
// Create a application object
|
||||
HttpApplication app = (HttpApplication) HttpRuntime.CreateInternalObject (_appType);
|
||||
|
||||
// Startup
|
||||
app.Startup(context, HttpApplicationFactory.ApplicationState);
|
||||
private void InitializeFactory (HttpContext context)
|
||||
{
|
||||
_appFilename = GetAppFilename (context);
|
||||
|
||||
CompileApp (context);
|
||||
|
||||
// Create a application object
|
||||
HttpApplication app = (HttpApplication) HttpRuntime.CreateInternalObject (_appType);
|
||||
|
||||
// Startup
|
||||
app.Startup(context, HttpApplicationFactory.ApplicationState);
|
||||
|
||||
// Shutdown the application if bin directory changes.
|
||||
string binFiles = HttpRuntime.BinDirectory;
|
||||
@@ -225,189 +261,218 @@ namespace System.Web {
|
||||
|
||||
binWatcher = CreateWatcher (binFiles, new FileSystemEventHandler (OnAppFileChanged));
|
||||
|
||||
// Fire OnAppStart
|
||||
HttpApplicationFactory.FireOnAppStart (app);
|
||||
|
||||
// Recycle our application instance
|
||||
RecyclePublicInstance(app);
|
||||
}
|
||||
|
||||
private void Dispose() {
|
||||
ArrayList torelease = new ArrayList();
|
||||
lock (_appFreePublicList) {
|
||||
while (_appFreePublicList.Count > 0) {
|
||||
torelease.Add(_appFreePublicList.Pop());
|
||||
_appFreePublicInstances--;
|
||||
}
|
||||
}
|
||||
|
||||
if (torelease.Count > 0) {
|
||||
foreach (Object obj in torelease) {
|
||||
((HttpApplication) obj).Cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
if (!_appFiredEnd) {
|
||||
lock (this) {
|
||||
if (!_appFiredEnd) {
|
||||
FireOnAppEnd();
|
||||
_appFiredEnd = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static IHttpHandler GetInstance(HttpContext context)
|
||||
{
|
||||
if (custApplication != null)
|
||||
return custApplication;
|
||||
|
||||
if (!s_Factory._appInitialized) {
|
||||
lock (s_Factory) {
|
||||
if (!s_Factory._appInitialized) {
|
||||
s_Factory.InitializeFactory(context);
|
||||
s_Factory._appInitialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return s_Factory.GetPublicInstance(context);
|
||||
}
|
||||
|
||||
internal static void RecycleInstance(HttpApplication app) {
|
||||
if (!s_Factory._appInitialized)
|
||||
throw new InvalidOperationException("Factory not intialized");
|
||||
|
||||
s_Factory.RecyclePublicInstance(app);
|
||||
}
|
||||
|
||||
internal static void AttachEvents (HttpApplication app)
|
||||
{
|
||||
Hashtable possibleEvents = GetApplicationTypeEvents (app);
|
||||
foreach (string key in possibleEvents.Keys) {
|
||||
int pos = key.IndexOf ('_');
|
||||
if (pos == -1 || key.Length <= pos + 1)
|
||||
continue;
|
||||
|
||||
string moduleName = key.Substring (0, pos);
|
||||
object target;
|
||||
if (moduleName == "Application") {
|
||||
target = app;
|
||||
} else {
|
||||
target = app.Modules [moduleName];
|
||||
if (target == null)
|
||||
continue;
|
||||
}
|
||||
|
||||
string eventName = key.Substring (pos + 1);
|
||||
EventInfo evt = target.GetType ().GetEvent (eventName);
|
||||
if (evt == null)
|
||||
continue;
|
||||
|
||||
string usualName = moduleName + "_" + eventName;
|
||||
object methodData = possibleEvents [usualName];
|
||||
if (methodData == null)
|
||||
continue;
|
||||
|
||||
if (methodData is MethodInfo) {
|
||||
AddHandler (evt, target, app, (MethodInfo) methodData);
|
||||
continue;
|
||||
}
|
||||
|
||||
ArrayList list = (ArrayList) methodData;
|
||||
foreach (MethodInfo method in list)
|
||||
AddHandler (evt, target, app, method);
|
||||
}
|
||||
}
|
||||
|
||||
static void AddHandler (EventInfo evt, object target, HttpApplication app, MethodInfo method)
|
||||
{
|
||||
int length = method.GetParameters ().Length;
|
||||
|
||||
if (length == 0) {
|
||||
NoParamsInvoker npi = new NoParamsInvoker (app, method.Name);
|
||||
evt.AddEventHandler (target, npi.FakeDelegate);
|
||||
} else {
|
||||
evt.AddEventHandler (target, Delegate.CreateDelegate (
|
||||
typeof (EventHandler), app, method.Name));
|
||||
}
|
||||
}
|
||||
|
||||
private IHttpHandler GetPublicInstance(HttpContext context) {
|
||||
HttpApplication app = null;
|
||||
|
||||
lock (_appFreePublicList) {
|
||||
if (_appFreePublicInstances > 0) {
|
||||
app = (HttpApplication) _appFreePublicList.Pop();
|
||||
_appFreePublicInstances--;
|
||||
}
|
||||
}
|
||||
|
||||
if (app == null) {
|
||||
// Create non-public object
|
||||
app = (HttpApplication) HttpRuntime.CreateInternalObject(_appType);
|
||||
|
||||
app.Startup(context, HttpApplicationFactory.ApplicationState);
|
||||
}
|
||||
|
||||
return (IHttpHandler) app;
|
||||
}
|
||||
|
||||
internal void RecyclePublicInstance(HttpApplication app) {
|
||||
lock (_appFreePublicList) {
|
||||
if (_appFreePublicInstances < _appMaxFreePublicInstances) {
|
||||
_appFreePublicList.Push(app);
|
||||
_appFreePublicInstances++;
|
||||
|
||||
app = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (app != null) {
|
||||
app.Cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
static HttpStaticObjectsCollection MakeStaticCollection (ArrayList list)
|
||||
{
|
||||
if (list == null || list.Count == 0)
|
||||
return null;
|
||||
|
||||
HttpStaticObjectsCollection coll = new HttpStaticObjectsCollection ();
|
||||
foreach (ObjectTagBuilder tag in list) {
|
||||
coll.Add (tag);
|
||||
}
|
||||
|
||||
return coll;
|
||||
}
|
||||
|
||||
static internal HttpApplicationState ApplicationState {
|
||||
get {
|
||||
if (null == s_Factory._state) {
|
||||
HttpStaticObjectsCollection app = MakeStaticCollection (GlobalAsaxCompiler.ApplicationObjects);
|
||||
HttpStaticObjectsCollection ses = MakeStaticCollection (GlobalAsaxCompiler.SessionObjects);
|
||||
s_Factory._state = new HttpApplicationState (app, ses);
|
||||
}
|
||||
|
||||
return s_Factory._state;
|
||||
}
|
||||
}
|
||||
|
||||
internal static void EndApplication() {
|
||||
s_Factory.Dispose();
|
||||
}
|
||||
|
||||
public static void SetCustomApplication (IHttpHandler customApplication)
|
||||
{
|
||||
custApplication = customApplication;
|
||||
}
|
||||
|
||||
internal Type AppType {
|
||||
get { return _appType; }
|
||||
}
|
||||
|
||||
internal static void SignalError(Exception exc) {
|
||||
// TODO: Raise an error (we probably don't have a HttpContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fire OnAppStart
|
||||
HttpApplicationFactory.FireOnAppStart (app);
|
||||
|
||||
// Recycle our application instance
|
||||
RecyclePublicInstance(app);
|
||||
}
|
||||
|
||||
private void Dispose() {
|
||||
ArrayList torelease = new ArrayList();
|
||||
lock (_appFreePublicList) {
|
||||
while (_appFreePublicList.Count > 0) {
|
||||
torelease.Add(_appFreePublicList.Pop());
|
||||
_appFreePublicInstances--;
|
||||
}
|
||||
}
|
||||
|
||||
if (torelease.Count > 0) {
|
||||
foreach (Object obj in torelease) {
|
||||
((HttpApplication) obj).Cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
if (!_appFiredEnd) {
|
||||
lock (this) {
|
||||
if (!_appFiredEnd) {
|
||||
FireOnAppEnd();
|
||||
_appFiredEnd = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static IHttpHandler GetInstance(HttpContext context)
|
||||
{
|
||||
if (custApplication != null)
|
||||
return custApplication;
|
||||
|
||||
if (!s_Factory._appInitialized) {
|
||||
lock (s_Factory) {
|
||||
if (!s_Factory._appInitialized) {
|
||||
s_Factory.InitializeFactory(context);
|
||||
s_Factory._appInitialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return s_Factory.GetPublicInstance(context);
|
||||
}
|
||||
|
||||
internal static void RecycleInstance(HttpApplication app) {
|
||||
if (!s_Factory._appInitialized)
|
||||
throw new InvalidOperationException("Factory not intialized");
|
||||
|
||||
s_Factory.RecyclePublicInstance(app);
|
||||
}
|
||||
|
||||
internal static void AttachEvents (HttpApplication app)
|
||||
{
|
||||
Hashtable possibleEvents = GetApplicationTypeEvents (app);
|
||||
foreach (string key in possibleEvents.Keys) {
|
||||
int pos = key.IndexOf ('_');
|
||||
if (pos == -1 || key.Length <= pos + 1)
|
||||
continue;
|
||||
|
||||
string moduleName = key.Substring (0, pos);
|
||||
object target;
|
||||
if (moduleName == "Application") {
|
||||
target = app;
|
||||
} else {
|
||||
target = app.Modules [moduleName];
|
||||
if (target == null)
|
||||
continue;
|
||||
}
|
||||
|
||||
string eventName = key.Substring (pos + 1);
|
||||
EventInfo evt = target.GetType ().GetEvent (eventName);
|
||||
if (evt == null)
|
||||
continue;
|
||||
|
||||
string usualName = moduleName + "_" + eventName;
|
||||
object methodData = possibleEvents [usualName];
|
||||
if (methodData == null)
|
||||
continue;
|
||||
|
||||
if (methodData is MethodInfo) {
|
||||
AddHandler (evt, target, app, (MethodInfo) methodData);
|
||||
continue;
|
||||
}
|
||||
|
||||
ArrayList list = (ArrayList) methodData;
|
||||
foreach (MethodInfo method in list)
|
||||
AddHandler (evt, target, app, method);
|
||||
}
|
||||
}
|
||||
|
||||
static void AddHandler (EventInfo evt, object target, HttpApplication app, MethodInfo method)
|
||||
{
|
||||
int length = method.GetParameters ().Length;
|
||||
|
||||
if (length == 0) {
|
||||
NoParamsInvoker npi = new NoParamsInvoker (app, method.Name);
|
||||
evt.AddEventHandler (target, npi.FakeDelegate);
|
||||
} else {
|
||||
evt.AddEventHandler (target, Delegate.CreateDelegate (
|
||||
typeof (EventHandler), app, method.Name));
|
||||
}
|
||||
}
|
||||
|
||||
#if TARGET_J2EE
|
||||
internal HttpApplication GetPublicInstance()
|
||||
{
|
||||
HttpApplication app = null;
|
||||
|
||||
lock (_appFreePublicList)
|
||||
{
|
||||
if (_appFreePublicInstances > 0)
|
||||
{
|
||||
app = (HttpApplication) _appFreePublicList.Pop();
|
||||
_appFreePublicInstances--;
|
||||
}
|
||||
}
|
||||
return app;
|
||||
}
|
||||
#endif
|
||||
|
||||
private IHttpHandler GetPublicInstance(HttpContext context) {
|
||||
HttpApplication app = null;
|
||||
|
||||
lock (_appFreePublicList) {
|
||||
if (_appFreePublicInstances > 0) {
|
||||
app = (HttpApplication) _appFreePublicList.Pop();
|
||||
_appFreePublicInstances--;
|
||||
}
|
||||
}
|
||||
|
||||
if (app == null) {
|
||||
// Create non-public object
|
||||
app = (HttpApplication) HttpRuntime.CreateInternalObject(_appType);
|
||||
|
||||
app.Startup(context, HttpApplicationFactory.ApplicationState);
|
||||
}
|
||||
|
||||
return (IHttpHandler) app;
|
||||
}
|
||||
|
||||
internal void RecyclePublicInstance(HttpApplication app) {
|
||||
lock (_appFreePublicList) {
|
||||
if (_appFreePublicInstances < _appMaxFreePublicInstances) {
|
||||
_appFreePublicList.Push(app);
|
||||
_appFreePublicInstances++;
|
||||
|
||||
app = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (app != null) {
|
||||
app.Cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
static HttpStaticObjectsCollection MakeStaticCollection (ArrayList list)
|
||||
{
|
||||
if (list == null || list.Count == 0)
|
||||
return null;
|
||||
|
||||
HttpStaticObjectsCollection coll = new HttpStaticObjectsCollection ();
|
||||
foreach (ObjectTagBuilder tag in list) {
|
||||
coll.Add (tag);
|
||||
}
|
||||
|
||||
return coll;
|
||||
}
|
||||
|
||||
static internal HttpApplicationState ApplicationState {
|
||||
#if TARGET_J2EE
|
||||
get {
|
||||
if (null == s_Factory._state) {
|
||||
HttpStaticObjectsCollection app = null;
|
||||
HttpStaticObjectsCollection ses = null;
|
||||
s_Factory._state = new HttpApplicationState (app, ses);
|
||||
}
|
||||
|
||||
return s_Factory._state;
|
||||
}
|
||||
#else
|
||||
get {
|
||||
if (null == s_Factory._state) {
|
||||
HttpStaticObjectsCollection app = MakeStaticCollection (GlobalAsaxCompiler.ApplicationObjects);
|
||||
HttpStaticObjectsCollection ses = MakeStaticCollection (GlobalAsaxCompiler.SessionObjects);
|
||||
s_Factory._state = new HttpApplicationState (app, ses);
|
||||
}
|
||||
|
||||
return s_Factory._state;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
internal static void EndApplication() {
|
||||
s_Factory.Dispose();
|
||||
}
|
||||
|
||||
public static void SetCustomApplication (IHttpHandler customApplication)
|
||||
{
|
||||
custApplication = customApplication;
|
||||
}
|
||||
|
||||
internal Type AppType {
|
||||
get { return _appType; }
|
||||
}
|
||||
|
||||
internal static void SignalError(Exception exc) {
|
||||
// TODO: Raise an error (we probably don't have a HttpContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,10 @@ namespace System.Web
|
||||
string errorPage;
|
||||
IPrincipal user;
|
||||
|
||||
#if TARGET_J2EE
|
||||
private object LOCK = new object();
|
||||
#endif
|
||||
|
||||
#if NET_2_0
|
||||
private System.Web.UI.Page lastPage;
|
||||
#endif
|
||||
@@ -202,13 +206,33 @@ namespace System.Web
|
||||
}
|
||||
}
|
||||
|
||||
#if TARGET_J2EE
|
||||
public bool IsDebuggingEnabled
|
||||
{
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#else
|
||||
public bool IsDebuggingEnabled
|
||||
{
|
||||
get {
|
||||
return CompilationConfiguration.GetInstance (this).Debug;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TARGET_J2EE
|
||||
private bool _timedOut;
|
||||
internal bool TimedOut {
|
||||
get {
|
||||
return _timedOut;
|
||||
}
|
||||
set {
|
||||
_timedOut = value;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
public IDictionary Items
|
||||
{
|
||||
get {
|
||||
@@ -280,16 +304,32 @@ namespace System.Web
|
||||
set { user = value; }
|
||||
}
|
||||
|
||||
#if TARGET_J2EE
|
||||
internal bool TimeoutPossible {
|
||||
get { return (timeoutPossible==1);}
|
||||
}
|
||||
internal void EndTimeoutPossible () {
|
||||
timeoutPossible = 0;
|
||||
}
|
||||
internal void TryWaitForTimeout () {
|
||||
while (TimeoutPossible) {
|
||||
Thread.Sleep (500);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !TARGET_J2EE
|
||||
internal bool TimeoutPossible {
|
||||
get { return (Interlocked.CompareExchange (ref timeoutPossible, 1, 1) == 1); }
|
||||
}
|
||||
|
||||
#endif
|
||||
internal void BeginTimeoutPossible ()
|
||||
{
|
||||
timeoutPossible = 1;
|
||||
timeoutBegin = DateTime.UtcNow.Ticks;
|
||||
}
|
||||
|
||||
#if !TARGET_J2EE
|
||||
internal void EndTimeoutPossible ()
|
||||
{
|
||||
Interlocked.CompareExchange (ref timeoutPossible, 0, 1);
|
||||
@@ -301,6 +341,7 @@ namespace System.Web
|
||||
Thread.Sleep (500);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
internal bool CheckIfTimeout (DateTime dt)
|
||||
{
|
||||
@@ -399,7 +440,7 @@ namespace System.Web
|
||||
}
|
||||
|
||||
path = UrlUtils.Combine (Request.BaseVirtualDir, path);
|
||||
if (!path.StartsWith (HttpRuntime.AppDomainAppVirtualPath))
|
||||
if (!StrUtils.StartsWith (path, HttpRuntime.AppDomainAppVirtualPath))
|
||||
throw new HttpException (404, "The virtual path '" + path +
|
||||
"' maps to another application.");
|
||||
|
||||
|
||||
@@ -34,8 +34,10 @@ using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Web.Compilation;
|
||||
using System.Web.Util;
|
||||
#if !TARGET_J2EE
|
||||
using System.Web.Compilation;
|
||||
#endif
|
||||
|
||||
namespace System.Web
|
||||
{
|
||||
@@ -133,11 +135,17 @@ namespace System.Web
|
||||
builder.Append ("<table summary=\"Stack Trace\" width=\"100%\" " +
|
||||
"bgcolor=\"#ffffc\">\r\n<tr><td>");
|
||||
WriteTextAsCode (builder, InnerException.ToString ());
|
||||
#if TARGET_J2EE //Required, because toString of Java doesn't print stackTrace
|
||||
WriteTextAsCode (builder, InnerException.StackTrace);
|
||||
#endif
|
||||
builder.Append ("</td></tr>\r\n</table>\r\n<p>\r\n");
|
||||
}
|
||||
|
||||
builder.Append ("<hr>\r\n</body>\r\n</html>\r\n");
|
||||
builder.AppendFormat ("<!--\r\n{0}\r\n-->\r\n", HttpUtility.HtmlEncode (this.ToString ()));
|
||||
#if TARGET_J2EE //Required, because toString of Java doesn't print stackTrace
|
||||
builder.AppendFormat ("<!--\r\n{0}\r\n-->\r\n", HttpUtility.HtmlEncode (this.StackTrace));
|
||||
#endif
|
||||
|
||||
return builder.ToString ();
|
||||
}
|
||||
@@ -150,7 +158,44 @@ namespace System.Web
|
||||
string res = HttpUtility.HtmlEncode (s);
|
||||
return res.Replace ("\r\n", "<br />");
|
||||
}
|
||||
#if TARGET_J2EE
|
||||
string GetHtmlizedErrorMessage ()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder ("<html>\r\n<title>");
|
||||
HtmlizedException exc = (HtmlizedException) this.InnerException;
|
||||
builder.Append (exc.Title);
|
||||
builder.AppendFormat ("</title><body bgcolor=\"white\">" +
|
||||
"<h1><font color=\"red\">Server Error in '{0}' " +
|
||||
"Application</font></h1><hr>\r\n",
|
||||
HttpRuntime.AppDomainAppVirtualPath);
|
||||
|
||||
builder.AppendFormat ("<h2><font color=\"maroon\"><i>{0}</i></font></h2>\r\n", exc.Title);
|
||||
builder.AppendFormat ("<b>Description: </b>{0}\r\n<p>\r\n", HtmlEncode (exc.Description));
|
||||
builder.AppendFormat ("<b>Error message: </b>{0}\r\n<p>\r\n", HtmlEncode (exc.ErrorMessage));
|
||||
|
||||
if (exc.FileName != null)
|
||||
builder.AppendFormat ("<b>File name: </b> {0}", HtmlEncode (exc.FileName));
|
||||
|
||||
if (exc.FileText != null) {
|
||||
if (exc.SourceFile != exc.FileName)
|
||||
builder.AppendFormat ("<p><b>Source File: </b>{0}", exc.SourceFile);
|
||||
|
||||
builder.Append ("\r\n<p>\r\n");
|
||||
|
||||
builder.Append ("<table summary=\"Source file\" width=\"100%\" " +
|
||||
"bgcolor=\"#ffffc\">\r\n<tr><td>");
|
||||
WriteSource (builder, exc);
|
||||
builder.Append ("</td></tr>\r\n</table>\r\n<p>\r\n");
|
||||
}
|
||||
|
||||
builder.Append ("<hr>\r\n</body>\r\n</html>\r\n");
|
||||
builder.AppendFormat ("<!--\r\n{0}\r\n-->\r\n", HtmlEncode (exc.ToString ()));
|
||||
builder.AppendFormat ("<!--\r\n{0}\r\n-->\r\n", HtmlEncode (exc.StackTrace));
|
||||
return builder.ToString ();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !TARGET_J2EE
|
||||
string GetHtmlizedErrorMessage ()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder ("<html>\r\n<title>");
|
||||
@@ -197,7 +242,7 @@ namespace System.Web
|
||||
builder.AppendFormat ("<!--\r\n{0}\r\n-->\r\n", HtmlEncode (exc.ToString ()));
|
||||
return builder.ToString ();
|
||||
}
|
||||
|
||||
#endif
|
||||
static void WriteTextAsCode (StringBuilder builder, string text)
|
||||
{
|
||||
builder.Append ("<code><pre>\r\n");
|
||||
@@ -205,6 +250,17 @@ namespace System.Web
|
||||
builder.Append ("</pre></code>\r\n");
|
||||
}
|
||||
|
||||
#if TARGET_J2EE
|
||||
static void WriteSource (StringBuilder builder, HtmlizedException e)
|
||||
{
|
||||
builder.Append ("<code><pre>");
|
||||
WritePageSource (builder, e);
|
||||
builder.Append ("</pre></code>\r\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !TARGET_J2EE
|
||||
static void WriteSource (StringBuilder builder, HtmlizedException e)
|
||||
{
|
||||
builder.Append ("<code><pre>");
|
||||
@@ -215,6 +271,7 @@ namespace System.Web
|
||||
|
||||
builder.Append ("</pre></code>\r\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
static void WriteCompilationSource (StringBuilder builder, HtmlizedException e)
|
||||
{
|
||||
|
||||
@@ -33,11 +33,16 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Web.Configuration;
|
||||
using System.Web.Util;
|
||||
|
||||
#if TARGET_J2EE
|
||||
using vmw.common;
|
||||
#endif
|
||||
|
||||
namespace System.Web {
|
||||
[MonoTODO("Review security in all path access function")]
|
||||
public sealed class HttpRequest {
|
||||
@@ -98,6 +103,9 @@ namespace System.Web {
|
||||
bool checkedQueryString;
|
||||
#endif
|
||||
|
||||
#if TARGET_J2EE
|
||||
private string _sGhFilePath;
|
||||
#endif
|
||||
public HttpRequest(string Filename, string Url, string Querystring) {
|
||||
_iContentLength = -1;
|
||||
_iTotalBytes = -1;
|
||||
@@ -216,8 +224,12 @@ namespace System.Web {
|
||||
|
||||
private void ParseFormData ()
|
||||
{
|
||||
string contentType = ContentType;
|
||||
if (0 == String.Compare (contentType, "application/x-www-form-urlencoded", true)) {
|
||||
string content_type = ContentType;
|
||||
if (content_type == null)
|
||||
return;
|
||||
|
||||
content_type = content_type.ToLower (CultureInfo.InvariantCulture);
|
||||
if (content_type == "application/x-www-form-urlencoded") {
|
||||
byte [] arrData = GetRawContent ();
|
||||
Encoding enc = ContentEncoding;
|
||||
string data = enc.GetString (arrData);
|
||||
@@ -225,24 +237,18 @@ namespace System.Web {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ContentType.StartsWith ("multipart/form-data")) {
|
||||
if (contentType.Length > 0)
|
||||
Console.WriteLine ("Content-Type -> {0} not supported", contentType);
|
||||
|
||||
GetRawContent (); // at least, read the data and check length validity
|
||||
_oFormData = new HttpValueCollection ();
|
||||
return;
|
||||
}
|
||||
|
||||
MultipartContentElement [] parts = GetMultipartFormData ();
|
||||
_oFormData = new HttpValueCollection ();
|
||||
if (parts == null) return;
|
||||
|
||||
foreach (MultipartContentElement p in parts) {
|
||||
if (!p.IsFormItem) continue;
|
||||
_oFormData.Add (p.Name, p.GetString (ContentEncoding));
|
||||
if (StrUtils.StartsWith (content_type, "multipart/form-data")) {
|
||||
MultipartContentElement [] parts = GetMultipartFormData ();
|
||||
if (parts == null)
|
||||
return;
|
||||
Encoding content_encoding = ContentEncoding;
|
||||
foreach (MultipartContentElement p in parts) {
|
||||
if (p.IsFormItem) {
|
||||
_oFormData.Add (p.Name, p.GetString (content_encoding));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[MonoTODO("void Dispose")]
|
||||
@@ -578,6 +584,25 @@ namespace System.Web {
|
||||
}
|
||||
}
|
||||
|
||||
#if TARGET_J2EE
|
||||
internal string GhFilePath {
|
||||
get {
|
||||
if (null == _sGhFilePath) {
|
||||
_sGhFilePath = FilePath;
|
||||
if (_sGhFilePath == null)
|
||||
return null;
|
||||
|
||||
if (_sGhFilePath.StartsWith(IAppDomainConfig.WAR_ROOT_SYMBOL))
|
||||
_sGhFilePath = _sGhFilePath.Substring(IAppDomainConfig.WAR_ROOT_SYMBOL.Length);
|
||||
if (_sGhFilePath.StartsWith(HttpRuntime.AppDomainAppVirtualPath))
|
||||
_sGhFilePath = _sGhFilePath.Substring(HttpRuntime.AppDomainAppVirtualPath.Length);
|
||||
}
|
||||
|
||||
return _sGhFilePath;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
HttpFileCollection files;
|
||||
public HttpFileCollection Files {
|
||||
get {
|
||||
@@ -593,7 +618,8 @@ namespace System.Web {
|
||||
|
||||
void FillPostedFiles ()
|
||||
{
|
||||
if (!ContentType.StartsWith ("multipart/form-data")) return;
|
||||
if (!StrUtils.StartsWith (ContentType, "multipart/form-data"))
|
||||
return;
|
||||
|
||||
MultipartContentElement [] parts = GetMultipartFormData ();
|
||||
if (parts == null) return;
|
||||
@@ -1059,25 +1085,20 @@ namespace System.Web {
|
||||
}
|
||||
}
|
||||
|
||||
public byte [] BinaryRead(int count) {
|
||||
int iSize = TotalBytes;
|
||||
if (iSize == 0) {
|
||||
throw new ArgumentException();
|
||||
public byte [] BinaryRead (int count)
|
||||
{
|
||||
if (count < 0 || count > TotalBytes)
|
||||
throw new ArgumentOutOfRangeException ("count");
|
||||
|
||||
byte [] data = new byte [count];
|
||||
int nread = InputStream.Read (data, 0, count);
|
||||
if (nread != count) {
|
||||
byte [] tmp = new byte [nread];
|
||||
Buffer.BlockCopy (data, 0, tmp, 0, nread);
|
||||
data = tmp;
|
||||
}
|
||||
|
||||
byte [] arrData = new byte[iSize];
|
||||
|
||||
int iRetSize = InputStream.Read(arrData, 0, iSize);
|
||||
if (iRetSize != iSize) {
|
||||
byte [] tmpData = new byte[iRetSize];
|
||||
if (iRetSize > 0) {
|
||||
Array.Copy(arrData, 0, tmpData, 0, iRetSize);
|
||||
}
|
||||
|
||||
arrData = tmpData;
|
||||
}
|
||||
|
||||
return arrData;
|
||||
return data;
|
||||
}
|
||||
|
||||
public int [] MapImageCoordinates(string ImageFieldName) {
|
||||
@@ -1120,6 +1141,15 @@ namespace System.Web {
|
||||
if (_WorkerRequest == null)
|
||||
throw new HttpException ("No HttpWorkerRequest!!!");
|
||||
|
||||
#if TARGET_J2EE
|
||||
if (baseVirtualDir.Equals(BaseVirtualDir))
|
||||
{
|
||||
string val = System.Web.GH.PageMapper.GetFromMapPathCache(virtualPath);
|
||||
if (val != null)
|
||||
return val;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (virtualPath == null || virtualPath.Length == 0)
|
||||
virtualPath = ".";
|
||||
else
|
||||
@@ -1127,7 +1157,10 @@ namespace System.Web {
|
||||
|
||||
if (virtualPath.IndexOf (':') != -1)
|
||||
throw new ArgumentException ("Invalid path -> " + virtualPath);
|
||||
|
||||
#if TARGET_J2EE
|
||||
if (virtualPath.StartsWith(IAppDomainConfig.WAR_ROOT_SYMBOL))
|
||||
return virtualPath;
|
||||
#endif
|
||||
if (System.IO.Path.DirectorySeparatorChar != '/')
|
||||
virtualPath = virtualPath.Replace (System.IO.Path.DirectorySeparatorChar, '/');
|
||||
|
||||
@@ -1142,7 +1175,7 @@ namespace System.Web {
|
||||
}
|
||||
|
||||
if (!allowCrossAppMapping) {
|
||||
if (!virtualPath.ToLower ().StartsWith (RootVirtualDir.ToLower ()))
|
||||
if (!StrUtils.StartsWith (virtualPath, RootVirtualDir, true))
|
||||
throw new HttpException ("Mapping across applications not allowed.");
|
||||
|
||||
if (RootVirtualDir.Length > 1 && virtualPath.Length > 1 && virtualPath [0] != '/')
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace System.Web
|
||||
bool _bSuppressHeaders;
|
||||
bool _bSuppressContent;
|
||||
bool _bChunked;
|
||||
bool last_chunk_sent;
|
||||
bool _bEnded;
|
||||
bool _bBuffering;
|
||||
bool _bHeadersSent;
|
||||
@@ -113,6 +114,12 @@ namespace System.Web
|
||||
_WorkerRequest = WorkerRequest;
|
||||
}
|
||||
|
||||
#if TARGET_J2EE
|
||||
public HttpWorkerRequest WorkerRequest{
|
||||
get{ return _WorkerRequest; }
|
||||
}
|
||||
#endif
|
||||
|
||||
internal void InitializeWriter ()
|
||||
{
|
||||
// We cannot do this in the .ctor because HttpWriter uses configuration and
|
||||
@@ -156,8 +163,10 @@ namespace System.Web
|
||||
ArrayList oHeaders = new ArrayList (_Headers);
|
||||
|
||||
oHeaders.Add (new HttpResponseHeader ("X-Powered-By", "Mono"));
|
||||
string date = DateTime.UtcNow.ToString ("ddd, d MMM yyyy HH:mm:ss ", CultureInfo.InvariantCulture);
|
||||
HttpResponseHeader date_header = new HttpResponseHeader ("Date", date + "GMT");
|
||||
|
||||
#if !TARGET_J2EE
|
||||
string date = DateTime.UtcNow.ToString ("ddd, d MMM yyyy HH:mm:ss 'GMT'", CultureInfo.InvariantCulture);
|
||||
HttpResponseHeader date_header = new HttpResponseHeader ("Date", date);
|
||||
oHeaders.Add (date_header);
|
||||
|
||||
if (IsCached)
|
||||
@@ -167,6 +176,7 @@ namespace System.Web
|
||||
oHeaders.Add (new HttpResponseHeader (HttpWorkerRequest.HeaderContentLength,
|
||||
_lContentLength.ToString ()));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Apache2 only auto-adds 'charset=blah' for text/plain and text/html
|
||||
if (_sContentType != null) {
|
||||
@@ -229,7 +239,11 @@ namespace System.Web
|
||||
foreach (HttpResponseHeader oHeader in oHeaders)
|
||||
oHeader.SendContent (_WorkerRequest);
|
||||
|
||||
#if !TARGET_J2EE //in J2EE env. we are setting headers into
|
||||
//HttpServletResponse instance -> headers are
|
||||
//still not sent
|
||||
_bHeadersSent = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
public string Status
|
||||
@@ -325,7 +339,7 @@ namespace System.Web
|
||||
string rvd = _Context.Request.RootVirtualDir;
|
||||
string basevd = rvd.Replace (app_path_mod, "");
|
||||
|
||||
if (!virtualPath.StartsWith (basevd))
|
||||
if (!StrUtils.StartsWith (virtualPath, basevd))
|
||||
return virtualPath;
|
||||
|
||||
virtualPath = UrlUtils.Combine (rvd, virtualPath.Substring (basevd.Length));
|
||||
@@ -635,7 +649,7 @@ namespace System.Web
|
||||
if (_bHeadersSent)
|
||||
throw new HttpException ("Headers has been sent to the client");
|
||||
|
||||
switch (name.ToLower ()) {
|
||||
switch (name.ToLower (CultureInfo.InvariantCulture)) {
|
||||
case "content-length":
|
||||
_lContentLength = Int64.Parse (value);
|
||||
break;
|
||||
@@ -711,6 +725,10 @@ namespace System.Web
|
||||
public void Close ()
|
||||
{
|
||||
if (!closed && !_bClientDisconnected) {
|
||||
if (_bChunked && !last_chunk_sent) {
|
||||
last_chunk_sent = true;
|
||||
_WorkerRequest.SendResponseFromMemory (s_arrChunkEnd, s_arrChunkEnd.Length);
|
||||
}
|
||||
_WorkerRequest.CloseConnection ();
|
||||
_bClientDisconnected = true;
|
||||
closed = true;
|
||||
@@ -737,7 +755,11 @@ namespace System.Web
|
||||
return;
|
||||
|
||||
if (_Context.TimeoutPossible)
|
||||
#if !TARGET_J2EE
|
||||
Thread.CurrentThread.Abort (new StepCompleteRequest ());
|
||||
#else
|
||||
throw new vmw.@internal.j2ee.StopExecutionException();
|
||||
#endif
|
||||
|
||||
Flush ();
|
||||
_bEnded = true;
|
||||
@@ -808,8 +830,8 @@ namespace System.Web
|
||||
|
||||
if (length == 0) {
|
||||
if (bFinish && _bChunked) {
|
||||
_WorkerRequest.SendResponseFromMemory (s_arrChunkEnd,
|
||||
s_arrChunkEnd.Length);
|
||||
last_chunk_sent = true;
|
||||
_WorkerRequest.SendResponseFromMemory (s_arrChunkEnd, s_arrChunkEnd.Length);
|
||||
}
|
||||
|
||||
_WorkerRequest.FlushResponse (bFinish);
|
||||
@@ -839,9 +861,11 @@ namespace System.Web
|
||||
|
||||
_WorkerRequest.SendResponseFromMemory (s_arrChunkSuffix,
|
||||
s_arrChunkSuffix.Length);
|
||||
if (bFinish)
|
||||
if (bFinish) {
|
||||
last_chunk_sent = true;
|
||||
_WorkerRequest.SendResponseFromMemory (
|
||||
s_arrChunkEnd, s_arrChunkEnd.Length);
|
||||
}
|
||||
} else {
|
||||
_Writer.SendContent (_WorkerRequest);
|
||||
}
|
||||
@@ -981,6 +1005,11 @@ namespace System.Web
|
||||
|
||||
public void WriteFile (string filename, bool readIntoMemory)
|
||||
{
|
||||
#if TARGET_J2EE
|
||||
if ((this.Request != null) && ((filename.Length <= 2)
|
||||
|| ((filename[0] != '\\') && (filename[1] != ':'))))
|
||||
filename = Request.MapPath(filename);
|
||||
#endif
|
||||
FileStream fs = null;
|
||||
try {
|
||||
fs = File.OpenRead (filename);
|
||||
@@ -999,6 +1028,11 @@ namespace System.Web
|
||||
public void WriteFile (string filename, long offset, long size)
|
||||
{
|
||||
FileStream fs = null;
|
||||
#if TARGET_J2EE
|
||||
if ((this.Request != null) && ((filename.Length <= 2)
|
||||
|| ((filename[0] != '\\') && (filename[1] != ':'))))
|
||||
filename = Request.MapPath(filename);
|
||||
#endif
|
||||
try {
|
||||
fs = File.OpenRead (filename);
|
||||
WriteFromStream (fs, offset, size, 30702);
|
||||
@@ -1023,6 +1057,9 @@ namespace System.Web
|
||||
[MonoTODO()]
|
||||
internal void OnCookieAdd (HttpCookie cookie)
|
||||
{
|
||||
#if TARGET_J2EE //naive implementation
|
||||
Request.Cookies.Add(cookie);
|
||||
#endif
|
||||
}
|
||||
|
||||
[MonoTODO("Do we need this?")]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//
|
||||
// System.Web.HttpResponseHeader
|
||||
//
|
||||
// Author:
|
||||
// Patrik Torstensson ([email protected])
|
||||
//
|
||||
//
|
||||
// System.Web.HttpResponseHeader
|
||||
//
|
||||
// Author:
|
||||
// Patrik Torstensson ([email protected])
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
@@ -25,49 +25,58 @@
|
||||
// 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;
|
||||
|
||||
namespace System.Web {
|
||||
internal class HttpResponseHeader {
|
||||
private string _sHeader;
|
||||
private string _sValue;
|
||||
private int _iKnowHeaderId;
|
||||
|
||||
internal HttpResponseHeader(int KnowHeaderId, string value) {
|
||||
_iKnowHeaderId = KnowHeaderId;
|
||||
_sValue = value;
|
||||
}
|
||||
|
||||
internal HttpResponseHeader(string header, string value) {
|
||||
_sHeader = header;
|
||||
_sValue = value;
|
||||
}
|
||||
|
||||
internal string Name {
|
||||
get {
|
||||
if (null == _sHeader) {
|
||||
return HttpWorkerRequest.GetKnownResponseHeaderName(_iKnowHeaderId);
|
||||
}
|
||||
|
||||
return _sHeader;
|
||||
}
|
||||
}
|
||||
|
||||
internal string Value {
|
||||
get {
|
||||
return _sValue;
|
||||
}
|
||||
set {
|
||||
_sValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal void SendContent(HttpWorkerRequest WorkerRequest) {
|
||||
if (null != _sHeader) {
|
||||
WorkerRequest.SendUnknownResponseHeader(_sHeader, _sValue);
|
||||
} else {
|
||||
WorkerRequest.SendKnownResponseHeader(_iKnowHeaderId, _sValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
|
||||
namespace System.Web {
|
||||
class HttpResponseHeader {
|
||||
string header;
|
||||
string val;
|
||||
int header_id;
|
||||
static char [] CRLF = { '\r', '\n' };
|
||||
|
||||
internal HttpResponseHeader (int KnowHeaderId, string val)
|
||||
{
|
||||
header_id = KnowHeaderId;
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
internal HttpResponseHeader (string header, string val) {
|
||||
this.header = header;
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
internal string Name {
|
||||
get {
|
||||
if (null == header)
|
||||
return HttpWorkerRequest.GetKnownResponseHeaderName (header_id);
|
||||
|
||||
return header;
|
||||
}
|
||||
}
|
||||
|
||||
internal string Value {
|
||||
get { return val; }
|
||||
set { val = value; }
|
||||
}
|
||||
|
||||
internal void SendContent (HttpWorkerRequest WorkerRequest)
|
||||
{
|
||||
// use URL encoding on the value (see bug #75392)
|
||||
// but only for CR and LF. Other characters are left untouched.
|
||||
string actual_val = val;
|
||||
if (actual_val != null) {
|
||||
int crlf = actual_val.IndexOfAny (CRLF);
|
||||
if (crlf >= 0) {
|
||||
actual_val = actual_val.Replace ("\r", "%0d");
|
||||
actual_val = actual_val.Replace ("\n", "%0a");
|
||||
}
|
||||
}
|
||||
|
||||
if (null != header) {
|
||||
WorkerRequest.SendUnknownResponseHeader (header, actual_val);
|
||||
} else {
|
||||
WorkerRequest.SendKnownResponseHeader (header_id, actual_val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,11 +51,30 @@ namespace System.Web {
|
||||
private static IStackWalk unrestrictedStackWalk;
|
||||
private static IStackWalk reflectionStackWalk;
|
||||
|
||||
#if !TARGET_JVM
|
||||
private static HttpRuntime _runtime;
|
||||
private static string appDomainAppId;
|
||||
private static string appDomainId;
|
||||
private static string appDomainAppPath;
|
||||
private static string appDomainAppVirtualPath;
|
||||
#else
|
||||
private static object _ghLock = new object();
|
||||
static private HttpRuntime _runtime {
|
||||
get {
|
||||
HttpRuntime runtime = (HttpRuntime)AppDomain.CurrentDomain.GetData("HttpRuntime");
|
||||
if (runtime == null)
|
||||
lock (_ghLock) {
|
||||
runtime = (HttpRuntime)AppDomain.CurrentDomain.GetData("HttpRuntime");
|
||||
if (runtime == null) {
|
||||
runtime = new HttpRuntime();
|
||||
runtime.Init();
|
||||
AppDomain.CurrentDomain.SetData("HttpRuntime", runtime);
|
||||
}
|
||||
}
|
||||
return runtime;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
private Cache _cache;
|
||||
|
||||
private int _activeRequests;
|
||||
@@ -73,11 +92,13 @@ namespace System.Web {
|
||||
private WaitCallback doRequestCallback;
|
||||
private int pendingCallbacks;
|
||||
|
||||
#if !TARGET_JVM
|
||||
static HttpRuntime ()
|
||||
{
|
||||
_runtime = new HttpRuntime ();
|
||||
_runtime.Init();
|
||||
}
|
||||
#endif
|
||||
|
||||
public HttpRuntime ()
|
||||
{
|
||||
@@ -253,9 +274,8 @@ namespace System.Web {
|
||||
WaitForRequests (2000);
|
||||
queueManager.Dispose (); // Send a 503 to all queued requests
|
||||
queueManager = null;
|
||||
|
||||
_cache = null;
|
||||
HttpApplicationFactory.EndApplication ();
|
||||
HttpApplicationFactory.EndApplication();
|
||||
}
|
||||
|
||||
void OnDomainUnload (object o, EventArgs args)
|
||||
@@ -372,6 +392,23 @@ namespace System.Web {
|
||||
}
|
||||
}
|
||||
|
||||
#if TARGET_JVM
|
||||
public static string AppDomainAppId {
|
||||
get { return (string) AppDomain.CurrentDomain.GetData (".appId"); }
|
||||
}
|
||||
|
||||
public static string AppDomainAppPath {
|
||||
get { return (string) AppDomain.CurrentDomain.GetData (".appPath"); }
|
||||
}
|
||||
|
||||
public static string AppDomainAppVirtualPath {
|
||||
get { return (string) AppDomain.CurrentDomain.GetData (".appVPath"); }
|
||||
}
|
||||
|
||||
public static string AppDomainId {
|
||||
get { return (string) AppDomain.CurrentDomain.GetData (".domainId"); }
|
||||
}
|
||||
#else
|
||||
public static string AppDomainAppId {
|
||||
get {
|
||||
if (appDomainAppId == null)
|
||||
@@ -407,6 +444,7 @@ namespace System.Web {
|
||||
return appDomainId;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public static string AspInstallDirectory {
|
||||
get {
|
||||
|
||||
@@ -731,7 +731,8 @@ namespace System.Web {
|
||||
// 2 -> between '&' and ';' but no '#'
|
||||
// 3 -> '#' found after '&' and getting numbers
|
||||
int state = 0;
|
||||
int number = -1;
|
||||
int number = 0;
|
||||
bool have_trailing_digits = false;
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
char c = s [i];
|
||||
@@ -746,7 +747,12 @@ namespace System.Web {
|
||||
}
|
||||
|
||||
if (c == '&') {
|
||||
state = 0;
|
||||
state = 1;
|
||||
if (have_trailing_digits) {
|
||||
entity.Append (number.ToString (CultureInfo.InvariantCulture));
|
||||
have_trailing_digits = false;
|
||||
}
|
||||
|
||||
output.Append (entity.ToString ());
|
||||
entity.Length = 0;
|
||||
entity.Append ('&');
|
||||
@@ -760,9 +766,9 @@ namespace System.Web {
|
||||
output.Append (c);
|
||||
entity.Length = 0;
|
||||
} else {
|
||||
number = 0;
|
||||
if (c != '#') {
|
||||
state = 2;
|
||||
number = 0;
|
||||
} else {
|
||||
state = 3;
|
||||
}
|
||||
@@ -790,14 +796,15 @@ namespace System.Web {
|
||||
}
|
||||
state = 0;
|
||||
entity.Length = 0;
|
||||
number = -1;
|
||||
have_trailing_digits = false;
|
||||
} else if (Char.IsDigit (c)) {
|
||||
number = number * 10 + ((int) c - '0');
|
||||
have_trailing_digits = true;
|
||||
} else {
|
||||
state = 2;
|
||||
if (number >= 0) {
|
||||
if (have_trailing_digits) {
|
||||
entity.Append (number.ToString (CultureInfo.InvariantCulture));
|
||||
number = -1;
|
||||
have_trailing_digits = false;
|
||||
}
|
||||
entity.Append (c);
|
||||
}
|
||||
@@ -806,7 +813,7 @@ namespace System.Web {
|
||||
|
||||
if (entity.Length > 0) {
|
||||
output.Append (entity.ToString ());
|
||||
} else if (number >= 0) {
|
||||
} else if (have_trailing_digits) {
|
||||
output.Append (number.ToString (CultureInfo.InvariantCulture));
|
||||
}
|
||||
return output.ToString ();
|
||||
@@ -850,13 +857,16 @@ namespace System.Web {
|
||||
output.Append (""");
|
||||
break;
|
||||
default:
|
||||
if ((int) c > 128) {
|
||||
// MS starts encoding with &# from 160 and stops at 255.
|
||||
// We don't do that. One reason is the 65308/65310 unicode
|
||||
// characters that look like '<' and '>'.
|
||||
if (c > 159) {
|
||||
output.Append ("&#");
|
||||
output.Append (((int) c).ToString ());
|
||||
output.Append (((int) c).ToString (CultureInfo.InvariantCulture));
|
||||
output.Append (";");
|
||||
}
|
||||
else
|
||||
} else {
|
||||
output.Append (c);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return output.ToString ();
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
2005-07-03 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* WebConnectionStream.cs: initiate writing the body before trying to
|
||||
read. This fixes the performance problems observed in web services.
|
||||
Closes bug #75455.
|
||||
|
||||
2005-06-26 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* WebConnection.cs: if cnc.EndRead throws, mark the asyncresult as done.
|
||||
* WebConnectionStream.cs: if we're done with the body of a chunk, don't
|
||||
require the next chunk header to be there, as some servers might close
|
||||
the connection (while also sending 'Connection: close').
|
||||
|
||||
2005-06-22 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* HttpWebRequest.cs: MS implementation follows redirects for POST. Seems
|
||||
to me that this is against 10.3.3 in RFC 2616, but may be the user
|
||||
'authorization' to do this is implicit in AllowAutoRedirect...
|
||||
|
||||
2005-06-21 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* WebConnection.cs: SslClientStream.BeginRead might not be asynchronous
|
||||
if there's no record available to read. This is a workaround that makes
|
||||
the call to BeginRead itself asynchronous. Fixes bug #75342.
|
||||
|
||||
2005-06-10 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* WebConnection.cs:
|
||||
|
||||
@@ -807,8 +807,10 @@ namespace System.Net
|
||||
case HttpStatusCode.MovedPermanently: // 301
|
||||
case HttpStatusCode.Redirect: // 302
|
||||
case HttpStatusCode.TemporaryRedirect: // 307
|
||||
/* MS follows the redirect for POST too
|
||||
if (method != "GET" && method != "HEAD") // 10.3
|
||||
return false;
|
||||
*/
|
||||
|
||||
uriString = webResponse.Headers ["Location"];
|
||||
break;
|
||||
|
||||
@@ -395,8 +395,21 @@ namespace System.Net
|
||||
sPoint.SetCertificates (client, server);
|
||||
certsAvailable = (server != null);
|
||||
}
|
||||
|
||||
|
||||
delegate void MyDelegate (object o);
|
||||
|
||||
internal static void InitRead (object state)
|
||||
{
|
||||
WebConnection cnc = (WebConnection) state;
|
||||
if (!cnc.ssl) {
|
||||
InitRead2 (state);
|
||||
} else {
|
||||
MyDelegate d = new MyDelegate (InitRead2);
|
||||
d.BeginInvoke (state, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
static void InitRead2 (object state)
|
||||
{
|
||||
WebConnection cnc = (WebConnection) state;
|
||||
Stream ns = cnc.nstream;
|
||||
@@ -698,7 +711,7 @@ namespace System.Net
|
||||
WebExceptionStatus.ServerProtocolViolation, null);
|
||||
}
|
||||
|
||||
if ((done || nbytes == 0) && chunkStream.WantMore) {
|
||||
if ((done || nbytes == 0) && chunkStream.ChunkLeft != 0) {
|
||||
HandleError (WebExceptionStatus.ReceiveFailure, null, "chunked EndRead");
|
||||
throw new WebException ("Read error", null, WebExceptionStatus.ReceiveFailure, null);
|
||||
}
|
||||
|
||||
@@ -320,9 +320,16 @@ namespace System.Net
|
||||
int nbytes = -1;
|
||||
try {
|
||||
nbytes = cnc.EndRead (result);
|
||||
} catch (Exception) {
|
||||
} catch (Exception exc) {
|
||||
lock (locker) {
|
||||
pendingReads--;
|
||||
if (pendingReads == 0)
|
||||
pending.Set ();
|
||||
}
|
||||
|
||||
nextReadCalled = true;
|
||||
cnc.Close (true);
|
||||
result.SetCompleted (false, exc);
|
||||
throw;
|
||||
}
|
||||
|
||||
@@ -518,12 +525,12 @@ namespace System.Net
|
||||
if (cnc.Data.StatusCode != 0 && cnc.Data.StatusCode != 100)
|
||||
return;
|
||||
|
||||
IAsyncResult result = cnc.BeginWrite (bytes, 0, length, null, null);
|
||||
if (!initRead) {
|
||||
initRead = true;
|
||||
WebConnection.InitRead (cnc);
|
||||
}
|
||||
|
||||
IAsyncResult result = cnc.BeginWrite (bytes, 0, length, null, null);
|
||||
complete_request_written = cnc.EndWrite (result);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
2005-06-21 Ben Maurer <[email protected]>
|
||||
|
||||
* StringBuilder.cs (Replace): Do the correct thing when we replace
|
||||
with a longer string. Thanks to Alexander Beznozdrev
|
||||
<[email protected]>
|
||||
|
||||
2005-05-26 Ben Maurer <[email protected]>
|
||||
|
||||
* Encoding.cs: Use static object for locking. `volatile' to
|
||||
|
||||
@@ -296,7 +296,10 @@ namespace System.Text {
|
||||
|
||||
InternalEnsureCapacity (replace.Length + (_length - count));
|
||||
|
||||
string end = _str.Substring (startIndex + count, _length - startIndex - count );
|
||||
|
||||
String.InternalStrcpy (_str, startIndex, replace);
|
||||
String.InternalStrcpy (_str, startIndex + replace.Length, end);
|
||||
|
||||
_length = replace.Length + (_length - count);
|
||||
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
2005-06-20 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* domain.c:
|
||||
* appdomain.c:
|
||||
* domain-internals.h:
|
||||
* reflection.c: 'domain_assemblies' field is now protected by its own
|
||||
lock. Don't call into managed code to run the AssemblyLoad event if we
|
||||
now there are no registered delegates for it.
|
||||
|
||||
2005-06-18 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* socket-io.c: fix the index in the socket array for writable/error
|
||||
sockets. Fixes bug #75306.
|
||||
|
||||
2005-06-12 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* icall.c: no need to convert from utf16 to utf8 and then back again
|
||||
|
||||
+29
-17
@@ -440,11 +440,11 @@ ves_icall_System_AppDomain_createDomain (MonoString *friendly_name, MonoAppDomai
|
||||
mono_context_init (data);
|
||||
|
||||
/* The new appdomain should have all assemblies loaded */
|
||||
mono_domain_lock (domain);
|
||||
mono_domain_assemblies_lock (domain);
|
||||
/*g_print ("copy assemblies from domain %p (%s)\n", domain, domain->friendly_name);*/
|
||||
for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next)
|
||||
add_assemblies_to_domain (data, tmp->data, NULL);
|
||||
mono_domain_unlock (domain);
|
||||
mono_domain_assemblies_unlock (domain);
|
||||
|
||||
return ad;
|
||||
}
|
||||
@@ -467,7 +467,7 @@ ves_icall_System_AppDomain_GetAssemblies (MonoAppDomain *ad, MonoBoolean refonly
|
||||
|
||||
count = 0;
|
||||
/* Need to skip internal assembly builders created by remoting */
|
||||
mono_domain_lock (domain);
|
||||
mono_domain_assemblies_lock (domain);
|
||||
for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) {
|
||||
ass = tmp->data;
|
||||
if (refonly && !ass->ref_only)
|
||||
@@ -486,7 +486,7 @@ ves_icall_System_AppDomain_GetAssemblies (MonoAppDomain *ad, MonoBoolean refonly
|
||||
mono_array_set (res, gpointer, i, mono_assembly_get_object (domain, ass));
|
||||
++i;
|
||||
}
|
||||
mono_domain_unlock (domain);
|
||||
mono_domain_assemblies_unlock (domain);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -517,7 +517,7 @@ try_assembly_resolve (MonoDomain *domain, MonoString *fname, gboolean refonly)
|
||||
}
|
||||
|
||||
/*
|
||||
* LOCKING: assumes domain is already locked.
|
||||
* LOCKING: assumes assemblies_lock in the domain is already locked.
|
||||
*/
|
||||
static void
|
||||
add_assemblies_to_domain (MonoDomain *domain, MonoAssembly *ass, GHashTable *ht)
|
||||
@@ -558,10 +558,12 @@ add_assemblies_to_domain (MonoDomain *domain, MonoAssembly *ass, GHashTable *ht)
|
||||
static void
|
||||
mono_domain_fire_assembly_load (MonoAssembly *assembly, gpointer user_data)
|
||||
{
|
||||
static MonoClassField *assembly_load_field;
|
||||
static MonoMethod *assembly_load_method;
|
||||
MonoDomain *domain = mono_domain_get ();
|
||||
MonoReflectionAssembly *ref_assembly;
|
||||
MonoClass *klass;
|
||||
MonoMethod *method;
|
||||
gpointer load_value;
|
||||
void *params [1];
|
||||
|
||||
if (!domain->domain)
|
||||
@@ -570,21 +572,31 @@ mono_domain_fire_assembly_load (MonoAssembly *assembly, gpointer user_data)
|
||||
|
||||
klass = domain->domain->mbr.obj.vtable->klass;
|
||||
|
||||
method = mono_class_get_method_from_name (klass, "DoAssemblyLoad", -1);
|
||||
if (method == NULL) {
|
||||
g_warning ("Method AppDomain.DoAssemblyLoad not found.\n");
|
||||
return;
|
||||
mono_domain_assemblies_lock (domain);
|
||||
add_assemblies_to_domain (domain, assembly, NULL);
|
||||
mono_domain_assemblies_unlock (domain);
|
||||
|
||||
if (assembly_load_field == NULL) {
|
||||
assembly_load_field = mono_class_get_field_from_name (klass, "AssemblyLoad");
|
||||
g_assert (assembly_load_field);
|
||||
}
|
||||
|
||||
mono_domain_lock (domain);
|
||||
add_assemblies_to_domain (domain, assembly, NULL);
|
||||
mono_domain_unlock (domain);
|
||||
mono_field_get_value (domain->domain, assembly_load_field, &load_value);
|
||||
if (load_value == NULL) {
|
||||
/* No events waiting to be triggered */
|
||||
return;
|
||||
}
|
||||
|
||||
ref_assembly = mono_assembly_get_object (domain, assembly);
|
||||
g_assert (ref_assembly);
|
||||
|
||||
if (assembly_load_method == NULL) {
|
||||
assembly_load_method = mono_class_get_method_from_name (klass, "DoAssemblyLoad", -1);
|
||||
g_assert (assembly_load_method);
|
||||
}
|
||||
|
||||
*params = ref_assembly;
|
||||
mono_runtime_invoke (method, domain->domain, params, NULL);
|
||||
mono_runtime_invoke (assembly_load_method, domain->domain, params, NULL);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
@@ -852,17 +864,17 @@ mono_domain_assembly_search (MonoAssemblyName *aname,
|
||||
MonoAssembly *ass;
|
||||
gboolean refonly = GPOINTER_TO_UINT (user_data);
|
||||
|
||||
mono_domain_lock (domain);
|
||||
mono_domain_assemblies_lock (domain);
|
||||
for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) {
|
||||
ass = tmp->data;
|
||||
/* Dynamic assemblies can't match here in MS.NET */
|
||||
if (ass->dynamic || refonly != ass->ref_only || !mono_assembly_names_equal (aname, &ass->aname))
|
||||
continue;
|
||||
|
||||
mono_domain_unlock (domain);
|
||||
mono_domain_assemblies_unlock (domain);
|
||||
return ass;
|
||||
}
|
||||
mono_domain_unlock (domain);
|
||||
mono_domain_assemblies_unlock (domain);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ mono_debug_open_mono_symbol_file (MonoDebugHandle *handle, gboolean create_symfi
|
||||
MonoSymbolFile *symfile;
|
||||
FILE* f;
|
||||
|
||||
mono_loader_lock ();
|
||||
mono_debugger_lock ();
|
||||
symfile = g_new0 (MonoSymbolFile, 1);
|
||||
|
||||
symfile->filename = g_strdup_printf ("%s.mdb", mono_image_get_filename (handle->image));
|
||||
@@ -121,15 +121,15 @@ mono_debug_open_mono_symbol_file (MonoDebugHandle *handle, gboolean create_symfi
|
||||
}
|
||||
|
||||
if (load_symfile (handle, symfile)) {
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
return symfile;
|
||||
} else if (!create_symfile) {
|
||||
mono_debug_close_mono_symbol_file (symfile);
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
return symfile;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ mono_debug_close_mono_symbol_file (MonoSymbolFile *symfile)
|
||||
if (!symfile)
|
||||
return;
|
||||
|
||||
mono_loader_lock ();
|
||||
mono_debugger_lock ();
|
||||
if (symfile->method_hash)
|
||||
g_hash_table_destroy (symfile->method_hash);
|
||||
|
||||
@@ -147,7 +147,7 @@ mono_debug_close_mono_symbol_file (MonoSymbolFile *symfile)
|
||||
mono_raw_buffer_free ((gpointer) symfile->raw_contents);
|
||||
|
||||
g_free (symfile);
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -187,15 +187,15 @@ mono_debug_find_source_location (MonoSymbolFile *symfile, MonoMethod *method, gu
|
||||
const char *ptr;
|
||||
int i;
|
||||
|
||||
mono_loader_lock ();
|
||||
mono_debugger_lock ();
|
||||
if (!symfile->method_hash) {
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
minfo = g_hash_table_lookup (symfile->method_hash, method);
|
||||
if (!minfo) {
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ mono_debug_find_source_location (MonoSymbolFile *symfile, MonoMethod *method, gu
|
||||
|
||||
if (line_number) {
|
||||
*line_number = read32(&(lne->_row));
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
if (source_file)
|
||||
return source_file;
|
||||
else
|
||||
@@ -225,16 +225,16 @@ mono_debug_find_source_location (MonoSymbolFile *symfile, MonoMethod *method, gu
|
||||
} else if (source_file) {
|
||||
gchar *retval = g_strdup_printf ("%s:%d", source_file, read32(&(lne->_row)));
|
||||
g_free (source_file);
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
return retval;
|
||||
} else {
|
||||
gchar* retval = g_strdup_printf ("%d", read32(&(lne->_row)));
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ mono_debug_find_method (MonoDebugHandle *handle, MonoMethod *method)
|
||||
if (handle->image != mono_class_get_image (mono_method_get_class (method)))
|
||||
return NULL;
|
||||
|
||||
mono_loader_lock ();
|
||||
mono_debugger_lock ();
|
||||
first_ie = (MonoSymbolFileMethodIndexEntry *)
|
||||
(symfile->raw_contents + read32(&(symfile->offset_table->_method_table_offset)));
|
||||
|
||||
@@ -288,7 +288,7 @@ mono_debug_find_method (MonoDebugHandle *handle, MonoMethod *method)
|
||||
sizeof (MonoSymbolFileMethodIndexEntry), compare_method);
|
||||
|
||||
if (!ie) {
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -308,6 +308,6 @@ mono_debug_find_method (MonoDebugHandle *handle, MonoMethod *method)
|
||||
|
||||
g_hash_table_insert (symfile->method_hash, method, minfo);
|
||||
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
return minfo;
|
||||
}
|
||||
@@ -128,6 +128,8 @@ struct _MonoDomain {
|
||||
* if the hashtable contains a GC visible reference to them.
|
||||
*/
|
||||
GHashTable *finalizable_objects_hash;
|
||||
/* Used when accessing 'domain_assemblies' */
|
||||
CRITICAL_SECTION assemblies_lock;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@@ -143,6 +145,8 @@ typedef struct {
|
||||
|
||||
#define mono_domain_lock(domain) EnterCriticalSection(&(domain)->lock)
|
||||
#define mono_domain_unlock(domain) LeaveCriticalSection(&(domain)->lock)
|
||||
#define mono_domain_assemblies_lock(domain) EnterCriticalSection(&(domain)->assemblies_lock)
|
||||
#define mono_domain_assemblies_unlock(domain) LeaveCriticalSection(&(domain)->assemblies_lock)
|
||||
|
||||
void
|
||||
mono_jit_info_table_add (MonoDomain *domain, MonoJitInfo *ji);
|
||||
|
||||
@@ -335,6 +335,7 @@ mono_domain_create (void)
|
||||
domain->jit_trampoline_hash = g_hash_table_new (mono_aligned_addr_hash, NULL);
|
||||
|
||||
InitializeCriticalSection (&domain->lock);
|
||||
InitializeCriticalSection (&domain->assemblies_lock);
|
||||
|
||||
EnterCriticalSection (&appdomains_mutex);
|
||||
domain_id_alloc (domain);
|
||||
@@ -764,15 +765,15 @@ mono_domain_assembly_open (MonoDomain *domain, const char *name)
|
||||
MonoAssembly *ass;
|
||||
GSList *tmp;
|
||||
|
||||
mono_domain_lock (domain);
|
||||
mono_domain_assemblies_lock (domain);
|
||||
for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) {
|
||||
ass = tmp->data;
|
||||
if (strcmp (name, ass->aname.name) == 0) {
|
||||
mono_domain_unlock (domain);
|
||||
mono_domain_assemblies_unlock (domain);
|
||||
return ass;
|
||||
}
|
||||
}
|
||||
mono_domain_unlock (domain);
|
||||
mono_domain_assemblies_unlock (domain);
|
||||
|
||||
if (!(ass = mono_assembly_open (name, NULL)))
|
||||
return NULL;
|
||||
@@ -882,6 +883,7 @@ mono_domain_free (MonoDomain *domain, gboolean force)
|
||||
g_hash_table_destroy (domain->special_static_fields);
|
||||
domain->special_static_fields = NULL;
|
||||
}
|
||||
DeleteCriticalSection (&domain->assemblies_lock);
|
||||
DeleteCriticalSection (&domain->lock);
|
||||
domain->setup = NULL;
|
||||
|
||||
|
||||
+13
-13
@@ -771,10 +771,10 @@ mono_debug_source_location_from_address (MonoMethod *method, guint32 address, gu
|
||||
char *res = NULL;
|
||||
gint32 offset;
|
||||
|
||||
mono_loader_lock ();
|
||||
mono_debugger_lock ();
|
||||
minfo = _mono_debug_lookup_method (method);
|
||||
if (!minfo || !minfo->handle || !minfo->handle->symfile || !minfo->handle->symfile->offset_table) {
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -783,7 +783,7 @@ mono_debug_source_location_from_address (MonoMethod *method, guint32 address, gu
|
||||
if (offset >= 0)
|
||||
res = mono_debug_find_source_location (minfo->handle->symfile, method, offset, line_number);
|
||||
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -808,15 +808,15 @@ mono_debug_source_location_from_il_offset (MonoMethod *method, guint32 offset, g
|
||||
char *res;
|
||||
MonoDebugMethodInfo *minfo;
|
||||
|
||||
mono_loader_lock ();
|
||||
mono_debugger_lock ();
|
||||
minfo = _mono_debug_lookup_method (method);
|
||||
if (!minfo || !minfo->handle || !minfo->handle->symfile) {
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
res = mono_debug_find_source_location (minfo->handle->symfile, method, offset, line_number);
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -838,16 +838,16 @@ mono_debug_il_offset_from_address (MonoMethod *method, gint32 address, MonoDomai
|
||||
if (address < 0)
|
||||
return -1;
|
||||
|
||||
mono_loader_lock ();
|
||||
mono_debugger_lock ();
|
||||
minfo = _mono_debug_lookup_method (method);
|
||||
if (!minfo || !minfo->il_offsets || !minfo->handle || !minfo->handle->symfile ||
|
||||
!minfo->handle->symfile->offset_table) {
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
res = il_offset_from_address (minfo, domain, address);
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -870,21 +870,21 @@ mono_debug_address_from_il_offset (MonoMethod *method, gint32 il_offset, MonoDom
|
||||
if (il_offset < 0)
|
||||
return -1;
|
||||
|
||||
mono_loader_lock ();
|
||||
mono_debugger_lock ();
|
||||
minfo = _mono_debug_lookup_method (method);
|
||||
if (!minfo || !minfo->il_offsets || !minfo->handle || !minfo->handle->symfile ||
|
||||
!minfo->handle->symfile->offset_table) {
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
jit = find_method (minfo, domain);
|
||||
if (!jit) {
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
res = _mono_debug_address_from_il_offset (jit, il_offset);
|
||||
mono_loader_unlock ();
|
||||
mono_debugger_unlock ();
|
||||
return res;
|
||||
}
|
||||
@@ -4358,9 +4358,9 @@ mono_image_basic_init (MonoReflectionAssemblyBuilder *assemblyb)
|
||||
assembly->assembly.aname.name = image->image.name;
|
||||
assembly->assembly.image = &image->image;
|
||||
|
||||
mono_domain_lock (domain);
|
||||
mono_domain_assemblies_lock (domain);
|
||||
domain->domain_assemblies = g_slist_prepend (domain->domain_assemblies, assembly);
|
||||
mono_domain_unlock (domain);
|
||||
mono_domain_assemblies_unlock (domain);
|
||||
|
||||
register_assembly (mono_object_domain (assemblyb), &assemblyb->assembly, &assembly->assembly);
|
||||
mono_assembly_invoke_load_hook ((MonoAssembly*)assembly);
|
||||
|
||||
@@ -1384,6 +1384,7 @@ void ves_icall_System_Net_Sockets_Socket_Select_internal(MonoArray **sockets, gi
|
||||
obj = mono_array_get (*sockets, MonoObject *, i);
|
||||
if (obj == NULL) {
|
||||
mode++;
|
||||
idx++;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
2005-06-18 Ben Maurer <[email protected]>
|
||||
|
||||
* mini.c: Take mono_get_domainvar out of macros. This makes sure
|
||||
that we do not depend on undefined C behavior: the order stuff
|
||||
gets evaluated within an expression. Fixes mono when compiled on
|
||||
GCC 4.
|
||||
|
||||
2005-06-17 Zoltan Varga <[email protected]>
|
||||
|
||||
* mini.c (mono_method_to_ir): Allow STACK_PTR as input to SWITCH.
|
||||
|
||||
2005-06-13 Zoltan Varga <[email protected]>
|
||||
|
||||
* mini.c (mono_jit_free_method): Remove the method from the JitInfo table
|
||||
|
||||
+18
-10
@@ -421,11 +421,13 @@ mono_jump_info_token_new (MonoMemPool *mp, MonoImage *image, guint32 token)
|
||||
} while (0)
|
||||
|
||||
#define NEW_DOMAINCONST(cfg,dest) do { \
|
||||
if (cfg->opt & MONO_OPT_SHARED) { \
|
||||
NEW_TEMPLOAD (cfg, dest, mono_get_domainvar (cfg)->inst_c0); \
|
||||
} else { \
|
||||
NEW_PCONST (cfg, dest, (cfg)->domain); \
|
||||
} \
|
||||
if (cfg->opt & MONO_OPT_SHARED) { \
|
||||
/* avoid depending on undefined C behavior in sequence points */ \
|
||||
MonoInst* __domain_var = mono_get_domainvar (cfg); \
|
||||
NEW_TEMPLOAD (cfg, dest, __domain_var->inst_c0); \
|
||||
} else { \
|
||||
NEW_PCONST (cfg, dest, (cfg)->domain); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define GET_VARINFO_INST(cfg,num) ((cfg)->varinfo [(num)]->inst)
|
||||
@@ -4299,7 +4301,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
|
||||
MONO_INST_NEW (cfg, ins, *ip);
|
||||
--sp;
|
||||
ins->inst_left = *sp;
|
||||
if (ins->inst_left->type != STACK_I4) goto unverified;
|
||||
if ((ins->inst_left->type != STACK_I4) && (ins->inst_left->type != STACK_PTR))
|
||||
ins->cil_code = ip;
|
||||
ip += 5;
|
||||
CHECK_OPSIZE (n * sizeof (guint32));
|
||||
@@ -4621,12 +4623,14 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
|
||||
if (cfg->opt & MONO_OPT_SHARED) {
|
||||
int temp;
|
||||
MonoInst *iargs [3];
|
||||
|
||||
MonoInst* domain_var;
|
||||
|
||||
if (cfg->compile_aot) {
|
||||
cfg->ldstr_list = g_list_prepend (cfg->ldstr_list, GINT_TO_POINTER (n));
|
||||
}
|
||||
|
||||
NEW_TEMPLOAD (cfg, iargs [0], mono_get_domainvar (cfg)->inst_c0);
|
||||
/* avoid depending on undefined C behavior in sequence points */
|
||||
domain_var = mono_get_domainvar (cfg);
|
||||
NEW_TEMPLOAD (cfg, iargs [0], domain_var->inst_c0);
|
||||
NEW_IMAGECONST (cfg, iargs [1], image);
|
||||
NEW_ICONST (cfg, iargs [2], mono_metadata_token_index (n));
|
||||
temp = mono_emit_jit_icall (cfg, bblock, mono_ldstr, iargs, ip);
|
||||
@@ -5196,8 +5200,12 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
|
||||
if ((cfg->opt & MONO_OPT_SHARED) || (cfg->compile_aot && addr)) {
|
||||
int temp;
|
||||
MonoInst *iargs [2];
|
||||
MonoInst *domain_var;
|
||||
|
||||
g_assert (field->parent);
|
||||
NEW_TEMPLOAD (cfg, iargs [0], mono_get_domainvar (cfg)->inst_c0);
|
||||
/* avoid depending on undefined C behavior in sequence points */
|
||||
domain_var = mono_get_domainvar (cfg);
|
||||
NEW_TEMPLOAD (cfg, iargs [0], domain_var->inst_c0);
|
||||
NEW_FIELDCONST (cfg, iargs [1], field);
|
||||
temp = mono_emit_jit_icall (cfg, bblock, mono_class_static_field_address, iargs, ip);
|
||||
NEW_TEMPLOAD (cfg, ins, temp);
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ libMonoPosixHelper_la_LIBADD = \
|
||||
$(Z_LIBS)
|
||||
|
||||
# libMonoPosixHelper_la_LDFLAGS = -no-undefined -version-info 1:0:1
|
||||
libMonoPosixHelper_la_LDFLAGS = -no-undefined -module -avoid-version
|
||||
libMonoPosixHelper_la_LDFLAGS = -no-undefined -avoid-version
|
||||
|
||||
#
|
||||
# Use this target to refresh the values in map.[ch]
|
||||
|
||||
@@ -119,7 +119,7 @@ copy_statfs (struct Mono_Posix_Statvfs *to, struct statfs *from)
|
||||
to->f_files = from->f_files;
|
||||
to->f_ffree = from->f_ffree;
|
||||
to->f_favail = from->f_ffree; /* OSX doesn't have f_avail */
|
||||
Mono_Posix_ToMountFlags (from->f_flag, &to->f_flag);
|
||||
Mono_Posix_ToMountFlags (from->f_flags, &to->f_flag);
|
||||
// from->f_fsid is an int32[2], to->f_fsid is a uint64,
|
||||
// so this shouldn't lose anything.
|
||||
memcpy (&to->f_fsid, &from->f_fsid, sizeof(to->f_fsid));
|
||||
|
||||
Reference in new issue
Block a user