2001-12-11 Manuel Guesdon <mguesdon@orange-concept.com>

* GSWeb.framework/GSWResourceManager.m: logs
	* GSWeb.framework/GSWDefaultAdaptorThread.m: logs
		corrected bug in response writing
	* GSWeb.framework/GSWApplication.m: logs
	* GSWAdaptors/common/GSWHTTPResponse.c: logs
	* added Example/hello 'application'


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@11702 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Manuel Guesdon 2001-12-11 14:35:30 +00:00
parent 95068eec21
commit ae58cc295f
25 changed files with 664 additions and 182 deletions

View file

@ -1,3 +1,12 @@
2001-12-11 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb.framework/GSWResourceManager.m: logs
* GSWeb.framework/GSWDefaultAdaptorThread.m: logs
corrected bug in response writing
* GSWeb.framework/GSWApplication.m: logs
* GSWAdaptors/common/GSWHTTPResponse.c: logs
* added Example/hello 'application'
2001-11-07 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWExtensions.framework/Makefile.preamble:

View file

@ -0,0 +1,54 @@
#
# examples makefile for the GNUstep Base Library
#
# Copyright (C) 1997 Free Software Foundation, Inc.
#
# Written by: Scott Christley <scottc@net-community.com>
#
# This file is part of the GNUstep Base 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Install into the system root by default
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT)
GNUSTEP_MAKEFILES = $(GNUSTEP_SYSTEM_ROOT)/Makefiles
include $(GNUSTEP_MAKEFILES)/common.make
include config.mak
GSWAPP_NAME=Hello
Hello_HAS_GSWCOMPONENTS=YES
Hello_PRINCIPAL_CLASS=Hello
Hello_GSWAPP_INFO_PLIST=Resources/Info-Hello.plist
# The Objective-C source files to be compiled
Hello_OBJC_FILES = Hello_main.m Hello.m HelloPage.m Main.m
Hello_COMPONENTS = Main.gswc HelloPage.gswc
SRCS = $(GSWAPP_NAME:=.m)
HDRS =
DIST_FILES = $(SRCS) $(HDRS) GNUmakefile Makefile.postamble Makefile.preamble
-include Makefile.preamble
include $(GNUSTEP_MAKEFILES)/gswapp.make
-include Makefile.postamble

3
Examples/hello/Hello.h Normal file
View file

@ -0,0 +1,3 @@
//====================================================================
@interface Hello : GSWApplication
@end

6
Examples/hello/Hello.m Normal file
View file

@ -0,0 +1,6 @@
#import <GSWeb/GSWeb.h>
#include "Hello.h"
@implementation Hello
@end

View file

@ -0,0 +1,16 @@
/*
* Hello.wod
*
* You may freely copy, distribute and reuse the code in this example.
* NeXT disclaims any warranty of any kind, expressed or implied, as to
* its fitness for any particular use.
*
* This example was written with a Beta version of WebObjects.
*
* Written by WebObjects Development Team
*
* This is the declarations file for the second page (Hello) of the
* HelloWorldObjC application.
*/
BODY_NAME_STRING:GSWString {value = nameString}

View file

@ -0,0 +1,4 @@
{
encoding = NSISOLatin1StringEncoding;
variables = {};
}

View file

@ -0,0 +1,8 @@
<HTML>
<HEAD>
<TITLE>Hello World!</TITLE>
</HEAD>
<BODY>
Hello <GSWEB NAME=BODY_NAME_STRING></GSWEB>!
</BODY>
</HTML>

View file

@ -0,0 +1,22 @@
/*
* HelloPage.h
*
* You may freely copy, distribute and reuse the code in this example.
* Apple disclaims any warranty of any kind, expressed or implied, as to
* its fitness for any particular use.
*
* This file declares the interface to the object that controls the Hello
* page.
*/
#import <GSWeb/GSWeb.h>
@interface HelloPage:GSWComponent
{
NSString *nameString;
}
- (void)setNameString:(NSString *)string;
@end

View file

