2003-07-23 Gonzalo Paniagua Javier <gonzalo@ximian.com>

* INSTALL:
	* README: updated.

	* NEWS: new file.

	* server/AcceptEncodingConfig.cs: class to hold the configuration for
	the filters enabled in web.config.

	* server/AcceptEncodingModule.cs: IHttpModule to plug the filters.

	* server/AcceptEncodingSectionHandler.cs: configuration file section
	handler for accept-encoding filters.

	* server/GZipFilter.cs: sample filter for gzip encoding.

	* server/Makefile: reference ICSharpCode.SharpZipLib, added new files
	and renamed executable to xsp.exe

	* server/server.exe.config: removed and renamed to...
	* server/xsp.exe.config: ...this one.
	* server/web.config: Removed file. It's been merged with...
	* test/web.config: ...this one and the new mono.aspnet configuration
	section has been added.

svn path=/trunk/xsp/; revision=16578
This commit is contained in:
Gonzalo Paniagua Javier 2003-07-23 17:05:09 +00:00
Родитель 1c32cff6ac
Коммит a6ccc09ceb
13 изменённых файлов: 424 добавлений и 42 удалений

11
INSTALL
Просмотреть файл

@ -8,7 +8,7 @@ Steps for installing the server:
...and follow the instructions...
You can change the listen port from the default (8080) using the
configuration file (server.exe.config).
configuration file (xsp.exe.config).
Or you can use the --port command line option.
@ -16,6 +16,11 @@ Steps for installing the server:
you may need to modify the values of DBProviderAssembly, DBConnectionType
and/or DbConnectionString in web.config file.
NOTE for windows users: you may need to set authentication mode to "None" in
web.config file until RNGCryptoServiceProvider works in windows.
Notes for MS runtime users
----------------------------
You may need to set authentication mode to "None" in web.config file until
RNGCryptoServiceProvider works in windows.
If you're compiling under windows, you may need to copy
ICSharpCode.SharpZipLib.dll (distributed with mono) to xsp/server and xsp/server/test/bin directories if it's not installed for the system.

10
NEWS Normal file
Просмотреть файл

@ -0,0 +1,10 @@
July 23, 2003 - Gonzalo Paniagua
----------------------------------
I should have started writing this before...
* Changed executable name to xsp.exe (yeah!)
* Added gzip encoding support. It's disabled by default. You can enable it in
test/web.config file.

6
README
Просмотреть файл

@ -24,10 +24,12 @@
mono xsp.exe --port 80
The default is port 8080, or you can configure the server using
the server.exe.config file.
the xsp.exe.config file.
There are other command line options and appSettings options.
Run 'mono server.exe --help' to view all of them.
Run 'mono xsp.exe --help' to view all of them.
You can also set some configuration values in test/web.config file.
This is not a full fledged server, it is just a shell for hosting
ASP.NET.

Просмотреть файл

