9 Commits
1.2 ... 1.2.1

Author SHA1 Message Date
Pierre-Olivier Latour
628cf6833c Make sure @bonjourName is not an empty string 2014-01-23 14:26:31 -08:00
Pierre-Olivier Latour
9392ddadb6 Added bonjourName property 2014-01-23 14:17:44 -08:00
Pierre-Olivier Latour
5dee044caa Check for main thread only during first +initialize call 2014-01-23 11:44:43 -08:00
Pierre-Olivier Latour
7c8205caa0 Don't use dispatch_release() under ARC in OS X 10.8 or iOS 6.0 and later 2014-01-23 11:33:33 -08:00
Pierre-Olivier Latour
965e111280 Don't use deprecated dispatch_get_current_queue() 2014-01-23 11:20:43 -08:00
Pierre-Olivier Latour
8a69050cca Merge pull request #14 from chrisdevereux/master
Log to stderr, not stdout
2014-01-13 10:03:33 -08:00
Chris Devereux
a15a49240a Log to stderr, not stdout 2014-01-13 12:58:54 +00:00
Pierre-Olivier Latour
404b46537e Merge pull request #13 from djmadcat/master
Add podspec for version 1.2
2014-01-12 17:06:46 -08:00
Alexey Aleshkov
811e18e2fa Add podspec for version 1.2 2014-01-13 01:44:54 +04:00
5 changed files with 39 additions and 7 deletions

View File

@@ -41,6 +41,7 @@ typedef GCDWebServerResponse* (^GCDWebServerProcessBlock)(GCDWebServerRequest* r
}
@property(nonatomic, readonly, getter=isRunning) BOOL running;
@property(nonatomic, readonly) NSUInteger port;
@property(nonatomic, readonly) NSString* bonjourName; // Only non-nil if Bonjour registration is active
- (void)addHandlerWithMatchBlock:(GCDWebServerMatchBlock)matchBlock processBlock:(GCDWebServerProcessBlock)processBlock;
- (void)removeAllHandlers;

View File

@@ -145,6 +145,11 @@ static void _SignalHandler(int signal) {
ARC_DEALLOC(super);
}
- (NSString*)bonjourName {
CFStringRef name = _service ? CFNetServiceGetName(_service) : NULL;
return name && CFStringGetLength(name) ? ARC_BRIDGE_RELEASE(CFStringCreateCopy(kCFAllocatorDefault, name)) : nil;
}
- (void)addHandlerWithMatchBlock:(GCDWebServerMatchBlock)matchBlock processBlock:(GCDWebServerProcessBlock)handlerBlock {
DCHECK(_source == NULL);
GCDWebServerHandler* handler = [[GCDWebServerHandler alloc] initWithMatchBlock:matchBlock processBlock:handlerBlock];
@@ -166,7 +171,7 @@ static void _NetServiceClientCallBack(CFNetServiceRef service, CFStreamError* er
if (error->error) {
LOG_ERROR(@"Bonjour error %i (domain %i)", error->error, (int)error->domain);
} else {
LOG_VERBOSE(@"Registered Bonjour service \"%@\" with type '%@' on port %i", CFNetServiceGetName(service), CFNetServiceGetType(service), CFNetServiceGetPortNumber(service));
LOG_VERBOSE(@"Registered Bonjour service \"%@\" in domain \"%@\" with type '%@' on port %i", CFNetServiceGetName(service), CFNetServiceGetDomain(service), CFNetServiceGetType(service), CFNetServiceGetPortNumber(service));
}
}
}
@@ -282,7 +287,7 @@ static void _NetServiceClientCallBack(CFNetServiceRef service, CFStreamError* er
}
dispatch_source_cancel(_source); // This will close the socket
dispatch_release(_source);
ARC_DISPATCH_RELEASE(_source);
_source = NULL;
LOG_VERBOSE(@"%@ stopped", [self class]);

View File

