libs-sqlclient/testWebServer.m
Richard Frith-Macdonald 0ef78e48ef Tidied
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@21740 72102866-910b-0410-8b05-ffd578937521
2005-09-23 11:46:04 +00:00

77 lines
2.1 KiB
Objective-C

/**
Copyright (C) 2005 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald <rfm@gnu.org>
Date: September 2005
This file is part of the SQLClient Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$Date$ $Revision$
*/
#include <Foundation/Foundation.h>
#include <GNUstepBase/GSMime.h>
#include "WebServer.h"
@interface Handler: NSObject
- (BOOL) processRequest: (GSMimeDocument*)request
response: (GSMimeDocument*)response
for: (WebServer*)http;
@end
@implementation Handler
- (BOOL) processRequest: (GSMimeDocument*)request
response: (GSMimeDocument*)response
for: (WebServer*)http
{
NSString *s;
s = [[NSString alloc] initWithData: [request rawMimeData]
encoding: NSISOLatin1StringEncoding];
NSLog(@"Got request -\n%@\n", s);
[response setContent: s type: @"text/plain" name: nil];
RELEASE(s);
return YES;
}
@end
int
main()
{
CREATE_AUTORELEASE_POOL(pool);
WebServer *server;
Handler *handler;
NSUserDefaults *defs;
defs = [NSUserDefaults standardUserDefaults];
[defs registerDefaults:
[NSDictionary dictionaryWithObjectsAndKeys:
@"80", @"Port",
nil]
];
server = [WebServer new];
handler = [Handler new];
[server setDelegate: handler];
[server setPort: [defs stringForKey: @"Port"] secure: nil];
[[NSRunLoop currentRunLoop] run];
RELEASE(pool);
return 0;
}