@ -0,0 +1,107 @@
//
// AcceptEncodingConfig.cs
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (c) 2003 Ximian, Inc (http://www.ximian.com)
//
using System;
using System.Collections;
using System.Collections.Specialized;
using System.IO;
using System.Web;
namespace Mono.ASPNET
{
public class AcceptEncodingConfig
{
Hashtable tbl = CollectionsUtil.CreateCaseInsensitiveHashtable ();
public AcceptEncodingConfig () : this (null)
{
}
public AcceptEncodingConfig (AcceptEncodingConfig parent)
{
if (parent == null)
return;
// FIXME: copy parent's config
}
public void Add (string encoding, string type)
{
tbl [encoding] = Type.GetType (type);
}
public bool SetFilter (HttpResponse response, string acceptEncoding)
{
if (acceptEncoding == null)
return false;
acceptEncoding = acceptEncoding.Trim ();
if (acceptEncoding == "")
return false;
string [] parts = null;
if (acceptEncoding.IndexOf (';') != -1)
parts = acceptEncoding.Split (';');
else
parts = acceptEncoding.Split (',');
string encoding;
float weight = 0.0f;
float current = 0.0f;
Type type = null;
string name = null;
int i = 0;
foreach (string s in parts) {
encoding = null;
ParseValue (s, ref encoding, ref weight);
if (encoding != null && weight > current && tbl.Contains (encoding)) {
type = tbl [encoding] as Type;
current = weight;
name = encoding;
}
i++;
}
if (type == null)
return false;
Stream filter = response.Filter;
response.Filter = (Stream) Activator.CreateInstance (type, new object [] {filter});
response.AppendHeader ("Content-Encoding", name);
return true;
}
public void Clear ()
{
tbl.Clear ();
}
static void ParseValue (string s, ref string encoding, ref float weight)
{
//FIXME: make it more spec compliant
string [] parts = s.Trim ().Split (',');
if (parts.Length == 1) {
encoding = parts [0].Trim ();
weight = 1.0f;
} else if (parts.Length == 2) {
encoding = parts [0].Trim ();
try {
int i = parts [1].IndexOf ('=');
if (i != -1)
weight = Convert.ToSingle (parts [1].Substring (i + 1));
} catch {
weight = 0.0f;
}
} else {
//ignore
}
}
}
}

Просмотреть файл

@ -0,0 +1,46 @@
//
// AcceptEncodingModule.cs
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (c) 2003 Ximian, Inc (http://www.ximian.com)
//
using System;
using System.Configuration;
using System.IO;
using System.Web;
namespace Mono.ASPNET
{
public class AcceptEncodingModule : IHttpModule
{
static readonly string configSection = "mono.aspnet/acceptEncoding";
AcceptEncodingConfig config;
public void Init (HttpApplication app)
{
app.BeginRequest += new EventHandler (CheckIfAddFilter);
}
public void Dispose ()
{
}
void CheckIfAddFilter (object sender, EventArgs args)
{
HttpApplication app = (HttpApplication) sender;
HttpRequest request = app.Request;
HttpResponse response = app.Response;
//FIXME: fix this when config is cached
if (config == null)
//config = (AcceptEncodingConfig) app.Context.GetConfig (configSection);
config = (AcceptEncodingConfig) ConfigurationSettings.GetConfig (configSection);
config.SetFilter (response, request.Headers ["Accept-Encoding"]);
}
}
}

Просмотреть файл

@ -0,0 +1,96 @@
//
// AcceptEncodingSectionHandler.cs
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (c) 2003 Ximian, Inc (http://www.ximian.com)
//
using System;
using System.Configuration;
using System.IO;
using System.Xml;
namespace Mono.ASPNET
{
public class AcceptEncodingSectionHandler : IConfigurationSectionHandler
{
public object Create (object parent, object configContext, XmlNode section)
{
AcceptEncodingConfig cfg = new AcceptEncodingConfig (parent as AcceptEncodingConfig);
if (section.Attributes != null && section.Attributes.Count != 0)
ThrowException ("Unrecognized attribute", section);
XmlNodeList nodes = section.ChildNodes;
foreach (XmlNode child in nodes) {
XmlNodeType ntype = child.NodeType;
if (ntype == XmlNodeType.Whitespace || ntype == XmlNodeType.Comment)
continue;
if (ntype != XmlNodeType.Element)
ThrowException ("Only elements allowed", child);
string name = child.Name;
if (name == "clear") {
if (child.Attributes != null && child.Attributes.Count != 0)
ThrowException ("Unrecognized attribute", child);
cfg.Clear ();
continue;
}
if (name != "add")
ThrowException ("Unexpected element", child);
string encoding = ExtractAttributeValue ("encoding", child, false);
string type = ExtractAttributeValue ("type", child, false);
string disabled = ExtractAttributeValue ("disabled", child, true);
if (disabled != null && disabled == "yes")
continue;
if (child.Attributes != null && child.Attributes.Count != 0)
ThrowException ("Unrecognized attribute", child);
cfg.Add (encoding, type);
}
return cfg;
}
static void ThrowException (string msg, XmlNode node)
{
if (node != null && node.Name != String.Empty)
msg = msg + " (node name: " + node.Name + ") ";
throw new ConfigurationException (msg, node);
}
static string ExtractAttributeValue (string attKey, XmlNode node, bool optional)
{
if (node.Attributes == null) {
if (optional)
return null;
ThrowException ("Required attribute not found: " + attKey, node);
}
XmlNode att = node.Attributes.RemoveNamedItem (attKey);
if (att == null) {
if (optional)
return null;
ThrowException ("Required attribute not found: " + attKey, node);
}
string value = att.Value;
if (value == String.Empty) {
string opt = optional ? "Optional" : "Required";
ThrowException (opt + " attribute is empty: " + attKey, node);
}
return value;
}
}
}

Просмотреть файл

@ -1,3 +1,22 @@
2003-07-23 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* AcceptEncodingConfig.cs: class to hold the configuration for the
filters enabled in web.config.
* AcceptEncodingModule.cs: IHttpModule to plug the filters.
* AcceptEncodingSectionHandler.cs: configuration file section handler
for accept-encoding filters.
* GZipFilter.cs: sample filter for gzip encoding.
* Makefile: reference ICSharpCode.SharpZipLib, added new files and
renamed executable to xsp.exe
* server.exe.config: removed and renamed to...
* xsp.exe.config: ...this one.
* web.config: Removed file. It's been merged with ../test/
2003-07-09 Lluis Sanchez Gual <lluis@ximian.com>
* Makefile: install target: copy web service files.

91
server/GZipFilter.cs Normal file
Просмотреть файл

@ -0,0 +1,91 @@
//
// GZipFilter.cs
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (c) 2003 Ximian, Inc (http://www.ximian.com)
//
using System;
using System.IO;
using ICSharpCode.SharpZipLib.GZip;
namespace Mono.ASPNET.Filters
{
public class GZipFilter : Stream
{
Stream baseStream;
GZipOutputStream st;
public GZipFilter (Stream baseStream)
{
// baseStream is not ready yet for filtering and any attemp to write
// the gzip header will throw.
this.baseStream = baseStream;
}
public override bool CanRead {
get { return false; }
}
public override bool CanSeek {
get { return false; }
}
public override bool CanWrite {
get {
if (st == null)
return false;
return st.CanWrite;
}
}
public override long Length {
get { return 0; }
}
public override long Position {
get { return 0; }
set { }
}
public override void Flush ()
{
}
public override int Read (byte [] buffer, int offset, int count)
{
return 0;
}
public override long Seek (long offset, SeekOrigin origin)
{
return 0;
}
public override void SetLength (long value)
{
}
public override void Write (byte [] buffer, int offset, int count)
{
if (st == null)
st = new GZipOutputStream (baseStream);
st.Write (buffer, offset, count);
}
public override void Close ()
{
if (st == null)
return;
st.Finish ();
st = null;
base.Close ();
}
}
}

Просмотреть файл

@ -4,7 +4,7 @@ CSC=mcs
CSCFLAGS+= /debug+ /debug:full /nologo
#
REFERENCES= System.Web
REFERENCES= System.Web ICSharpCode.SharpZipLib
REFS= $(addsuffix .dll, $(addprefix /r:, $(REFERENCES)))
SOURCES = AssemblyInfo.cs \
@ -13,27 +13,30 @@ SOURCES = AssemblyInfo.cs \
MonoWorkerRequest.cs \
XSPWorkerRequest.cs \
Tracing.cs \
server.cs
server.cs \
AcceptEncodingConfig.cs \
AcceptEncodingModule.cs \
AcceptEncodingSectionHandler.cs \
GZipFilter.cs
all: xsp.exe
all: server.exe
install: server.exe web.config global.asax
install: xsp.exe global.asax
rm -rf test
mkdir -p test/bin
cp server.exe server.exe.config web.config global.asax test
cp server.exe test/bin
cp xsp.exe xsp.exe.config global.asax test
cp xsp.exe test/bin
cp ../test/*.aspx ../test/*.asmx ../test/*.config ../test/*.ascx ../test/*.xml ../test/*.xsl ../test/*.png ../test/*.inc test
cp ../test/*.dll test/bin
server.exe: $(SOURCES)
xsp.exe: $(SOURCES)
$(CSC) $(CSCFLAGS) $(REFS) /out:$@ $^
trace:
rm -f server.exe
rm -f xsp.exe
$(MAKE) -C . CSCFLAGS=/d:WEBTRACE CSC=$(CSC)
clean:
rm -f server.exe *~ *.pdb
rm -f xsp.exe *~ *.pdb
rm -rf test

Просмотреть файл

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<customErrors mode="Off"/>
<authentication mode= "Forms">
</authentication>
</system.web>
<appSettings>
<add key="MonoServerDefaultIndexFiles"
value="index.aspx, Default.aspx, default.aspx, index.html, index.htm" />
<add key="DBProviderAssembly"
value="Mono.Data.PostgreSqlClient"/>
<add key="DBConnectionType"
value="Mono.Data.PostgreSqlClient.PgSqlConnection"/>
<add key="DBConnectionString"
value="hostaddr=127.0.0.1;user=monotest;password=monotest;dbname=monotest"/>
</appSettings>
</configuration>

Просмотреть файл

Просмотреть файл

@ -1,3 +1,8 @@
2003-07-23 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* web.config: the new mono.aspnet configuration section has been added
and other contents from ../server/web.config file.
2003-07-09 Lluis Sanchez Gual <lluis@ximian.com>
* README: added descrption of web service samples.

Просмотреть файл

@ -1,5 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="mono.aspnet">
<section name="acceptEncoding" type="Mono.ASPNET.AcceptEncodingSectionHandler, xsp"/>
</sectionGroup>
</configSections>
<system.web>
<customErrors mode="Off"/>
<webServices>
@ -10,7 +16,18 @@
</webServices>
<authentication mode= "Forms">
</authentication>
<httpModules>
<add name="AcceptEncodingModule" type="Mono.ASPNET.AcceptEncodingModule, xsp"/>
</httpModules>
</system.web>
<mono.aspnet>
<acceptEncoding>
<!-- Change disabled to 'no' to enable gzip content encoding -->
<add encoding="gzip" type="Mono.ASPNET.Filters.GZipFilter, xsp" disabled="yes" />
</acceptEncoding>
</mono.aspnet>
<appSettings>
<add key="MonoServerDefaultIndexFiles"
value="index.aspx, Default.aspx, default.aspx, index.html, index.htm" />