mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-06-04 19:11:17 +00:00
o remove response saving (now use recording)
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@18164 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b7ab1bed16
commit
1a437a835a
2 changed files with 6 additions and 59 deletions
|
@ -1,5 +1,6 @@
|
||||||
/** GSWDefaultAdaptorThread.h - GSWeb: Class GSWDefaultAdaptorThread
|
/** GSWDefaultAdaptorThread.h - <title>GSWeb: Class GSWDefaultAdaptorThread</title>
|
||||||
Copyright (C) 1999-2002 Free Software Foundation, Inc.
|
|
||||||
|
Copyright (C) 1999-2003 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
|
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
|
||||||
Date: Feb 1999
|
Date: Feb 1999
|
||||||
|
@ -82,9 +83,6 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
|
||||||
+(void)sendRetryLasterResponseToStream:(NSFileHandle*)stream;
|
+(void)sendRetryLasterResponseToStream:(NSFileHandle*)stream;
|
||||||
+(void)sendConnectionRefusedResponseToStream:(NSFileHandle*)stream
|
+(void)sendConnectionRefusedResponseToStream:(NSFileHandle*)stream
|
||||||
withMessage:(NSString*)message;
|
withMessage:(NSString*)message;
|
||||||
+(void)saveResponse:(GSWResponse*)response
|
|
||||||
data:(NSData*)allResponseData
|
|
||||||
remoteAddress:(NSString*)remoteAddress;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -377,7 +377,7 @@ RCS_ID("$Id$")
|
||||||
NSMutableData* pendingData=nil;
|
NSMutableData* pendingData=nil;
|
||||||
NSDate* maxDate=[NSDate dateWithTimeIntervalSinceNow:360]; //360s
|
NSDate* maxDate=[NSDate dateWithTimeIntervalSinceNow:360]; //360s
|
||||||
NSData* dataBlock=nil;
|
NSData* dataBlock=nil;
|
||||||
int sleepTime=250; //250ms
|
double sleepTime=0.250; //250ms
|
||||||
int readenBytesNb=0;
|
int readenBytesNb=0;
|
||||||
int headersBytesNb=0;
|
int headersBytesNb=0;
|
||||||
int dataBytesNb=0;
|
int dataBytesNb=0;
|
||||||
|
@ -524,7 +524,7 @@ RCS_ID("$Id$")
|
||||||
isElapsed=[[NSDate date]compare:maxDate]==NSOrderedDescending;
|
isElapsed=[[NSDate date]compare:maxDate]==NSOrderedDescending;
|
||||||
if (!isElapsed)
|
if (!isElapsed)
|
||||||
{
|
{
|
||||||
usleep(sleepTime);//Is this the good method ? //TODOV
|
NSTimeIntervalSleep(sleepTime);//Is this the good method ? //TODOV
|
||||||
isElapsed=[[NSDate date]compare:maxDate]==NSOrderedDescending;
|
isElapsed=[[NSDate date]compare:maxDate]==NSOrderedDescending;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -575,7 +575,7 @@ RCS_ID("$Id$")
|
||||||
if ([requestLineArray count]!=3)
|
if ([requestLineArray count]!=3)
|
||||||
{
|
{
|
||||||
ExceptionRaise(@"GSWDefaultAdaptorThread",
|
ExceptionRaise(@"GSWDefaultAdaptorThread",
|
||||||
@"bad request first line (elements count %d != 3).\nrequestLine: %@\nrequestLineArray: %@",
|
@"bad request first line (elements count %d != 3). requestLine: '%@'.RequestLineArray: %@",
|
||||||
[requestLineArray count],
|
[requestLineArray count],
|
||||||
requestLine,
|
requestLine,
|
||||||
requestLineArray);
|
requestLineArray);
|
||||||
|
@ -692,9 +692,6 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
|
||||||
GSWHTTPHeader_Response_OK,
|
GSWHTTPHeader_Response_OK,
|
||||||
GSWHTTPHeader_Response_HeaderLineEnd[requestNamingConv]];
|
GSWHTTPHeader_Response_HeaderLineEnd[requestNamingConv]];
|
||||||
NSString* empty=[NSString stringWithString:@"\n"];
|
NSString* empty=[NSString stringWithString:@"\n"];
|
||||||
NSDebugDeepMLLog(@"low",@"[GSWApplication saveResponsesPath]:%@",[GSWApplication saveResponsesPath]);
|
|
||||||
if ([GSWApplication saveResponsesPath])
|
|
||||||
allResponseData=(NSMutableData*)[NSMutableData data];
|
|
||||||
|
|
||||||
NSDebugDeepMLLog(@"low",@"head:%@",head);
|
NSDebugDeepMLLog(@"low",@"head:%@",head);
|
||||||
NSDebugDeepMLLog(@"low",@"responseData:%@",responseData);
|
NSDebugDeepMLLog(@"low",@"responseData:%@",responseData);
|
||||||
|
@ -724,7 +721,6 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
|
||||||
[responseData appendData:[empty dataUsingEncoding:NSASCIIStringEncoding]];
|
[responseData appendData:[empty dataUsingEncoding:NSASCIIStringEncoding]];
|
||||||
NSDebugDeepMLLog(@"low",@"responseData:%@",responseData);
|
NSDebugDeepMLLog(@"low",@"responseData:%@",responseData);
|
||||||
|
|
||||||
[allResponseData appendData:responseData];
|
|
||||||
NS_DURING
|
NS_DURING
|
||||||
{
|
{
|
||||||
[aStream writeData:responseData];
|
[aStream writeData:responseData];
|
||||||
|
@ -755,7 +751,6 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
|
||||||
encoding:NSISOLatin1StringEncoding]
|
encoding:NSISOLatin1StringEncoding]
|
||||||
autorelease]);
|
autorelease]);
|
||||||
|
|
||||||
[allResponseData appendData:responseData];
|
|
||||||
NS_DURING
|
NS_DURING
|
||||||
{
|
{
|
||||||
[aStream writeData:responseData];
|
[aStream writeData:responseData];
|
||||||
|
@ -773,10 +768,6 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
|
||||||
NS_ENDHANDLER;
|
NS_ENDHANDLER;
|
||||||
NSDebugDeepMLLog0(@"info",@"Response content Written");
|
NSDebugDeepMLLog0(@"info",@"Response content Written");
|
||||||
};
|
};
|
||||||
if (allResponseData)
|
|
||||||
[self saveResponse:response
|
|
||||||
data:allResponseData
|
|
||||||
remoteAddress:remoteAddress];
|
|
||||||
};
|
};
|
||||||
[aStream closeFile];
|
[aStream closeFile];
|
||||||
LOGObjectFnStop();
|
LOGObjectFnStop();
|
||||||
|
@ -852,46 +843,4 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
|
||||||
DESTROY(pool);
|
DESTROY(pool);
|
||||||
};
|
};
|
||||||
|
|
||||||
+(NSString*)savedResponseFilenameWithResponse:(GSWResponse*)response
|
|
||||||
remoteAddress:(NSString*)remoteAddress
|
|
||||||
{
|
|
||||||
NSString* dateString=[[NSCalendarDate calendarDate] descriptionWithCalendarFormat:@"%Y-%m-%d_%H-%M-%S.%F"];
|
|
||||||
return [NSString stringWithFormat:@"GSWeb-%@-Response-%@-%@-%p",
|
|
||||||
[[GSWApplication application]name],
|
|
||||||
dateString,
|
|
||||||
(remoteAddress ? remoteAddress : @"unknown"),
|
|
||||||
response];
|
|
||||||
};
|
|
||||||
|
|
||||||
+(void)saveResponse:(GSWResponse*)response
|
|
||||||
data:(NSData*)allResponseData
|
|
||||||
remoteAddress:(NSString*)remoteAddress
|
|
||||||
{
|
|
||||||
NSString* path=nil;
|
|
||||||
LOGObjectFnStart();
|
|
||||||
path=[GSWApplication saveResponsesPath];
|
|
||||||
if (path)
|
|
||||||
{
|
|
||||||
path=[path stringByAppendingPathComponent:[self savedResponseFilenameWithResponse:response
|
|
||||||
remoteAddress:remoteAddress]];
|
|
||||||
NSDebugDeepMLog(@"path=%@:",path);
|
|
||||||
NS_DURING
|
|
||||||
{
|
|
||||||
NSString* str=[[[NSString alloc]initWithData:allResponseData
|
|
||||||
encoding:NSASCIIStringEncoding]autorelease];
|
|
||||||
[str writeToFile:path
|
|
||||||
atomically:NO];
|
|
||||||
}
|
|
||||||
NS_HANDLER
|
|
||||||
{
|
|
||||||
LOGException(@"GSWDefaultAdaptorThread: Exception:%@ (%@)",
|
|
||||||
localException,[localException reason]);
|
|
||||||
NSDebugMLog(@"EXCEPTION GSWDefaultAdaptorThread: Exception:%@ (%@)",
|
|
||||||
localException,[localException reason]);
|
|
||||||
}
|
|
||||||
NS_ENDHANDLER;
|
|
||||||
}
|
|
||||||
LOGObjectFnStop();
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue