Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: robbiehanson/CocoaHTTPServer
base: master
...
head fork: bignerdranch/CocoaHTTPServer
compare: master
Checking mergeability… Don’t worry, you can still create the pull request.
  • 16 commits
  • 7 files changed
  • 0 commit comments
  • 2 contributors
Commits on Mar 29, 2012
Alex Silverman Added httpHeaders property de93d97
Alex Silverman Remove delegate from web sockets when server is stopped 2714269
Alex Silverman Changed socket disconnect be synchronous d973683
Alex Silverman Removed locks to accommodate the synchronous changes from last commit d0fb0d1
Alex Silverman blah bafaee0
Commits on Mar 30, 2012
Alex Silverman Made the connection queue concurrent e55e9b0
Commits on Apr 02, 2012
Alex Silverman Added a conditional check e9c8e47
Alex Silverman Added a mutableCopy on the init method AsyncReadPacket 3c2f0b8
Alex Silverman Merge remote-tracking branch 'upstream/master' 04bcd2b
Commits on Apr 11, 2012
Alex Silverman Blah d84adb2
Commits on Apr 17, 2012
Alex Silverman @synchronized some calls f080789
Commits on Apr 25, 2012
Alex Silverman added more @synchronized calls 875c902
Commits on Jul 03, 2012
Alex Silverman Merge remote-tracking branch 'upstream/master' cbe7e6c
Commits on Mar 13, 2013
@jeremy-w jeremy-w fixes uninitialized variable warning 0feeb97
Commits on Nov 21, 2013
@jeremy-w jeremy-w Merge branch 'master' of github.com:robbiehanson/CocoaHTTPServer
Conflicts:
	Core/HTTPConnection.m
	Core/HTTPServer.m