@@ -193,7 +193,7 @@ static dispatch_queue_t _formatterQueue = NULL;
#if !__has_feature(objc_arc)
[data retain];
#endif
dispatch_data_t buffer = dispatch_data_create(data.bytes, data.length, dispatch_get_current_queue(), ^{
dispatch_data_t buffer = dispatch_data_create(data.bytes, data.length, dispatch_get_main_queue(), ^{
#if __has_feature(objc_arc)
[data self]; // Keeps ARC from releasing data too early
#else
@@ -201,7 +201,7 @@ static dispatch_queue_t _formatterQueue = NULL;
#endif
});
[self _writeBuffer:buffer withCompletionBlock:block];
dispatch_release(buffer);
ARC_DISPATCH_RELEASE(buffer);
}
- (void)_writeHeadersWithCompletionBlock:(WriteHeadersCompletionBlock)block {
@@ -226,7 +226,7 @@ static dispatch_queue_t _formatterQueue = NULL;
}
}];
dispatch_release(wrapper);
ARC_DISPATCH_RELEASE(wrapper);
} else if (result < 0) {
LOG_ERROR(@"Failed reading response body on socket %i (error %i)", _socket, (int)result);
block(NO);
@@ -244,7 +244,6 @@ static dispatch_queue_t _formatterQueue = NULL;
@synthesize server=_server, address=_address, totalBytesRead=_bytesRead, totalBytesWritten=_bytesWritten;
+ (void)initialize {
DCHECK([NSThread isMainThread]); // NSDateFormatter should be initialized on main thread
if (_separatorData == nil) {
_separatorData = [[NSData alloc] initWithBytes:"\r\n\r\n" length:4];
DCHECK(_separatorData);
@@ -260,6 +259,7 @@ static dispatch_queue_t _formatterQueue = NULL;
DCHECK(_continueData);
}
if (_dateFormatter == nil) {
DCHECK([NSThread isMainThread]); // NSDateFormatter should be initialized on main thread
_dateFormatter = [[NSDateFormatter alloc] init];
_dateFormatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
_dateFormatter.dateFormat = @"EEE',' dd MMM yyyy HH':'mm':'ss 'GMT'";

View File

@@ -25,6 +25,8 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <TargetConditionals.h>
#if __has_feature(objc_arc)
#define ARC_BRIDGE __bridge
#define ARC_BRIDGE_RELEASE(__OBJECT__) CFBridgingRelease(__OBJECT__)
@@ -32,6 +34,11 @@
#define ARC_RELEASE(__OBJECT__)
#define ARC_AUTORELEASE(__OBJECT__) __OBJECT__
#define ARC_DEALLOC(__OBJECT__)
#if (TARGET_OS_IPHONE && (__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0)) || (!TARGET_OS_IPHONE && (__MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_8))
#define ARC_DISPATCH_RELEASE(__OBJECT__)
#else
#define ARC_DISPATCH_RELEASE(__OBJECT__) dispatch_release(__OBJECT__)
#endif
#else
#define ARC_BRIDGE
#define ARC_BRIDGE_RELEASE(__OBJECT__) [(id)__OBJECT__ autorelease]
@@ -39,6 +46,7 @@
#define ARC_RELEASE(__OBJECT__) [__OBJECT__ release]
#define ARC_AUTORELEASE(__OBJECT__) [__OBJECT__ autorelease]
#define ARC_DEALLOC(__OBJECT__) [__OBJECT__ dealloc]
#define ARC_DISPATCH_RELEASE(__OBJECT__) dispatch_release(__OBJECT__)
#endif
#import "GCDWebServerConnection.h"
@@ -62,7 +70,7 @@ static inline void __LogMessage(long level, NSString* format, ...) {
va_start(arguments, format);
NSString* message = [[NSString alloc] initWithFormat:format arguments:arguments];
va_end(arguments);
printf("[%s] %s\n", levelNames[level], [message UTF8String]);
fprintf(stderr, "[%s] %s\n", levelNames[level], [message UTF8String]);
ARC_RELEASE(message);
}
}

18
GCDWebServer.podspec Normal file
View File

@@ -0,0 +1,18 @@
Pod::Spec.new do |s|
s.name = 'GCDWebServer'
s.version = '1.2'
s.author = { 'Pierre-Olivier Latour' => 'info@pol-online.net' }
s.license = { :type => 'BSD', :file => 'LICENSE' }
s.homepage = 'https://github.com/swisspol/GCDWebServer'
s.summary = 'Lightweight GCD based HTTP server for Mac OS X & iOS apps'
s.source = { :git => 'https://github.com/swisspol/GCDWebServer.git', :tag => s.version.to_s }
s.requires_arc = true
s.source_files = 'CGDWebServer/*.{h,m}'
s.ios.deployment_target = '5.0'
s.osx.deployment_target = '10.7'
s.ios.framework = 'MobileCoreServices'
end