//
//
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2005-2009 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
//
using System.Collections;
+using System.Collections.Generic;
+using System.Collections.Specialized;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Web.UI;
-using System.Collections.Specialized;
-
-namespace System.Web {
+namespace System.Web
+{
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[ComVisible (false)]
- public abstract class HttpWorkerRequest {
-
+ public abstract partial class HttpWorkerRequest
+ {
public delegate void EndOfSendNotification (HttpWorkerRequest wr, object extraData);
public const int HeaderCacheControl = 0;
public const int ReasonCacheSecurity = 3;
public const int ReasonClientDisconnect = 4;
public const int ReasonDefault = 0;
-
- static readonly Hashtable RequestHeaderIndexer;
- static readonly Hashtable ResponseHeaderIndexer;
-
- static HttpWorkerRequest() {
- RequestHeaderIndexer = CollectionsUtil.CreateCaseInsensitiveHashtable(RequestHeaderMaximum);
+ static readonly Dictionary <string, int> RequestHeaderIndexer;
+ static readonly Dictionary <string, int> ResponseHeaderIndexer;
+
+ static HttpWorkerRequest ()
+ {
+ RequestHeaderIndexer = new Dictionary <string, int> (StringComparer.OrdinalIgnoreCase);
for (int i = 0; i < RequestHeaderMaximum; i++)
- RequestHeaderIndexer[GetKnownRequestHeaderName(i)] = i;
+ RequestHeaderIndexer.Add (GetKnownRequestHeaderName(i), i);
- ResponseHeaderIndexer = CollectionsUtil.CreateCaseInsensitiveHashtable(ResponseHeaderMaximum);
+ ResponseHeaderIndexer = new Dictionary <string, int> (StringComparer.OrdinalIgnoreCase);
for (int i = 0; i < ResponseHeaderMaximum; i++)
- ResponseHeaderIndexer[GetKnownResponseHeaderName(i)] = i;
+ ResponseHeaderIndexer.Add (GetKnownResponseHeaderName(i), i);
+ }
+
+ bool started_internally;
+ internal bool StartedInternally {
+ get { return started_internally; }
+ set { started_internally = value; }
}
public virtual string MachineConfigPath {
}
}
-#if NET_2_0
public virtual Guid RequestTraceIdentifier {
get { return Guid.Empty; }
}
public virtual string RootWebConfigPath {
get { return null; }
}
-#endif
public virtual void CloseConnection ()
{
{
return null;
}
-#if NET_2_0
+
public virtual int GetPreloadedEntityBody (byte[] buffer, int offset)
{
return 0;
{
return 0;
}
-#endif
+
public virtual string GetProtocol ()
{
if (IsSecure ())
{
return null;
}
-#if NET_2_0
+
public virtual int GetTotalEntityBodyLength ()
{
return 0;
}
-#endif
+
public virtual string GetUnknownRequestHeader (string name)
{
return null;
{
return 0;
}
-#if NET_2_0
+
public virtual int ReadEntityBody (byte [] buffer, int offset, int size)
{
- return 0;
+ byte[] temp = new byte [size];
+ int n = ReadEntityBody (temp, size);
+
+ if(n > 0)
+ Array.Copy (temp, 0, buffer, offset, n);
+
+ return n;
}
-#endif
- public virtual void SendCalculatedContentLength (int contentLength)
+
+ public virtual void SendCalculatedContentLength (long contentLength)
{
- throw new NotImplementedException ();
+ SendCalculatedContentLength ((int)contentLength);
}
-#if TARGET_JVM
- public virtual void SendResponseFromMemory (IntPtr data, int length)
+ public virtual void SendCalculatedContentLength (int contentLength)
{
- throw new NotImplementedException("SendResponseFromMemory: unsafe buffers (IntPtr) are not supported");
+ // apparently does nothing in MS.NET
}
-#else
+
public virtual void SendResponseFromMemory (IntPtr data, int length)
{
if (data != IntPtr.Zero) {
SendResponseFromMemory (copy, length);
}
}
-#endif
public virtual void SetEndOfSendNotification (HttpWorkerRequest.EndOfSendNotification callback, object extraData)
{
public static int GetKnownRequestHeaderIndex (string header)
{
- switch (header){
- case "Cache-Control": return HeaderCacheControl;
- case "Connection": return HeaderConnection;
- case "Date": return HeaderDate;
- case "Keep-Alive": return HeaderKeepAlive;
- case "Pragma": return HeaderPragma;
- case "Trailer": return HeaderTrailer;
- case "Transfer-Encoding": return HeaderTransferEncoding;
- case "Upgrade": return HeaderUpgrade;
- case "Via": return HeaderVia;
- case "Warning": return HeaderWarning;
- case "Allow": return HeaderAllow;
- case "Content-Length": return HeaderContentLength;
- case "Content-Type": return HeaderContentType;
- case "Content-Encoding": return HeaderContentEncoding;
- case "Content-Language": return HeaderContentLanguage;
- case "Content-Location": return HeaderContentLocation;
- case "Content-MD5": return HeaderContentMd5;
- case "Content-Range": return HeaderContentRange;
- case "Expires": return HeaderExpires;
- case "Last-Modified": return HeaderLastModified;
- case "Accept": return HeaderAccept;
- case "Accept-Charset": return HeaderAcceptCharset;
- case "Accept-Encoding": return HeaderAcceptEncoding;
- case "Accept-Language": return HeaderAcceptLanguage;
- case "Authorization": return HeaderAuthorization;
- case "Cookie": return HeaderCookie;
- case "Expect": return HeaderExpect;
- case "From": return HeaderFrom;
- case "Host": return HeaderHost;
- case "If-Match": return HeaderIfMatch;
- case "If-Modified-Since": return HeaderIfModifiedSince;
- case "If-None-Match": return HeaderIfNoneMatch;
- case "If-Range": return HeaderIfRange;
- case "If-Unmodified-Since": return HeaderIfUnmodifiedSince;
- case "Max-Forwards": return HeaderMaxForwards;
- case "Proxy-Authorization": return HeaderProxyAuthorization;
- case "Referer": return HeaderReferer;
- case "Range": return HeaderRange;
- case "TE": return HeaderTe;
- case "User-Agent": return HeaderUserAgent;
- }
-
- object index = RequestHeaderIndexer[header];
- if (index != null)
- return (int)index;
+ int index;
+ if (RequestHeaderIndexer.TryGetValue (header, out index))
+ return index;
return -1;
}
public static int GetKnownResponseHeaderIndex (string header)
{
- switch (header){
- case "Cache-Control": return HeaderCacheControl;
- case "Connection": return HeaderConnection;
- case "Date": return HeaderDate;
- case "Keep-Alive": return HeaderKeepAlive;
- case "Pragma": return HeaderPragma;
- case "Trailer": return HeaderTrailer;
- case "Transfer-Encoding": return HeaderTransferEncoding;
- case "Upgrade": return HeaderUpgrade;
- case "Via": return HeaderVia;
- case "Warning": return HeaderWarning;
- case "Allow": return HeaderAllow;
- case "Content-Length": return HeaderContentLength;
- case "Content-Type": return HeaderContentType;
- case "Content-Encoding": return HeaderContentEncoding;
- case "Content-Language": return HeaderContentLanguage;
- case "Content-Location": return HeaderContentLocation;
- case "Content-MD5": return HeaderContentMd5;
- case "Content-Range": return HeaderContentRange;
- case "Expires": return HeaderExpires;
- case "Last-Modified": return HeaderLastModified;
- case "Accept-Ranges": return HeaderAcceptRanges;
- case "Age": return HeaderAge;
- case "ETag": return HeaderEtag;
- case "Location": return HeaderLocation;
- case "Proxy-Authenticate":return HeaderProxyAuthenticate;
- case "Retry-After": return HeaderRetryAfter;
- case "Server": return HeaderServer;
- case "Set-Cookie": return HeaderSetCookie;
- case "Vary": return HeaderVary;
- case "WWW-Authenticate": return HeaderWwwAuthenticate;
- }
-
- object index = ResponseHeaderIndexer[header];
- if (index != null)
- return (int)index;
+ int index;
+ if (ResponseHeaderIndexer.TryGetValue (header, out index))
+ return index;
return -1;
}