Browse files

Make Frank compile

  • Loading branch information...
1 parent 651e825 commit f925533a49cf55261349ff42806a67a0805ba41c @soutaro soutaro committed Jul 28, 2012
Showing with 26 additions and 11 deletions.
  1. +2 −0 src/FrankCommandRoute.m
  2. +5 −0 src/FrankLoader.m
  3. +0 −1 src/FrankServer.m
  4. +16 −9 src/RoutingHTTPConnection.m
  5. +3 −1 src/StaticResourcesRoute.m
View
2 src/FrankCommandRoute.m
@@ -6,6 +6,8 @@
// Copyright 2010 ThoughtWorks. See NOTICE file for details.
//
+#import "HTTPDataResponse.h"
+
#import "FrankCommandRoute.h"
#import "RoutingHTTPConnection.h"
View
5 src/FrankLoader.m
@@ -13,6 +13,9 @@
#import <dlfcn.h>
+#import "DDLog.h"
+#import "DDTTYLogger.h"
+
BOOL frankLogEnabled = NO;
@implementation FrankLoader
@@ -24,6 +27,8 @@ + (void)applicationDidBecomeActive:(NSNotification *)notification{
}
+ (void)load{
+ [DDLog addLogger:[DDTTYLogger sharedInstance]];
+
NSLog(@"Injecting Frank loader");
NSAutoreleasePool *autoreleasePool = [[NSAutoreleasePool alloc] init];
View
1 src/FrankServer.m
@@ -37,7 +37,6 @@ - (id) initWithStaticFrankBundleNamed:(NSString *)bundleName
if( ![bundleName hasSuffix:@".bundle"] )
bundleName = [bundleName stringByAppendingString:@".bundle"];
-
FrankCommandRoute *frankCommandRoute = [[[FrankCommandRoute alloc] init] autorelease];
[frankCommandRoute registerCommand:[[[DumpCommand alloc]init]autorelease] withName:@"dump"];
[frankCommandRoute registerCommand:[[[MapOperationCommand alloc]init]autorelease] withName:@"map"];
View
25 src/RoutingHTTPConnection.m
@@ -45,21 +45,28 @@ - (NSString *)postDataAsString{
* Returns whether or not the server will accept POSTs.
* That is, whether the server will accept uploaded data for the given URI.
**/
-- (BOOL)supportsPOST:(NSString *)path withSize:(UInt64)contentLength
+//- (BOOL)supportsPOST:(NSString *)path withSize:(UInt64)contentLength
+//{
+// return [self.router canHandlePostForPath:path];
+//}
+- (BOOL)supportsMethod:(NSString *)method atPath:(NSString *)path
{
- return [self.router canHandlePostForPath:path];
+ NSLog(@"%s, %@", __func__, method);
+ return YES;
}
/**
* This method is called to handle data read from a POST.
* The given data is part of the POST body.
**/
-- (void)processPostDataChunk:(NSData *)postDataChunk
+- (void)processBodyData:(NSData *)postDataChunk
{
- if( nil == _postData )
- _postData = [[NSMutableData alloc] init];
-
- [_postData appendData:postDataChunk];
+ [_postData appendData:postDataChunk];
+}
+
+- (void)prepareForBodyWithSize:(UInt64)contentLength
+{
+ _postData = [[NSMutableData alloc] initWithCapacity:contentLength];
}
/**
@@ -69,11 +76,11 @@ - (void)processPostDataChunk:(NSData *)postDataChunk
* HTTPFileResponse is a wrapper for an NSFileHandle object, and is the preferred way to send a file response.
* HTTPDataResopnse is a wrapper for an NSData object, and may be used to send a custom response.
**/
-- (NSObject<HTTPResponse> *)httpResponseForURI:(NSString *)path
+- (NSObject<HTTPResponse> *)httpResponseForMethod:(NSString *)method URI:(NSString *)path
{
NSObject<HTTPResponse> *response = [self.router handleRequestForPath:path withConnection:self];
- postContentLength = 0;
+ requestContentLength = 0;
if( nil != _postData )
{
[_postData release];
View
4 src/StaticResourcesRoute.m
@@ -6,6 +6,8 @@
// Copyright 2010 ThoughtWorks. See NOTICE file for details.
//
+#import "RoutingHTTPConnection.h"
+#import "HTTPFileResponse.h"
#import "StaticResourcesRoute.h"
extern BOOL frankLogEnabled;
@@ -37,7 +39,7 @@ - (void) dealloc
}
BOOL isDir = YES;
if( [[NSFileManager defaultManager] fileExistsAtPath:fullPathToRequestedResource isDirectory:&isDir] && !isDir )
- return [[HTTPFileResponse alloc] initWithFilePath:fullPathToRequestedResource];
+ return [[HTTPFileResponse alloc] initWithFilePath:fullPathToRequestedResource forConnection:connection];
else
return nil;
}

0 comments on commit f925533

Please sign in to comment.