Skip to content

Commit

Permalink
Fixed XML-RPC server to work with pluggable HTTP server
Browse files Browse the repository at this point in the history
  • Loading branch information
stevestreza committed Nov 23, 2008
1 parent b8430b5 commit 1b716c2
Show file tree
Hide file tree
Showing 4 changed files with 1,191 additions and 161 deletions.
Expand Up @@ -20,8 +20,12 @@

CFHTTPMessageRef message;
BOOL isMessageComplete;

NSData *messageBody;
}

@property (readonly) NSData *messageBody;

- (id)initWithFileHandle:(NSFileHandle *)fh delegate:(id)dl;
- (NSFileHandle *)fileHandle;
- (TCHTTPServer *)server;
Expand Down
15 changes: 12 additions & 3 deletions Classes/Plugins/Organization/TCHTTPServerPlugin/TCHTTPConnection.m
Expand Up @@ -24,6 +24,7 @@ - (id)initWithFileHandle:(NSFileHandle *)fh delegate:(id)dl

isMessageComplete = YES;
message = NULL;
messageBody = [[NSMutableData data] retain];

// Get IP address of remote client
CFSocketRef socket;
Expand Down Expand Up @@ -88,9 +89,15 @@ - (void)dataReceivedNotification:(NSNotification *)notification
Boolean success = CFHTTPMessageAppendBytes(message,
[data bytes],
[data length]);

if( success ) {
if( CFHTTPMessageIsHeaderComplete(message) ) {
isMessageComplete = YES;

[messageBody release];
messageBody = nil;
[self messageBody];

CFURLRef url = CFHTTPMessageCopyRequestURL(message);
[delegate newRequestWithURL:(NSURL *)url connection:self];
CFRelease(url);
Expand Down Expand Up @@ -160,9 +167,11 @@ -(void)_setServer:(TCHTTPServer *)srv{
}

-(NSData *)messageBody{
CFDataRef messageData = CFHTTPMessageCopyBody(message);
NSData *messageBody = (NSData *)messageData;
return [messageBody autorelease];
if(!messageBody){
CFDataRef messageData = CFHTTPMessageCopyBody(message);
messageBody = (NSData *)messageData;
}
return messageBody;
}

@end

0 comments on commit 1b716c2

Please sign in to comment.