private void ServeCfg()
{
using ( StreamReader textReader = new StreamReader( stream ) ) {
using ( StreamWriter textWriter = new StreamWriter( stream ) ) {
string firstLine = "G" + textReader.ReadLine();
var match = HttpFirstLine.Match( firstLine );
if ( match.Success ) {
string worldName = match.Groups[1].Value;
bool firstTime = match.Groups[2].Success;
World world = WorldManager.FindWorldExact( worldName );
if ( world != null ) {
string cfg = world.GenerateWoMConfig( firstTime );
byte[] content = Encoding.UTF8.GetBytes( cfg );
textWriter.WriteLine( "HTTP/1.1 200 OK" );
textWriter.WriteLine( "Date: " + DateTime.UtcNow.ToString( "R" ) );
textWriter.WriteLine( "Content-Type: text/plain" );
textWriter.WriteLine( "Content-Length: " + content.Length );
textWriter.WriteLine();
textWriter.WriteLine( cfg );
} else {
textWriter.WriteLine( "HTTP/1.1 404 Not Found" );
}
} else {
textWriter.WriteLine( "HTTP/1.1 400 Bad Request" );
}
}
}
}