@ -0,0 +1,27 @@
/*
* HelloPage.m
*
* You may freely copy, distribute and reuse the code in this example.
* Apple disclaims any warranty of any kind, expressed or implied, as to
* its fitness for any particular use.
*
* This is the implementation file for the object that controls the Hello
* page.
*/
#import "HelloPage.h"
@implementation HelloPage
- (void)dealloc
{
DESTROY(nameString);
[super dealloc];
}
- (void)setNameString:(NSString *)string
{
ASSIGN(nameString,string);
}
@end

View file

@ -0,0 +1,10 @@
#import <GSWeb/GSWeb.h>
int main(int argc, const char *argv[])
{
int ret=0;
NSAutoreleasePool *arp = [NSAutoreleasePool new];
ret=GSWApplicationMain(@"Hello", argc, argv);
[arp release];
return ret;
}

23
Examples/hello/INSTALL Normal file
View file

@ -0,0 +1,23 @@
To install this little application:
o install GNUstep, GNUstepWeb (including apache module),..
o do a make install in this directory
o add entry for this application in your apache module configuration file:
hello = {
adaptorTemplatesPath = "/home/httpd/GSWAdaptorTemplates";
GSWExtensionsFrameworkWebServerResources="/GSW/GSWExtensions/WebServerResources";
canDump = YES;
instances = {
1 = {
host=YourHostName;
port=9001;
parameters= {
transport=socket;
};
};
};
};
o cd /usr/GNUstep/System/GSWApps/Hello.gswa
o run ./ix86/linux-gnu/gnu-gnu-gnu/Hello
o open your browser a goto: http://YourHostName/GSWeb/hello

View file

@ -0,0 +1,23 @@
/*
* Main.wod
*
* You may freely copy, distribute and reuse the code in this example.
* NeXT disclaims any warranty of any kind, expressed or implied, as to
* its fitness for any particular use.
*
* Written by WebObjects Development Team
*
* This is the declarations file for the first page (Main) of the
* HelloWorldObjC application. Each declaration corresponds to a WEBOBJECT
* element in Main.html. The declarations specify a WODynamicElement to
* represent the corresponding WEBOBJECT element and configure the dynamic
* element with variables and methods defined in the Main object.
*
*/
NAME_FIELD:GSWTextField {value = nameString}
SUBMIT_BUTTON:GSWSubmitButton {action = sayHello}
MyForm: GSWForm {
}

View file

@ -0,0 +1,13 @@
<HTML>
<HEAD>
<TITLE>Hello World!</TITLE>
</HEAD>
<BODY>
<GSWEB NAME=MyForm>
What's your name?
<P>
<GSWEB NAME=NAME_FIELD><INPUT TYPE="text"></GSWEB>
<GSWEB NAME=SUBMIT_BUTTON><INPUT TYPE="SUBMIT"></GSWEB>
</GSWEB>
</BODY>
</HTML>

22
Examples/hello/Main.h Normal file
View file

@ -0,0 +1,22 @@
/*
* Main.h
*
* You may freely copy, distribute and reuse the code in this example.
* Apple disclaims any warranty of any kind, expressed or implied, as to
* its fitness for any particular use.
*
* This file declares the interface to the object that controls the Main
* page.
*/
#import <GSWeb/GSWeb.h>
@interface Main:GSWComponent
{
NSString *nameString;
}
- (GSWComponent *)sayHello;
@end

54
Examples/hello/Main.m Normal file
View file

@ -0,0 +1,54 @@
/*
* Main.m
*
* You may freely copy, distribute and reuse the code in this example.
* Apple disclaims any warranty of any kind, expressed or implied, as to
* its fitness for any particular use.
*
* Written by WebObjects Development Team
*
* This is the implementation file for the object that controls the Main
* page.
*/
#import "Main.h"
#import "Hello.h"
#import "HelloPage.h"
@implementation Main
- (void)dealloc
{
DESTROY(nameString);
[super dealloc];
}
- (GSWComponent *)sayHello
{
HelloPage *nextPage= (HelloPage*)[self pageWithName:@"HelloPage"];
// Here we are using the EOKeyValueCodingProtocol to set 'nameString' in the Hello page
// The alternative would be to implement the accessor method 'setNameString:'
// [nextPage takeValue:nameString forKey:@"nameString"];
[nextPage setNameString:nameString];
return nextPage;
}
@end
@interface Session:GSWSession
{
}
@end
@interface Application:GSWApplication
{
}
@end
@implementation Session
@end
@implementation Application
@end