This puts us at v2.3+.
8585204
@jeremy-w jeremy-w fixes enum conversion warning a89b1f7
View
36 Core/HTTPConnection.m
@@ -582,7 +582,7 @@ - (void)start
**/
- (void)stop
{
- dispatch_async(connectionQueue, ^{ @autoreleasepool {
+ dispatch_sync(connectionQueue, ^{ @autoreleasepool {
// Disconnect the socket.
// The socketDidDisconnect delegate method will handle everything else.
@@ -1318,11 +1318,13 @@ - (NSUInteger)writeQueueSize
{
NSUInteger result = 0;
- NSUInteger i;
- for(i = 0; i < [responseDataSizes count]; i++)
- {
- result += [[responseDataSizes objectAtIndex:i] unsignedIntegerValue];
- }
+ @synchronized(responseDataSizes) {
+ NSUInteger i;
+ for(i = 0; i < [responseDataSizes count]; i++)
+ {
+ result += [[responseDataSizes objectAtIndex:i] unsignedIntegerValue];
+ }
+ }
return result;
}
@@ -2363,9 +2365,11 @@ - (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag
if (tag == HTTP_PARTIAL_RESPONSE_BODY)
{
// Update the amount of data we have in asyncSocket's write queue
+ @synchronized(responseDataSizes) {
if ([responseDataSizes count] > 0) {
[responseDataSizes removeObjectAtIndex:0];
}
+ } // @synchronized(responseDateSizes)
// We only wrote a part of the response - there may be more
[self continueSendingStandardResponseBody];
@@ -2374,9 +2378,12 @@ - (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag
{
// Update the amount of data we have in asyncSocket's write queue.
// This will allow asynchronous responses to continue sending more data.
- if ([responseDataSizes count] > 0) {
- [responseDataSizes removeObjectAtIndex:0];
+ @synchronized(responseDataSizes) {
+ if ([responseDataSizes count] > 0) {
+ [responseDataSizes removeObjectAtIndex:0];
+ }
}
+
// Don't continue sending the response yet.
// The chunked footer that was sent after the body will tell us if we have more data to send.
}
@@ -2388,28 +2395,33 @@ - (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag
else if (tag == HTTP_PARTIAL_RANGE_RESPONSE_BODY)
{
// Update the amount of data we have in asyncSocket's write queue
+ @synchronized(responseDataSizes) {
if ([responseDataSizes count] > 0) {
[responseDataSizes removeObjectAtIndex:0];
}
+ } // @synchronized(responseDateSizes)
// We only wrote a part of the range - there may be more
[self continueSendingSingleRangeResponseBody];
}
else if (tag == HTTP_PARTIAL_RANGES_RESPONSE_BODY)
{
// Update the amount of data we have in asyncSocket's write queue
+ @synchronized(responseDataSizes) {
if ([responseDataSizes count] > 0) {
[responseDataSizes removeObjectAtIndex:0];
}
+ } // @synchronized(responseDateSizes)
// We only wrote part of the range - there may be more, or there may be more ranges
[self continueSendingMultiRangeResponseBody];
}
else if (tag == HTTP_RESPONSE || tag == HTTP_FINAL_RESPONSE)
{
// Update the amount of data we have in asyncSocket's write queue
- if ([responseDataSizes count] > 0)
- {
- [responseDataSizes removeObjectAtIndex:0];
- }
+ @synchronized(responseDataSizes) {
+ if ([responseDataSizes count] > 0) {
+ [responseDataSizes removeObjectAtIndex:0];
+ }
+ }
doneSendingResponse = YES;
}
View
36 Core/HTTPServer.m
@@ -40,7 +40,7 @@ - (id)init
// Setup underlying dispatch queues
serverQueue = dispatch_queue_create("HTTPServer", NULL);
- connectionQueue = dispatch_queue_create("HTTPConnection", NULL);
+ connectionQueue = dispatch_queue_create("HTTPConnection", DISPATCH_QUEUE_CONCURRENT);
IsOnServerQueueKey = &IsOnServerQueueKey;
IsOnConnectionQueueKey = &IsOnConnectionQueueKey;
@@ -81,18 +81,6 @@ - (id)init
connectionsLock = [[NSLock alloc] init];
webSocketsLock = [[NSLock alloc] init];
- // Register for notifications of closed connections
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(connectionDidDie:)
- name:HTTPConnectionDidDieNotification
- object:nil];
-
- // Register for notifications of closed websocket connections
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(webSocketDidDie:)
- name:WebSocketDidDieNotification
- object:nil];
-
isRunning = NO;
}
return self;
@@ -417,6 +405,16 @@ - (BOOL)start:(NSError **)errPtr
isRunning = YES;
[self publishBonjour];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(connectionDidDie:)
+ name:HTTPConnectionDidDieNotification
+ object:nil];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(webSocketDidDie:)
+ name:WebSocketDidDieNotification
+ object:nil];
}
else
{
@@ -450,23 +448,27 @@ - (void)stop:(BOOL)keepExistingConnections
if (!keepExistingConnections)
{
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+
// Stop all HTTP connections the server owns
- [connectionsLock lock];
+ //[connectionsLock lock];
for (HTTPConnection *connection in connections)
{
[connection stop];
}
[connections removeAllObjects];
- [connectionsLock unlock];
+ //[connectionsLock unlock];
// Stop all WebSocket connections the server owns
- [webSocketsLock lock];
+ //[webSocketsLock lock];
+
for (WebSocket *webSocket in webSockets)
{
+ webSocket.delegate = nil;
[webSocket stop];
}
[webSockets removeAllObjects];
- [webSocketsLock unlock];
+ //[webSocketsLock unlock];
}
}});
}
View
1  Core/Responses/HTTPAsyncFileResponse.h
@@ -33,6 +33,7 @@
dispatch_source_t readSource;
BOOL readSourceSuspended;
}
+@property (nonatomic, strong) NSDictionary *httpHeaders;
- (id)initWithFilePath:(NSString *)filePath forConnection:(HTTPConnection *)connection;
- (NSString *)filePath;
View
2  Core/Responses/HTTPAsyncFileResponse.m
@@ -34,6 +34,8 @@
@implementation HTTPAsyncFileResponse
+@synthesize httpHeaders;
+
- (id)initWithFilePath:(NSString *)fpath forConnection:(HTTPConnection *)parent
{
if ((self = [super init]))
View
2  Core/WebSocket.m
@@ -258,7 +258,7 @@ - (void)stop
// This method is not exactly designed to be overriden.
// Subclasses are encouraged to override the didClose method instead.
- dispatch_async(websocketQueue, ^{ @autoreleasepool {
+ dispatch_sync(websocketQueue, ^{ @autoreleasepool {
[asyncSocket disconnect];
}});
View
2  Vendor/CocoaAsyncSocket/GCDAsyncSocket.m
@@ -554,7 +554,7 @@ - (id)initWithData:(NSMutableData *)d
if (d)
{
- buffer = d;
+ buffer = [d mutableCopy];
startOffset = s;
bufferOwner = NO;
originalBufferLength = [d length];
View
2  Vendor/CocoaLumberjack/DDTTYLogger.m
@@ -685,7 +685,7 @@ + (void)getRed:(CGFloat *)rPtr green:(CGFloat *)gPtr blue:(CGFloat *)bPtr fromCo
CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB();
unsigned char pixel[4];
- CGContextRef context = CGBitmapContextCreate(&pixel, 1, 1, 8, 4, rgbColorSpace, kCGImageAlphaNoneSkipLast);
+ CGContextRef context = CGBitmapContextCreate(&pixel, 1, 1, 8, 4, rgbColorSpace, (CGBitmapInfo)kCGImageAlphaNoneSkipLast);
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, CGRectMake(0, 0, 1, 1));

No commit comments for this range

Something went wrong with that request. Please try again.