Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions CocoaHTTPServer/CocoaHTTPServer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
D678F0AC2472FA6F006DB114 /* DDData.h in Headers */ = {isa = PBXBuildFile; fileRef = D678F0A62472FA6F006DB114 /* DDData.h */; };
D678F0AD2472FA6F006DB114 /* DDData.m in Sources */ = {isa = PBXBuildFile; fileRef = D678F0A72472FA6F006DB114 /* DDData.m */; };
D678F0B82472FA88006DB114 /* HTTPResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = D678F0AE2472FA88006DB114 /* HTTPResponse.h */; settings = {ATTRIBUTES = (Public, ); }; };
D678F0B92472FA88006DB114 /* HTTPServer.m in Sources */ = {isa = PBXBuildFile; fileRef = D678F0AF2472FA88006DB114 /* HTTPServer.m */; };
D678F0BA2472FA88006DB114 /* HTTPServer.h in Headers */ = {isa = PBXBuildFile; fileRef = D678F0B02472FA88006DB114 /* HTTPServer.h */; settings = {ATTRIBUTES = (Public, ); }; };
D678F0B92472FA88006DB114 /* CHTTPServer.m in Sources */ = {isa = PBXBuildFile; fileRef = D678F0AF2472FA88006DB114 /* CHTTPServer.m */; };
D678F0BA2472FA88006DB114 /* CHTTPServer.h in Headers */ = {isa = PBXBuildFile; fileRef = D678F0B02472FA88006DB114 /* CHTTPServer.h */; settings = {ATTRIBUTES = (Public, ); }; };
D678F0BB2472FA88006DB114 /* HTTPAuthenticationRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = D678F0B12472FA88006DB114 /* HTTPAuthenticationRequest.m */; };
D678F0BC2472FA88006DB114 /* HTTPMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D678F0B22472FA88006DB114 /* HTTPMessage.h */; settings = {ATTRIBUTES = (Public, ); }; };
D678F0BD2472FA88006DB114 /* HTTPLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = D678F0B32472FA88006DB114 /* HTTPLogging.h */; };
D678F0BE2472FA88006DB114 /* HTTPConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = D678F0B42472FA88006DB114 /* HTTPConnection.h */; settings = {ATTRIBUTES = (Public, ); }; };
D678F0BF2472FA88006DB114 /* HTTPConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = D678F0B52472FA88006DB114 /* HTTPConnection.m */; };
D678F0BE2472FA88006DB114 /* CHTTPConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = D678F0B42472FA88006DB114 /* CHTTPConnection.h */; settings = {ATTRIBUTES = (Public, ); }; };
D678F0BF2472FA88006DB114 /* CHTTPConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = D678F0B52472FA88006DB114 /* CHTTPConnection.m */; };
D678F0C02472FA88006DB114 /* HTTPAuthenticationRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = D678F0B62472FA88006DB114 /* HTTPAuthenticationRequest.h */; };
D678F0C12472FA88006DB114 /* HTTPMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D678F0B72472FA88006DB114 /* HTTPMessage.m */; };
D678F0C82472FA9C006DB114 /* MultipartFormDataParser.h in Headers */ = {isa = PBXBuildFile; fileRef = D678F0C22472FA9C006DB114 /* MultipartFormDataParser.h */; };
Expand Down Expand Up @@ -59,13 +59,13 @@
D678F0A62472FA6F006DB114 /* DDData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DDData.h; path = ../Core/Categories/DDData.h; sourceTree = "<group>"; };
D678F0A72472FA6F006DB114 /* DDData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DDData.m; path = ../Core/Categories/DDData.m; sourceTree = "<group>"; };
D678F0AE2472FA88006DB114 /* HTTPResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTTPResponse.h; path = ../Core/HTTPResponse.h; sourceTree = "<group>"; };
D678F0AF2472FA88006DB114 /* HTTPServer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HTTPServer.m; path = ../Core/HTTPServer.m; sourceTree = "<group>"; };
D678F0B02472FA88006DB114 /* HTTPServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTTPServer.h; path = ../Core/HTTPServer.h; sourceTree = "<group>"; };
D678F0AF2472FA88006DB114 /* CHTTPServer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CHTTPServer.m; path = ../Core/CHTTPServer.m; sourceTree = "<group>"; };
D678F0B02472FA88006DB114 /* CHTTPServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CHTTPServer.h; path = ../Core/CHTTPServer.h; sourceTree = "<group>"; };
D678F0B12472FA88006DB114 /* HTTPAuthenticationRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HTTPAuthenticationRequest.m; path = ../Core/HTTPAuthenticationRequest.m; sourceTree = "<group>"; };
D678F0B22472FA88006DB114 /* HTTPMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTTPMessage.h; path = ../Core/HTTPMessage.h; sourceTree = "<group>"; };
D678F0B32472FA88006DB114 /* HTTPLogging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTTPLogging.h; path = ../Core/HTTPLogging.h; sourceTree = "<group>"; };
D678F0B42472FA88006DB114 /* HTTPConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTTPConnection.h; path = ../Core/HTTPConnection.h; sourceTree = "<group>"; };
D678F0B52472FA88006DB114 /* HTTPConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HTTPConnection.m; path = ../Core/HTTPConnection.m; sourceTree = "<group>"; };
D678F0B42472FA88006DB114 /* CHTTPConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CHTTPConnection.h; path = ../Core/CHTTPConnection.h; sourceTree = "<group>"; };
D678F0B52472FA88006DB114 /* CHTTPConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CHTTPConnection.m; path = ../Core/CHTTPConnection.m; sourceTree = "<group>"; };
D678F0B62472FA88006DB114 /* HTTPAuthenticationRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTTPAuthenticationRequest.h; path = ../Core/HTTPAuthenticationRequest.h; sourceTree = "<group>"; };
D678F0B72472FA88006DB114 /* HTTPMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HTTPMessage.m; path = ../Core/HTTPMessage.m; sourceTree = "<group>"; };
D678F0C22472FA9C006DB114 /* MultipartFormDataParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MultipartFormDataParser.h; path = ../Core/Mime/MultipartFormDataParser.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -138,14 +138,14 @@
D678F09F2472FA35006DB114 /* Categories */,
D678F0B62472FA88006DB114 /* HTTPAuthenticationRequest.h */,
D678F0B12472FA88006DB114 /* HTTPAuthenticationRequest.m */,
D678F0B42472FA88006DB114 /* HTTPConnection.h */,
D678F0B52472FA88006DB114 /* HTTPConnection.m */,
D678F0B42472FA88006DB114 /* CHTTPConnection.h */,
D678F0B52472FA88006DB114 /* CHTTPConnection.m */,
D678F0B32472FA88006DB114 /* HTTPLogging.h */,
D678F0B22472FA88006DB114 /* HTTPMessage.h */,
D678F0B72472FA88006DB114 /* HTTPMessage.m */,
D678F0AE2472FA88006DB114 /* HTTPResponse.h */,
D678F0B02472FA88006DB114 /* HTTPServer.h */,
D678F0AF2472FA88006DB114 /* HTTPServer.m */,
D678F0B02472FA88006DB114 /* CHTTPServer.h */,
D678F0AF2472FA88006DB114 /* CHTTPServer.m */,
D678F0A02472FA42006DB114 /* Mime */,
D678F0A12472FA49006DB114 /* Responses */,
D678F0E62472FAB9006DB114 /* WebSocket.h */,
Expand Down Expand Up @@ -215,11 +215,11 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
D678F0BA2472FA88006DB114 /* HTTPServer.h in Headers */,
D678F0BA2472FA88006DB114 /* CHTTPServer.h in Headers */,
D678F0DD2472FAAE006DB114 /* HTTPDataResponse.h in Headers */,
D678F0B82472FA88006DB114 /* HTTPResponse.h in Headers */,
D678F0BC2472FA88006DB114 /* HTTPMessage.h in Headers */,
D678F0BE2472FA88006DB114 /* HTTPConnection.h in Headers */,
D678F0BE2472FA88006DB114 /* CHTTPConnection.h in Headers */,
D678F0E82472FAB9006DB114 /* WebSocket.h in Headers */,
D678F0C02472FA88006DB114 /* HTTPAuthenticationRequest.h in Headers */,
D678F0E42472FAAE006DB114 /* HTTPErrorResponse.h in Headers */,
Expand Down Expand Up @@ -307,15 +307,15 @@
buildActionMask = 2147483647;
files = (
D678F0BB2472FA88006DB114 /* HTTPAuthenticationRequest.m in Sources */,
D678F0BF2472FA88006DB114 /* HTTPConnection.m in Sources */,
D678F0BF2472FA88006DB114 /* CHTTPConnection.m in Sources */,
D678F0AD2472FA6F006DB114 /* DDData.m in Sources */,
D678F0DB2472FAAE006DB114 /* HTTPDynamicFileResponse.m in Sources */,
D678F0AA2472FA6F006DB114 /* DDNumber.m in Sources */,
D678F0C92472FA9C006DB114 /* MultipartMessageHeaderField.m in Sources */,
D678F0CD2472FA9C006DB114 /* MultipartMessageHeader.m in Sources */,
D678F0E52472FAAE006DB114 /* HTTPErrorResponse.m in Sources */,
D678F0E92472FAB9006DB114 /* WebSocket.m in Sources */,
D678F0B92472FA88006DB114 /* HTTPServer.m in Sources */,
D678F0B92472FA88006DB114 /* CHTTPServer.m in Sources */,
D678F0E22472FAAE006DB114 /* HTTPRedirectResponse.m in Sources */,
D678F0CC2472FA9C006DB114 /* MultipartFormDataParser.m in Sources */,
D678F0AB2472FA6F006DB114 /* DDRange.m in Sources */,
Expand Down
4 changes: 2 additions & 2 deletions CocoaHTTPServer/CocoaHTTPServer/CocoaHTTPServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ FOUNDATION_EXPORT const unsigned char CocoaHTTPServerVersionString[];
#import <CocoaHTTPServer/HTTPResponse.h>
#import <CocoaHTTPServer/HTTPDataResponse.h>
#import <CocoaHTTPServer/HTTPMessage.h>
#import <CocoaHTTPServer/HTTPServer.h>
#import <CocoaHTTPServer/HTTPConnection.h>
#import <CocoaHTTPServer/CHTTPServer.h>
#import <CocoaHTTPServer/CHTTPConnection.h>
14 changes: 7 additions & 7 deletions Core/HTTPConnection.h → Core/CHTTPConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@class GCDAsyncSocket;
@class HTTPMessage;
@class HTTPServer;
@class CHTTPServer;
@class WebSocket;
@protocol HTTPResponse;

Expand All @@ -15,15 +15,15 @@

@interface HTTPConfig : NSObject
{
HTTPServer __unsafe_unretained *server;
CHTTPServer __unsafe_unretained *server;
NSString __strong *documentRoot;
dispatch_queue_t queue;
}

- (id)initWithServer:(HTTPServer *)server documentRoot:(NSString *)documentRoot;
- (id)initWithServer:(HTTPServer *)server documentRoot:(NSString *)documentRoot queue:(dispatch_queue_t)q;
- (id)initWithServer:(CHTTPServer *)server documentRoot:(NSString *)documentRoot;
- (id)initWithServer:(CHTTPServer *)server documentRoot:(NSString *)documentRoot queue:(dispatch_queue_t)q;

@property (nonatomic, unsafe_unretained, readonly) HTTPServer *server;
@property (nonatomic, unsafe_unretained, readonly) CHTTPServer *server;
@property (nonatomic, strong, readonly) NSString *documentRoot;
@property (nonatomic, readonly) dispatch_queue_t queue;

Expand All @@ -33,7 +33,7 @@
#pragma mark -
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

@interface HTTPConnection : NSObject
@interface CHTTPConnection : NSObject
{
dispatch_queue_t connectionQueue;
GCDAsyncSocket *asyncSocket;
Expand Down Expand Up @@ -113,7 +113,7 @@

@end

@interface HTTPConnection (AsynchronousHTTPResponse)
@interface CHTTPConnection (AsynchronousHTTPResponse)
- (void)responseHasAvailableData:(NSObject<HTTPResponse> *)sender;
- (void)responseDidAbort:(NSObject<HTTPResponse> *)sender;
@end
12 changes: 6 additions & 6 deletions Core/HTTPConnection.m → Core/CHTTPConnection.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "HTTPServer.h"
#import "HTTPConnection.h"
#import "CHTTPServer.h"
#import "CHTTPConnection.h"
#import "HTTPMessage.h"
#import "HTTPResponse.h"
#import "HTTPAuthenticationRequest.h"
Expand Down Expand Up @@ -81,7 +81,7 @@
// the HTTP_RESPONSE tag. For all other segments prior to the last segment use HTTP_PARTIAL_RESPONSE, or some other
// tag of your own invention.

@interface HTTPConnection (PrivateAPI)
@interface CHTTPConnection (PrivateAPI)
- (void)startReadingRequest;
- (void)sendResponseHeadersAndBody;
@end
Expand All @@ -90,7 +90,7 @@ - (void)sendResponseHeadersAndBody;
#pragma mark -
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

@implementation HTTPConnection
@implementation CHTTPConnection

static dispatch_queue_t recentNonceQueue;
static NSMutableArray *recentNonces;
Expand Down Expand Up @@ -2667,7 +2667,7 @@ @implementation HTTPConfig
@synthesize documentRoot;
@synthesize queue;

- (id)initWithServer:(HTTPServer *)aServer documentRoot:(NSString *)aDocumentRoot
- (id)initWithServer:(CHTTPServer *)aServer documentRoot:(NSString *)aDocumentRoot
{
if ((self = [super init]))
{
Expand All @@ -2677,7 +2677,7 @@ - (id)initWithServer:(HTTPServer *)aServer documentRoot:(NSString *)aDocumentRoo
return self;
}

- (id)initWithServer:(HTTPServer *)aServer documentRoot:(NSString *)aDocumentRoot queue:(dispatch_queue_t)q
- (id)initWithServer:(CHTTPServer *)aServer documentRoot:(NSString *)aDocumentRoot queue:(dispatch_queue_t)q
{
if ((self = [super init]))
{
Expand Down
2 changes: 1 addition & 1 deletion Core/HTTPServer.h → Core/CHTTPServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#endif


@interface HTTPServer : NSObject IMPLEMENTED_PROTOCOLS
@interface CHTTPServer : NSObject IMPLEMENTED_PROTOCOLS
{
// Underlying asynchronous TCP/IP socket
GCDAsyncSocket *asyncSocket;
Expand Down
14 changes: 7 additions & 7 deletions Core/HTTPServer.m → Core/CHTTPServer.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "HTTPServer.h"
#import "HTTPConnection.h"
#import "CHTTPServer.h"
#import "CHTTPConnection.h"
#import "WebSocket.h"
@import CocoaAsyncSocket;

Expand All @@ -11,7 +11,7 @@
//// Other flags: trace
//static const int httpLogLevel = HTTP_LOG_LEVEL_ERROR; // HTTP_LOG_LEVEL_INFO; // | HTTP_LOG_FLAG_TRACE;

@interface HTTPServer (PrivateAPI)
@interface CHTTPServer (PrivateAPI)

- (void)unpublishBonjour;
- (void)publishBonjour;
Expand All @@ -25,7 +25,7 @@ + (void)performBonjourBlock:(dispatch_block_t)block;
#pragma mark -
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

@implementation HTTPServer
@implementation CHTTPServer

/**
* Standard Constructor.
Expand Down Expand Up @@ -53,7 +53,7 @@ - (id)init
asyncSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:serverQueue];

// Use default connection class of HTTPConnection
connectionClass = [HTTPConnection self];
connectionClass = [CHTTPConnection self];

// By default bind on all available interfaces, en1, wifi etc
interface = nil;
Expand Down Expand Up @@ -451,7 +451,7 @@ - (void)stop:(BOOL)keepExistingConnections
{
// Stop all HTTP connections the server owns
[self->connectionsLock lock];
for (HTTPConnection *connection in self->connections)
for (CHTTPConnection *connection in self->connections)
{
[connection stop];
}
Expand Down Expand Up @@ -545,7 +545,7 @@ - (HTTPConfig *)config

- (void)socket:(GCDAsyncSocket *)sock didAcceptNewSocket:(GCDAsyncSocket *)newSocket
{
HTTPConnection *newConnection = (HTTPConnection *)[[connectionClass alloc] initWithAsyncSocket:newSocket
CHTTPConnection *newConnection = (CHTTPConnection *)[[connectionClass alloc] initWithAsyncSocket:newSocket
configuration:[self config]];
[connectionsLock lock];
[connections addObject:newConnection];
Expand Down
6 changes: 3 additions & 3 deletions Core/Responses/HTTPAsyncFileResponse.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#import <Foundation/Foundation.h>
#import "HTTPResponse.h"

@class HTTPConnection;
@class CHTTPConnection;

/**
* This is an asynchronous version of HTTPFileResponse.
Expand All @@ -13,7 +13,7 @@

@interface HTTPAsyncFileResponse : NSObject <HTTPResponse>
{
HTTPConnection *connection;
CHTTPConnection *connection;

NSString *filePath;
UInt64 fileLength;
Expand All @@ -34,7 +34,7 @@
BOOL readSourceSuspended;
}

- (id)initWithFilePath:(NSString *)filePath forConnection:(HTTPConnection *)connection;
- (id)initWithFilePath:(NSString *)filePath forConnection:(CHTTPConnection *)connection;
- (NSString *)filePath;

@end
Expand Down
4 changes: 2 additions & 2 deletions Core/Responses/HTTPAsyncFileResponse.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "HTTPAsyncFileResponse.h"
#import "HTTPConnection.h"
#import "CHTTPConnection.h"

#import <unistd.h>
#import <fcntl.h>
Expand Down Expand Up @@ -33,7 +33,7 @@

@implementation HTTPAsyncFileResponse

- (id)initWithFilePath:(NSString *)fpath forConnection:(HTTPConnection *)parent
- (id)initWithFilePath:(NSString *)fpath forConnection:(CHTTPConnection *)parent
{
if ((self = [super init]))
{
Expand Down
2 changes: 1 addition & 1 deletion Core/Responses/HTTPDynamicFileResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
}

- (id)initWithFilePath:(NSString *)filePath
forConnection:(HTTPConnection *)connection
forConnection:(CHTTPConnection *)connection
separator:(NSString *)separatorStr
replacementDictionary:(NSDictionary *)dictionary;

Expand Down
4 changes: 2 additions & 2 deletions Core/Responses/HTTPDynamicFileResponse.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "HTTPDynamicFileResponse.h"
#import "HTTPConnection.h"
#import "CHTTPConnection.h"

#if ! __has_feature(objc_arc)
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
Expand All @@ -15,7 +15,7 @@
@implementation HTTPDynamicFileResponse

- (id)initWithFilePath:(NSString *)fpath
forConnection:(HTTPConnection *)parent
forConnection:(CHTTPConnection *)parent
separator:(NSString *)separatorStr
replacementDictionary:(NSDictionary *)dict
{
Expand Down
6 changes: 3 additions & 3 deletions Core/Responses/HTTPFileResponse.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#import <Foundation/Foundation.h>
#import "HTTPResponse.h"

@class HTTPConnection;
@class CHTTPConnection;


@interface HTTPFileResponse : NSObject <HTTPResponse>
{
HTTPConnection *connection;
CHTTPConnection *connection;

NSString *filePath;
UInt64 fileLength;
Expand All @@ -19,7 +19,7 @@
NSUInteger bufferSize;
}

- (id)initWithFilePath:(NSString *)filePath forConnection:(HTTPConnection *)connection;
- (id)initWithFilePath:(NSString *)filePath forConnection:(CHTTPConnection *)connection;
- (NSString *)filePath;

@end
4 changes: 2 additions & 2 deletions Core/Responses/HTTPFileResponse.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "HTTPFileResponse.h"
#import "HTTPConnection.h"
#import "CHTTPConnection.h"

#import <unistd.h>
#import <fcntl.h>
Expand All @@ -17,7 +17,7 @@

@implementation HTTPFileResponse

- (id)initWithFilePath:(NSString *)fpath forConnection:(HTTPConnection *)parent
- (id)initWithFilePath:(NSString *)fpath forConnection:(CHTTPConnection *)parent
{
if((self = [super init]))
{
Expand Down