View file

@ -0,0 +1,71 @@
# Makefile.postamble
# Copyright (C) 1999 Free Software Foundation, Inc.
#
# Written by: Manuel Guesdon <mguesdon@sbuilders.com>
# Date: Jan 1999
#
# This file is part of the GNUstep Web 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Makefile.postamble
#
# Project specific makefile rules
#
# Uncomment the targets you want.
# The double colons (::) are important, do not make them single colons
# otherwise the normal makefile rules will not be performed.
#
# Things to do before compiling
# before-all::
# Things to do after compiling
# after-all::
# Things to do before installing
# before-install::
# Things to do after installing
# after-install::
# Things to do before uninstalling
# before-uninstall::
# Things to do after uninstalling
# after-uninstall::
# Things to do before cleaning
# before-clean::
# Things to do after cleaning
# after-clean::
# Things to do before distcleaning
# before-distclean::
# Things to do after distcleaning
# after-distclean::
# Things to do before checking
# before-check::
# Things to do after checking
# after-check::
regenerate:
copy-dist: $(DIST_FILES)

View file

@ -0,0 +1,72 @@
# Copyright (C) 1999 Free Software Foundation, Inc.
#
# Written by: Manuel Guesdon <mguesdon@sbuilders.com>
# Date: Jan 1999
#
# This file is part of the GNUstep Web 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Makefile.preamble
#
# Project specific makefile variables, and additional
#
# Do not put any Makefile rules in this file, instead they should
# be put into Makefile.postamble.
#
#
# Flags dealing with compiling and linking
#
# Additional flags to pass to the preprocessor
ADDITIONAL_CPPFLAGS =
# Additional flags to pass to the Objective-C compiler
ADDITIONAL_OBJCFLAGS =
# Additional flags to pass to the C compiler
ADDITIONAL_CFLAGS =
# Additional flags to pass to the Objective-C compiler
#new
ifeq ($(GDL2), yes)
ADDITIONAL_OBJCFLAGS = -DUSE_BUILTIN -DGDL2
else
ADDITIONAL_OBJCFLAGS = -DUSE_BUILTIN
endif
# Additional include directories the compiler should search
ADDITIONAL_INCLUDE_DIRS = -I$(GNUSTEP_SYSTEM_ROOT)/db -I../..
# Additional LDFLAGS to pass to the linker
ifeq ($(debug), yes)
ADDITIONAL_LDFLAGS = -lFoundationExt_d -lGSWeb -lGSANTLR_d -lgnustep-db2_d -lgnustep-db2control_d
else
ADDITIONAL_LDFLAGS = -lFoundationExt -lGSWeb -lGSANTLR -lgnustep-db2 -lgnustep-db2control
endif
#-lgnustep-xraw
# Additional library directories the linker should search
ADDITIONAL_LIB_DIRS =
#
# Flags dealing with installing and uninstalling
#
# Additional directories to be created during installation
ADDITIONAL_INSTALL_DIRS =

View file

@ -0,0 +1,14 @@
defaults = {
GSWAdaptor = GSWDefaultAdaptor;
GSWDebugSetConfigFilePath = "/etc/gsweb/Hello.logstate";
GSWHost = "localhost";
GSWPort = 9001;
GSWApplicationBaseURL = "/GSW";
GSWFrameworksBaseURL = "/GSW/frameworks";
GSWLoadFrameworks = (
"gsweb/GSWExtensionsGSW",
"gsweb/GSWExtensions"
);
GSWMonitorAppConfFilePath = "/etc/httpd/conf/GSWebMonitor.conf";
GSWSessionTimeOut = 1200;
};

View file

@ -0,0 +1,2 @@
DYNAMIC_LINKER=simple
#GDL2=yes

View file

@ -277,7 +277,7 @@ int GSWApp_ReceiveLine(AppConnectHandle p_handle,
{
int iRetValue=-1;
#ifdef DEBUG
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWApp_ReceiveLine");
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWApp_ReceiveLine p_iBufferSize=%d",p_iBufferSize);
#endif
*p_pszBuffer=0;
if (!p_handle)

View file

@ -53,6 +53,9 @@ GSWHTTPResponse* GSWHTTPResponse_New(CONST char* p_pszStatus,void* p_pLogServerD
GSWHTTPResponse* pHTTPResponse=NULL;
BOOL fOk=FALSE;
// Accept "HTTP/1.0 200 OK GSWeb..." and "HTTP/1.0 200 OK GNUstep GSWeb..."
#ifdef DEBUG
GSWLog(GSW_INFO,p_pLogServerData,"p_pszStatus=%s",p_pszStatus);
#endif
if (strncmp(p_pszStatus,HTTP_SLASH,strlen(HTTP_SLASH))==0)
{
// Status Code
@ -63,8 +66,14 @@ GSWHTTPResponse* GSWHTTPResponse_New(CONST char* p_pszStatus,void* p_pLogServerD
fOk=TRUE;
pszSpace++;
uStatus=atoi(pszSpace);
#ifdef DEBUG
GSWLog(GSW_INFO,p_pLogServerData,"uStatus=%u",uStatus);
#endif
for(;fOk && *pszSpace && !isspace(*pszSpace);pszSpace++)
fOk=isdigit(*pszSpace);
#ifdef DEBUG
GSWLog(GSW_INFO,p_pLogServerData,"fOk=%d",(int)fOk);
#endif
if (fOk)
{
pHTTPResponse = calloc(1,sizeof(GSWHTTPResponse));

View file

@ -71,6 +71,7 @@ void GSWApplicationDebugSetChange()
_change=![_newStateString isEqualToString:_prevStateString];
else if (_prevStateString)
_change=![_prevStateString isEqualToString:_newStateString];
NSDebugFLog(@"_change=%d",_change);
if (_change)
{
@ -4080,7 +4081,7 @@ int GSWApplicationMain(NSString* applicationClassName,
//--------------------------------------------------------------------
+(NSBundle*)mainBundle
{
LOGClassFnNotImplemented(); //TODOFN
// LOGClassFnNotImplemented(); //TODOFN
return [NSBundle mainBundle];
/*
_flags=unsigned int UINT:104005633

View file

@ -344,188 +344,200 @@ printf("dealloc GSWDefaultAdaptorThread end");
//--------------------------------------------------------------------
-(BOOL)readRequestReturnedRequestLine:(NSString**)requestLine_
returnedHeaders:(NSDictionary**)headers_
returnedData:(NSData**)data_
returnedHeaders:(NSDictionary**)headers_
returnedData:(NSData**)data_
{
BOOL ok=NO;
LOGObjectFnStart();
if (!stream)
{
ExceptionRaise0(@"GSWDefaultAdaptorThread",@"no stream");
}
{
ExceptionRaise0(@"GSWDefaultAdaptorThread",@"no stream");
}
else
{
{
#define REQUEST_METHOD__UNKNOWN 0
#define REQUEST_METHOD__GET 1
#define REQUEST_METHOD__POST 2
NSMutableData* _pendingData=nil;
NSDate* maxDate=[NSDate dateWithTimeIntervalSinceNow:360]; //360s
NSData* dataBlock=nil;
int sleepTime=250; //250ms
int readenBytesNb=0;
int headersBytesNb=0;
int dataBytesNb=0;
int dataBlockLength=0;
int contentLength=-1;
int _requestMethod=REQUEST_METHOD__UNKNOWN;
BOOL _isRequestLineSetted=NO;
BOOL _isDataStep=NO;
BOOL _isAllDataReaden=NO;
BOOL _isElapsed=NO;
NSMutableDictionary* _headers=nil;
NSString* _userAgent=nil;
NSString* _remoteAddr=nil;
NSDebugMLog0(@"dataBlock try reading");
do
{
dataBlock=[stream availableDataNonBlocking];
dataBlockLength=[dataBlock length];
NSDebugMLog(@"dataBlockLength=%i",dataBlockLength);
if (dataBlockLength>0)
{
readenBytesNb+=dataBlockLength;
if (!_pendingData)
_pendingData=(NSMutableData*)[NSMutableData data];
[_pendingData appendData:dataBlock];
if (_isDataStep)
dataBytesNb=[_pendingData length];
else
{
int _newBytesCount=0;
NSMutableArray* _newLines=[GSWDefaultAdaptorThread completeLinesWithData:_pendingData
returnedConsumedCount:&_newBytesCount
returnedHeadersEndFlag:&_isDataStep];
NSDebugMLLog(@"low",@"newLines=%@ isDataStep=%s newBytesCount=%d",
_newLines,
_isDataStep ? "YES" : "NO",
_newBytesCount);
headersBytesNb+=_newBytesCount;
if (_newLines)
{
int i=0;
for(i=0;i<[_newLines count];i++)
{
NSString* _line=[_newLines objectAtIndex:i];
NSDebugMLLog(@"low",@"Line:%@",_line);
NSAssert([_line length]>0,@"No line length");
if (!_isRequestLineSetted)
{
*requestLine_=_line;
_isRequestLineSetted=YES;
}
else
{
NSString* _key=nil;
NSString* _value=nil;
NSArray* _newValue=nil;
NSArray* _prevValue=nil;
NSRange _keyRange=[_line rangeOfString:@":"];
if (_keyRange.length<=0)
{
_key=_line;
NSDebugMLLog(@"low",@"key:%@",_key);
_value=[NSString string];
}
else
{
_key=[_line substringToIndex:_keyRange.location];
NSDebugMLLog(@"low",@"key:%@",_key);
_key=[[_key stringByTrimmingSpaces] lowercaseString];
if (_keyRange.location+1<[_line length])
{
_value=[_line substringFromIndex:_keyRange.location+1];
_value=[_value stringByTrimmingSpaces];
}
else
_value=[NSString string];
NSDebugMLLog(@"low",@"_value:%@",_value);
};
NSDebugMLLog(@"low",@"key:%@ value:%@",_key,_value);
if ([_key isEqualToString:GSWHTTPHeader_ContentLength])
contentLength=[_value intValue];
else if ([_key isEqualToString:GSWHTTPHeader_Method[GSWNAMES_INDEX]]
|| [_key isEqualToString:GSWHTTPHeader_Method[WONAMES_INDEX]])
{
if ([_value isEqualToString:GSWHTTPHeader_MethodPost])
_requestMethod=REQUEST_METHOD__POST;
else if ([_value isEqualToString:GSWHTTPHeader_MethodGet])
_requestMethod=REQUEST_METHOD__GET;
else
{
NSAssert1(NO,@"Unknown method %@",_value);
};
}
else if ([_key isEqualToString:GSWHTTPHeader_UserAgent])
_userAgent=_value;
else if ([_key isEqualToString:GSWHTTPHeader_RemoteAddress[GSWNAMES_INDEX]]
||[_key isEqualToString:GSWHTTPHeader_RemoteAddress[WONAMES_INDEX]])
_remoteAddr=_value;
if ([_key isEqualToString:GSWHTTPHeader_AdaptorVersion[GSWNAMES_INDEX]]
|| [_key isEqualToString:GSWHTTPHeader_ServerName[GSWNAMES_INDEX]])
requestNamingConv=GSWNAMES_INDEX;
else if ([_key isEqualToString:GSWHTTPHeader_AdaptorVersion[WONAMES_INDEX]]
|| [_key isEqualToString:GSWHTTPHeader_ServerName[WONAMES_INDEX]])
requestNamingConv=WONAMES_INDEX;
_prevValue=[_headers objectForKey:_key];
NSDebugMLLog(@"low",@"_prevValue:%@",_prevValue);
if (_prevValue)
_newValue=[_prevValue arrayByAddingObject:_value];
else
_newValue=[NSArray arrayWithObject:_value];
if (!_headers)
_headers=[NSMutableDictionary dictionary];
[_headers setObject:_newValue
forKey:_key];
};
};
};
};
};
NSDebugMLog(@"_requestMethod=%d",_requestMethod);
dataBytesNb=[_pendingData length];
if (_isDataStep)
{
if (_requestMethod==REQUEST_METHOD__GET)
_isAllDataReaden=YES;
else if (_requestMethod==REQUEST_METHOD__POST)
_isAllDataReaden=(dataBytesNb>=contentLength);
};
if (!_isAllDataReaden)
{
_isElapsed=[[NSDate date]compare:maxDate]==NSOrderedDescending;
if (!_isElapsed)
{
usleep(sleepTime);//Is this the good method ? //TODOV
_isElapsed=[[NSDate date]compare:maxDate]==NSOrderedDescending;
};
};
} while (!_isAllDataReaden && !_isElapsed);
NSDebugMLog(@"GSWDefaultAdaptor: _userAgent=%@ _remoteAddr=%@ _isAllDataReaden=%s _isElapsed=%s readenBytesNb=%d contentLength=%d dataBytesNb=%d headersBytesNb=%d",
_userAgent,
_remoteAddr,
_isAllDataReaden ? "YES" : "NO",
_isElapsed ? "YES" : "NO",
readenBytesNb,
contentLength,
dataBytesNb,
headersBytesNb);
ok=_isAllDataReaden;
if (_isAllDataReaden)
{
*headers_=[[_headers copy] autorelease];
if ([_pendingData length]>0)
*data_=[_pendingData copy];
else
*data_=nil;
}
else
{
*requestLine_=nil;
*headers_=nil;
*data_=nil;
};
}
NSMutableData* _pendingData=nil;
NSDate* maxDate=[NSDate dateWithTimeIntervalSinceNow:360]; //360s
NSData* dataBlock=nil;
int sleepTime=250; //250ms
int readenBytesNb=0;
int headersBytesNb=0;
int dataBytesNb=0;
int dataBlockLength=0;
int contentLength=-1;
int _requestMethod=REQUEST_METHOD__UNKNOWN;
BOOL _isRequestLineSetted=NO;
BOOL _isDataStep=NO;
BOOL _isAllDataReaden=NO;
BOOL _isElapsed=NO;
NSMutableDictionary* _headers=nil;
NSString* _userAgent=nil;
NSString* _remoteAddr=nil;
NSDebugMLog0(@"dataBlock try reading");
do
{
dataBlock=[stream availableDataNonBlocking];
dataBlockLength=[dataBlock length];
NSDebugMLog(@"dataBlockLength=%i",dataBlockLength);
if (dataBlockLength>0)
{
readenBytesNb+=dataBlockLength;
if (!_pendingData)
_pendingData=(NSMutableData*)[NSMutableData data];
[_pendingData appendData:dataBlock];
if (_isDataStep)
dataBytesNb=[_pendingData length];
else
{
int _newBytesCount=0;
NSMutableArray* _newLines=[GSWDefaultAdaptorThread completeLinesWithData:_pendingData
returnedConsumedCount:&_newBytesCount
returnedHeadersEndFlag:&_isDataStep];
NSDebugMLLog(@"low",@"newLines=%p",_newLines);
NSDebugMLLog(@"low",@"newLines=%@",_newLines);
NSDebugMLLog(@"low",@"isDataStep=%s newBytesCount=%d",
_isDataStep ? "YES" : "NO",
_newBytesCount);
headersBytesNb+=_newBytesCount;
if (_newLines)
{
int i=0;
for(i=0;i<[_newLines count];i++)
{
NSString* _line=[_newLines objectAtIndex:i];
NSDebugMLLog(@"low",@"Line=%@",_line);
NSAssert([_line length]>0,@"No line length");
if (!_isRequestLineSetted)
{
*requestLine_=_line;
_isRequestLineSetted=YES;
}
else
{
NSString* _key=nil;
NSString* _value=nil;
NSArray* _newValue=nil;
NSArray* _prevValue=nil;
NSRange _keyRange=[_line rangeOfString:@":"];
if (_keyRange.length<=0)
{
_key=_line;
NSDebugMLLog(@"low",@"key=%@",_key);
_value=[NSString string];
}
else
{
_key=[_line substringToIndex:_keyRange.location];
NSDebugMLLog(@"low",@"location=%d key=%@",
_keyRange.location,
_key);
_key=[[_key stringByTrimmingSpaces] lowercaseString];
NSDebugMLLog(@"low",@"location=%d line length=%d key=%@",
_keyRange.location,
[_line length],
_key);
if (_keyRange.location+1<[_line length])
{
_value=[_line substringFromIndex:_keyRange.location+1];
NSDebugMLLog(@"low",@"value lengt=%d value=*%@*",
[_value length],
_value);
_value=[_value stringByTrimmingSpaces];
NSDebugMLLog(@"low",@"value=%@",
_value);
}
else
_value=[NSString string];
NSDebugMLLog(@"low",@"_value:%@",_value);
};
NSDebugMLLog(@"low",@"key:%@ value:%@",_key,_value);
if ([_key isEqualToString:GSWHTTPHeader_ContentLength])
contentLength=[_value intValue];
else if ([_key isEqualToString:GSWHTTPHeader_Method[GSWNAMES_INDEX]]
|| [_key isEqualToString:GSWHTTPHeader_Method[WONAMES_INDEX]])
{
if ([_value isEqualToString:GSWHTTPHeader_MethodPost])
_requestMethod=REQUEST_METHOD__POST;
else if ([_value isEqualToString:GSWHTTPHeader_MethodGet])
_requestMethod=REQUEST_METHOD__GET;
else
{
NSAssert1(NO,@"Unknown method %@",_value);
};
}
else if ([_key isEqualToString:GSWHTTPHeader_UserAgent])
_userAgent=_value;
else if ([_key isEqualToString:GSWHTTPHeader_RemoteAddress[GSWNAMES_INDEX]]
||[_key isEqualToString:GSWHTTPHeader_RemoteAddress[WONAMES_INDEX]])
_remoteAddr=_value;
if ([_key isEqualToString:GSWHTTPHeader_AdaptorVersion[GSWNAMES_INDEX]]
|| [_key isEqualToString:GSWHTTPHeader_ServerName[GSWNAMES_INDEX]])
requestNamingConv=GSWNAMES_INDEX;
else if ([_key isEqualToString:GSWHTTPHeader_AdaptorVersion[WONAMES_INDEX]]
|| [_key isEqualToString:GSWHTTPHeader_ServerName[WONAMES_INDEX]])
requestNamingConv=WONAMES_INDEX;
_prevValue=[_headers objectForKey:_key];
NSDebugMLLog(@"low",@"_prevValue:%@",_prevValue);
if (_prevValue)
_newValue=[_prevValue arrayByAddingObject:_value];
else
_newValue=[NSArray arrayWithObject:_value];
if (!_headers)
_headers=[NSMutableDictionary dictionary];
[_headers setObject:_newValue
forKey:_key];
};
};
};
};
};
NSDebugMLog(@"_requestMethod=%d",_requestMethod);
dataBytesNb=[_pendingData length];
if (_isDataStep)
{
if (_requestMethod==REQUEST_METHOD__GET)
_isAllDataReaden=YES;
else if (_requestMethod==REQUEST_METHOD__POST)
_isAllDataReaden=(dataBytesNb>=contentLength);
};
if (!_isAllDataReaden)
{
_isElapsed=[[NSDate date]compare:maxDate]==NSOrderedDescending;
if (!_isElapsed)
{
usleep(sleepTime);//Is this the good method ? //TODOV
_isElapsed=[[NSDate date]compare:maxDate]==NSOrderedDescending;
};
};
} while (!_isAllDataReaden && !_isElapsed);
NSDebugMLog(@"GSWDefaultAdaptor: _userAgent=%@ _remoteAddr=%@ _isAllDataReaden=%s _isElapsed=%s readenBytesNb=%d contentLength=%d dataBytesNb=%d headersBytesNb=%d",
_userAgent,
_remoteAddr,
_isAllDataReaden ? "YES" : "NO",
_isElapsed ? "YES" : "NO",
readenBytesNb,
contentLength,
dataBytesNb,
headersBytesNb);
ok=_isAllDataReaden;
if (_isAllDataReaden)
{
*headers_=[[_headers copy] autorelease];
if ([_pendingData length]>0)
*data_=[_pendingData copy];
else
*data_=nil;
}
else
{
*requestLine_=nil;
*headers_=nil;
*data_=nil;
};
}
LOGObjectFnStop();
return ok;
};
@ -596,6 +608,7 @@ printf("dealloc GSWDefaultAdaptorThread end");
BOOL ok=YES;
LOGObjectFnStart();
printf("class sendResponse: START\n");
NSDebugMLLog(@"low",@"response:%p",response);
[response willSend];
if (response)
{
@ -617,7 +630,9 @@ printf("dealloc GSWDefaultAdaptorThread end");
*/
NSString* empty=[NSString stringWithString:@"\n"];
NSDebugMLLog(@"low",@"head:%@",head);
NSDebugMLLog(@"low",@"responseData:%@",responseData);
[responseData appendData:[head dataUsingEncoding:NSASCIIStringEncoding]];
NSDebugMLLog(@"low",@"responseData:%@",responseData);
for(headerN=0;headerN<[headerKeys count];headerN++)
{
key=[headerKeys objectAtIndex:headerN];
@ -629,16 +644,19 @@ printf("dealloc GSWDefaultAdaptorThread end");
[headersForKey objectAtIndex:headerNForKey]];
[responseData appendData:[anHeader dataUsingEncoding:NSASCIIStringEncoding]];
NSDebugMLLog(@"low",@"anHeader:%@",anHeader);
NSDebugMLLog(@"low",@"responseData:%@",responseData);
};
};
// NSDebugMLLog(@"low",@"cl:%@",cl);
NSDebugMLLog(@"low",@"empty:%@",empty);
// [responseData appendData:[cl dataUsingEncoding:NSASCIIStringEncoding]];
NSDebugMLLog(@"low",@"responseData:%@",responseData);
[responseData appendData:[empty dataUsingEncoding:NSASCIIStringEncoding]];
NSDebugMLLog(@"low",@"responseData:%@",responseData);
NS_DURING
{
[stream writeData:responseData];
[aStream writeData:responseData];
}
NS_HANDLER
{

View file

@ -49,14 +49,15 @@ NSString* globalLanguagesPListPathName=nil;
{
NSString* _bundlePath=nil;
_mainBundle=[GSWApplication mainBundle];
NSDebugMLLog(@"resmanager",@"_mainBundle:%@",_mainBundle);
//NSDebugMLLog(@"resmanager",@"_mainBundle:%p",_mainBundle);
//NSDebugMLLog(@"resmanager",@"_mainBundle:%@",_mainBundle);
_bundlePath=[_mainBundle bundlePath];
NSDebugMLLog(@"resmanager",@"_bundlePath:%@",_bundlePath);
//NSDebugMLLog(@"resmanager",@"_bundlePath:%@",_bundlePath);
_deployedBundle=[GSWDeployedBundle bundleWithPath:_bundlePath];
NSDebugMLLog(@"resmanager",@"_deployedBundle:%@",_deployedBundle);
//NSDebugMLLog(@"resmanager",@"_deployedBundle:%@",_deployedBundle);
globalAppProjectBundle=[[_deployedBundle projectBundle] retain];
NSDebugMLLog(@"resmanager",@"globalAppProjectBundle=%@",globalAppProjectBundle);
//NSDebugMLLog(@"resmanager",@"globalAppProjectBundle=%@",globalAppProjectBundle);
NSAssert(globalAppProjectBundle,@"no globalAppProjectBundle");
// LOGDumpObject(globalAppProjectBundle,2);
//call _deployedBundle bundlePath

View file

@ -2,4 +2,4 @@
#
#
DYNAMIC_LINKER=simple
#GDL2=yes
GDL2=yes