23 Commits
3.3.1 ... 3.3.3

Author SHA1 Message Date
Pierre-Olivier Latour
43555c6662 Merge pull request #272 from bizz84/master
Removed cs.default_subspec from subspecs as this is now disallowed
2016-07-15 11:46:05 -07:00
Andrea Bizzotto
7c08c54156 Removed cs.default_subspec from subspecs as this is now disallowed in Cocoapods 2016-07-15 19:23:27 +01:00
Pierre-Olivier Latour
5834770e08 Removed exception handling which was only partial anyway 2016-06-29 21:38:57 -07:00
Pierre-Olivier Latour
52406a12c2 Merge pull request #267 from hsin919/master
Fix the typo in swift samples
2016-06-29 09:15:10 -07:00
Pierre-Olivier Latour
e83814b0fa Merge pull request #269 from opsGavin/patch-1
Typo in GCDWebServerGZipDecoder:open
2016-06-29 09:11:43 -07:00
Gavin MacLean
fba593a602 Typo in GCDWebServerGZipDecoder:open
I haven't tested or dug into this, as I just happened to spot it while looking through a colleagues code.

It looks like `inflateInit2` is called and then `deflateEnd` on error. I'm wondering if this is a copy and paste issue from `GCDWebServerGZipEncoder` and really it should be `inflateEnd` here instead?
2016-06-29 15:36:40 +01:00
hsin
eec17d5c7b Fix the typo in swift samples 2016-06-08 09:25:04 +08:00
Pierre-Olivier Latour
32bc72113a Merge pull request #266 from DD-P/read-me-typo-fix
Minor documentation fix: "owns" -> "own"
2016-05-08 08:00:48 -07:00
David Davies-Payne
200d21c3fa Minor documentation fix: "owns" -> "own" 2016-05-08 19:32:34 +12:00
Pierre-Olivier Latour
3042b853bc Fix 2016-04-17 20:07:54 -07:00
Pierre-Olivier Latour
50eb0437c1 Updated for Xcode 7.3 2016-04-17 20:07:49 -07:00
Pierre-Olivier Latour
00cc560b8e Merge pull request #264 from AmpMe/refacor/add-queue-priorty-as-an-option
Add an option to set the priority of the dispatch queue
2016-04-03 17:53:13 -07:00
Martin Gagnon
fa41f26b30 Add an option to set the priority of the dispatch queue 2016-04-03 20:11:35 -04:00
Pierre-Olivier Latour
845969ec0d Merge pull request #262 from pra85/patch-1
Fix a typo in Readme
2016-03-24 06:36:57 -07:00
Prayag Verma
629df7895d Fix a typo in Readme
`asynchronously` → `asynchronously`
2016-02-18 13:32:09 +05:30
Pierre-Olivier Latour
55104e5b1e Update README.md 2016-02-08 01:00:25 -08:00
Pierre-Olivier Latour
fcc95fdc11 Merge pull request #260 from jjrscott/master
Added __kindof keyword where appropriate
2016-02-07 17:18:39 -08:00
John Scott
10a94e36fd Removed guards around __kindof usage as the project is Xcode 7 only. 2016-02-06 12:18:49 +00:00
John Scott
010ef9b8bc Added __kindof keyword where appropriate to avoid errors of the form "incompatible block pointer types sending 'GCDWebServerResponse *(^)(GCDWebServerDataRequest *__strong)' to parameter of type 'GCDWebServerProcessBlock' (aka 'GCDWebServerResponse *(^)(GCDWebServerRequest *__strong)')" 2016-02-05 20:45:46 +00:00
Pierre-Olivier Latour
5ca7c27a07 Bumped version 2016-01-20 07:24:59 -08:00
Pierre-Olivier Latour
c6632633f8 Disabled address sanitizer 2016-01-20 07:21:37 -08:00
Pierre-Olivier Latour
5b6eebbb9e Fixed build warning 2016-01-20 07:21:18 -08:00
Pierre-Olivier Latour
a4c61bd071 Bumped version 2016-01-16 06:29:35 -08:00
13 changed files with 45 additions and 74 deletions

View File

@@ -2,12 +2,12 @@
# http://guides.cocoapods.org/making/getting-setup-with-trunk.html # http://guides.cocoapods.org/making/getting-setup-with-trunk.html
# $ sudo gem update cocoapods # $ sudo gem update cocoapods
# (optional) $ pod trunk register {email} {name} --description={computer} # (optional) $ pod trunk register {email} {name} --description={computer}
# $ pod trunk push # $ pod trunk --verbose push
# DELETE THIS SECTION BEFORE PROCEEDING! # DELETE THIS SECTION BEFORE PROCEEDING!
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'GCDWebServer' s.name = 'GCDWebServer'
s.version = '3.3.1' s.version = '3.3.3'
s.author = { 'Pierre-Olivier Latour' => 'info@pol-online.net' } s.author = { 'Pierre-Olivier Latour' => 'info@pol-online.net' }
s.license = { :type => 'BSD', :file => 'LICENSE' } s.license = { :type => 'BSD', :file => 'LICENSE' }
s.homepage = 'https://github.com/swisspol/GCDWebServer' s.homepage = 'https://github.com/swisspol/GCDWebServer'
@@ -39,8 +39,6 @@ Pod::Spec.new do |s|
end end
s.subspec 'WebDAV' do |cs| s.subspec 'WebDAV' do |cs|
cs.default_subspec = 'Core'
cs.subspec "Core" do |ccs| cs.subspec "Core" do |ccs|
ccs.dependency 'GCDWebServer/Core' ccs.dependency 'GCDWebServer/Core'
ccs.source_files = 'GCDWebDAVServer/*.{h,m}' ccs.source_files = 'GCDWebDAVServer/*.{h,m}'
@@ -58,8 +56,6 @@ Pod::Spec.new do |s|
end end
s.subspec 'WebUploader' do |cs| s.subspec 'WebUploader' do |cs|
cs.default_subspec = 'Core'
cs.subspec "Core" do |ccs| cs.subspec "Core" do |ccs|
ccs.dependency 'GCDWebServer/Core' ccs.dependency 'GCDWebServer/Core'
ccs.source_files = 'GCDWebUploader/*.{h,m}' ccs.source_files = 'GCDWebUploader/*.{h,m}'

View File

@@ -854,7 +854,7 @@
08FB7793FE84155DC02AAC07 /* Project object */ = { 08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 0720; LastUpgradeCheck = 0730;
TargetAttributes = { TargetAttributes = {
CEE28CD01AE004D800F4023C = { CEE28CD01AE004D800F4023C = {
CreatedOnToolsVersion = 6.3; CreatedOnToolsVersion = 6.3;
@@ -1208,7 +1208,7 @@
1DEB928A08733DD80010E9CD /* Debug */ = { 1DEB928A08733DD80010E9CD /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
BUNDLE_VERSION_STRING = 3.3.1; BUNDLE_VERSION_STRING = 3.3.3;
CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_ARC = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_OPTIMIZATION_LEVEL = 0; GCC_OPTIMIZATION_LEVEL = 0;
@@ -1238,6 +1238,7 @@
"-Wno-reserved-id-macro", "-Wno-reserved-id-macro",
"-Wno-cast-qual", "-Wno-cast-qual",
"-Wno-nullable-to-nonnull-conversion", "-Wno-nullable-to-nonnull-conversion",
"-Wno-partial-availability",
); );
}; };
name = Debug; name = Debug;
@@ -1245,7 +1246,7 @@
1DEB928B08733DD80010E9CD /* Release */ = { 1DEB928B08733DD80010E9CD /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
BUNDLE_VERSION_STRING = 3.3.1; BUNDLE_VERSION_STRING = 3.3.3;
CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_ARC = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = __GCDWEBSERVER_ENABLE_TESTING__; GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = __GCDWEBSERVER_ENABLE_TESTING__;

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "0720" LastUpgradeVersion = "0730"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"
@@ -50,7 +50,6 @@
useCustomWorkingDirectory = "NO" useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO" ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES" debugDocumentVersioning = "YES"
enableAddressSanitizer = "YES"
debugServiceExtension = "internal" debugServiceExtension = "internal"
allowLocationSimulation = "YES"> allowLocationSimulation = "YES">
<MacroExpansion> <MacroExpansion>
@@ -63,11 +62,6 @@
</BuildableReference> </BuildableReference>
</MacroExpansion> </MacroExpansion>
<AdditionalOptions> <AdditionalOptions>
<AdditionalOption
key = "NSZombieEnabled"
value = "YES"
isEnabled = "YES">
</AdditionalOption>
</AdditionalOptions> </AdditionalOptions>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "0720" LastUpgradeVersion = "0730"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"
@@ -49,7 +49,6 @@
useCustomWorkingDirectory = "NO" useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO" ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES" debugDocumentVersioning = "YES"
enableAddressSanitizer = "YES"
debugServiceExtension = "internal" debugServiceExtension = "internal"
allowLocationSimulation = "YES"> allowLocationSimulation = "YES">
<MacroExpansion> <MacroExpansion>
@@ -62,11 +61,6 @@
</BuildableReference> </BuildableReference>
</MacroExpansion> </MacroExpansion>
<AdditionalOptions> <AdditionalOptions>
<AdditionalOption
key = "NSZombieEnabled"
value = "YES"
isEnabled = "YES">
</AdditionalOption>
</AdditionalOptions> </AdditionalOptions>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "0720" LastUpgradeVersion = "0730"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"
@@ -49,7 +49,6 @@
useCustomWorkingDirectory = "NO" useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO" ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES" debugDocumentVersioning = "YES"
enableAddressSanitizer = "YES"
debugServiceExtension = "internal" debugServiceExtension = "internal"
allowLocationSimulation = "YES"> allowLocationSimulation = "YES">
<MacroExpansion> <MacroExpansion>
@@ -62,11 +61,6 @@
</BuildableReference> </BuildableReference>
</MacroExpansion> </MacroExpansion>
<AdditionalOptions> <AdditionalOptions>
<AdditionalOption
key = "NSZombieEnabled"
value = "YES"
isEnabled = "YES">
</AdditionalOption>
</AdditionalOptions> </AdditionalOptions>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction

View File

@@ -52,7 +52,7 @@ typedef GCDWebServerRequest* (^GCDWebServerMatchBlock)(NSString* requestMethod,
* recommended to return a GCDWebServerErrorResponse on error so more useful * recommended to return a GCDWebServerErrorResponse on error so more useful
* information can be returned to the client. * information can be returned to the client.
*/ */
typedef GCDWebServerResponse* (^GCDWebServerProcessBlock)(GCDWebServerRequest* request); typedef GCDWebServerResponse* (^GCDWebServerProcessBlock)(__kindof GCDWebServerRequest* request);
/** /**
* The GCDWebServerAsynchronousProcessBlock works like the GCDWebServerProcessBlock * The GCDWebServerAsynchronousProcessBlock works like the GCDWebServerProcessBlock
@@ -65,7 +65,7 @@ typedef GCDWebServerResponse* (^GCDWebServerProcessBlock)(GCDWebServerRequest* r
* useful information can be returned to the client. * useful information can be returned to the client.
*/ */
typedef void (^GCDWebServerCompletionBlock)(GCDWebServerResponse* response); typedef void (^GCDWebServerCompletionBlock)(GCDWebServerResponse* response);
typedef void (^GCDWebServerAsyncProcessBlock)(GCDWebServerRequest* request, GCDWebServerCompletionBlock completionBlock); typedef void (^GCDWebServerAsyncProcessBlock)(__kindof GCDWebServerRequest* request, GCDWebServerCompletionBlock completionBlock);
/** /**
* The port used by the GCDWebServer (NSNumber / NSUInteger). * The port used by the GCDWebServer (NSNumber / NSUInteger).
@@ -176,6 +176,15 @@ extern NSString* const GCDWebServerOption_AutomaticallyMapHEADToGET;
*/ */
extern NSString* const GCDWebServerOption_ConnectedStateCoalescingInterval; extern NSString* const GCDWebServerOption_ConnectedStateCoalescingInterval;
/**
* Set the dispatch queue priority on which server connection will be
* run (NSNumber / long).
*
*
* The default value is DISPATCH_QUEUE_PRIORITY_DEFAULT.
*/
extern NSString* const GCDWebServerOption_DispatchQueuePriority;
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE
/** /**
@@ -537,12 +546,10 @@ extern NSString* const GCDWebServerAuthenticationMethod_DigestAccess;
* GWS_LOG_INFO(...) * GWS_LOG_INFO(...)
* GWS_LOG_WARNING(...) * GWS_LOG_WARNING(...)
* GWS_LOG_ERROR(...) * GWS_LOG_ERROR(...)
* GWS_LOG_EXCEPTION(__EXCEPTION__)
* *
* IMPORTANT: Except for GWS_LOG_EXCEPTION() which gets passed an NSException, * IMPORTANT: These macros must behave like NSLog(). Furthermore the GWS_LOG_DEBUG()
* these macros must behave like NSLog(). Furthermore the GWS_LOG_DEBUG() macro * macro should not do anything unless the preprocessor constant "DEBUG" evaluates
* should not do anything unless the preprocessor constant "DEBUG" evaluates to * to non-zero.
* non-zero.
* *
* The logging methods below send log messages to the same logging facility * The logging methods below send log messages to the same logging facility
* used by GCDWebServer. They can be used for consistency wherever you interact * used by GCDWebServer. They can be used for consistency wherever you interact
@@ -562,7 +569,6 @@ extern NSString* const GCDWebServerAuthenticationMethod_DigestAccess;
* INFO = 2 * INFO = 2
* WARNING = 3 * WARNING = 3
* ERROR = 4 * ERROR = 4
* EXCEPTION = 5
*/ */
+ (void)setLogLevel:(int)level; + (void)setLogLevel:(int)level;
@@ -586,11 +592,6 @@ extern NSString* const GCDWebServerAuthenticationMethod_DigestAccess;
*/ */
- (void)logError:(NSString*)format, ... NS_FORMAT_FUNCTION(1,2); - (void)logError:(NSString*)format, ... NS_FORMAT_FUNCTION(1,2);
/**
* Logs an exception to the logging facility at the EXCEPTION level.
*/
- (void)logException:(NSException*)exception;
@end @end
#ifdef __GCDWEBSERVER_ENABLE_TESTING__ #ifdef __GCDWEBSERVER_ENABLE_TESTING__

View File

@@ -63,6 +63,7 @@ NSString* const GCDWebServerOption_AuthenticationAccounts = @"AuthenticationAcco
NSString* const GCDWebServerOption_ConnectionClass = @"ConnectionClass"; NSString* const GCDWebServerOption_ConnectionClass = @"ConnectionClass";
NSString* const GCDWebServerOption_AutomaticallyMapHEADToGET = @"AutomaticallyMapHEADToGET"; NSString* const GCDWebServerOption_AutomaticallyMapHEADToGET = @"AutomaticallyMapHEADToGET";
NSString* const GCDWebServerOption_ConnectedStateCoalescingInterval = @"ConnectedStateCoalescingInterval"; NSString* const GCDWebServerOption_ConnectedStateCoalescingInterval = @"ConnectedStateCoalescingInterval";
NSString* const GCDWebServerOption_DispatchQueuePriority = @"DispatchQueuePriority";
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE
NSString* const GCDWebServerOption_AutomaticallySuspendInBackground = @"AutomaticallySuspendInBackground"; NSString* const GCDWebServerOption_AutomaticallySuspendInBackground = @"AutomaticallySuspendInBackground";
#endif #endif
@@ -91,7 +92,7 @@ static BOOL _run;
#ifdef __GCDWEBSERVER_LOGGING_FACILITY_BUILTIN__ #ifdef __GCDWEBSERVER_LOGGING_FACILITY_BUILTIN__
void GCDWebServerLogMessage(GCDWebServerLoggingLevel level, NSString* format, ...) { void GCDWebServerLogMessage(GCDWebServerLoggingLevel level, NSString* format, ...) {
static const char* levelNames[] = {"DEBUG", "VERBOSE", "INFO", "WARNING", "ERROR", "EXCEPTION"}; static const char* levelNames[] = {"DEBUG", "VERBOSE", "INFO", "WARNING", "ERROR"};
static int enableLogging = -1; static int enableLogging = -1;
if (enableLogging < 0) { if (enableLogging < 0) {
enableLogging = (isatty(STDERR_FILENO) ? 1 : 0); enableLogging = (isatty(STDERR_FILENO) ? 1 : 0);
@@ -170,6 +171,7 @@ static void _ExecuteMainThreadRunLoopSources() {
Class _connectionClass; Class _connectionClass;
BOOL _mapHEADToGET; BOOL _mapHEADToGET;
CFTimeInterval _disconnectDelay; CFTimeInterval _disconnectDelay;
dispatch_queue_priority_t _dispatchQueuePriority;
NSUInteger _port; NSUInteger _port;
dispatch_source_t _source4; dispatch_source_t _source4;
dispatch_source_t _source6; dispatch_source_t _source6;
@@ -195,7 +197,7 @@ static void _ExecuteMainThreadRunLoopSources() {
@synthesize delegate=_delegate, handlers=_handlers, port=_port, serverName=_serverName, authenticationRealm=_authenticationRealm, @synthesize delegate=_delegate, handlers=_handlers, port=_port, serverName=_serverName, authenticationRealm=_authenticationRealm,
authenticationBasicAccounts=_authenticationBasicAccounts, authenticationDigestAccounts=_authenticationDigestAccounts, authenticationBasicAccounts=_authenticationBasicAccounts, authenticationDigestAccounts=_authenticationDigestAccounts,
shouldAutomaticallyMapHEADToGET=_mapHEADToGET; shouldAutomaticallyMapHEADToGET=_mapHEADToGET, dispatchQueuePriority=_dispatchQueuePriority;
+ (void)initialize { + (void)initialize {
GCDWebServerInitializeFunctions(); GCDWebServerInitializeFunctions();
@@ -493,7 +495,7 @@ static inline NSString* _EncodeBase64(NSString* string) {
- (dispatch_source_t)_createDispatchSourceWithListeningSocket:(int)listeningSocket isIPv6:(BOOL)isIPv6 { - (dispatch_source_t)_createDispatchSourceWithListeningSocket:(int)listeningSocket isIPv6:(BOOL)isIPv6 {
dispatch_group_enter(_sourceGroup); dispatch_group_enter(_sourceGroup);
dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, listeningSocket, 0, kGCDWebServerGCDQueue); dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, listeningSocket, 0, dispatch_get_global_queue(_dispatchQueuePriority, 0));
dispatch_source_set_cancel_handler(source, ^{ dispatch_source_set_cancel_handler(source, ^{
@autoreleasepool { @autoreleasepool {
@@ -599,6 +601,7 @@ static inline NSString* _EncodeBase64(NSString* string) {
_connectionClass = _GetOption(_options, GCDWebServerOption_ConnectionClass, [GCDWebServerConnection class]); _connectionClass = _GetOption(_options, GCDWebServerOption_ConnectionClass, [GCDWebServerConnection class]);
_mapHEADToGET = [_GetOption(_options, GCDWebServerOption_AutomaticallyMapHEADToGET, @YES) boolValue]; _mapHEADToGET = [_GetOption(_options, GCDWebServerOption_AutomaticallyMapHEADToGET, @YES) boolValue];
_disconnectDelay = [_GetOption(_options, GCDWebServerOption_ConnectedStateCoalescingInterval, @1.0) doubleValue]; _disconnectDelay = [_GetOption(_options, GCDWebServerOption_ConnectedStateCoalescingInterval, @1.0) doubleValue];
_dispatchQueuePriority = [_GetOption(_options, GCDWebServerOption_DispatchQueuePriority, @(DISPATCH_QUEUE_PRIORITY_DEFAULT)) longValue];
_source4 = [self _createDispatchSourceWithListeningSocket:listeningSocket4 isIPv6:NO]; _source4 = [self _createDispatchSourceWithListeningSocket:listeningSocket4 isIPv6:NO];
_source6 = [self _createDispatchSourceWithListeningSocket:listeningSocket6 isIPv6:YES]; _source6 = [self _createDispatchSourceWithListeningSocket:listeningSocket6 isIPv6:YES];
@@ -1128,10 +1131,6 @@ static inline NSString* _EncodeBase64(NSString* string) {
va_end(arguments); va_end(arguments);
} }
- (void)logException:(NSException*)exception {
GWS_LOG_EXCEPTION(exception);
}
@end @end
#ifdef __GCDWEBSERVER_ENABLE_TESTING__ #ifdef __GCDWEBSERVER_ENABLE_TESTING__

View File

@@ -88,7 +88,7 @@ static int32_t _connectionCounter = 0;
@implementation GCDWebServerConnection (Read) @implementation GCDWebServerConnection (Read)
- (void)_readData:(NSMutableData*)data withLength:(NSUInteger)length completionBlock:(ReadDataCompletionBlock)block { - (void)_readData:(NSMutableData*)data withLength:(NSUInteger)length completionBlock:(ReadDataCompletionBlock)block {
dispatch_read(_socket, length, kGCDWebServerGCDQueue, ^(dispatch_data_t buffer, int error) { dispatch_read(_socket, length, dispatch_get_global_queue(_server.dispatchQueuePriority, 0), ^(dispatch_data_t buffer, int error) {
@autoreleasepool { @autoreleasepool {
if (error == 0) { if (error == 0) {
@@ -247,10 +247,10 @@ static inline NSUInteger _ScanHexNumber(const void* bytes, NSUInteger size) {
@implementation GCDWebServerConnection (Write) @implementation GCDWebServerConnection (Write)
- (void)_writeData:(NSData*)data withCompletionBlock:(WriteDataCompletionBlock)block { - (void)_writeData:(NSData*)data withCompletionBlock:(WriteDataCompletionBlock)block {
dispatch_data_t buffer = dispatch_data_create(data.bytes, data.length, kGCDWebServerGCDQueue, ^{ dispatch_data_t buffer = dispatch_data_create(data.bytes, data.length, dispatch_get_global_queue(_server.dispatchQueuePriority, 0), ^{
[data self]; // Keeps ARC from releasing data too early [data self]; // Keeps ARC from releasing data too early
}); });
dispatch_write(_socket, buffer, kGCDWebServerGCDQueue, ^(dispatch_data_t remainingData, int error) { dispatch_write(_socket, buffer, dispatch_get_global_queue(_server.dispatchQueuePriority, 0), ^(dispatch_data_t remainingData, int error) {
@autoreleasepool { @autoreleasepool {
if (error == 0) { if (error == 0) {
@@ -758,12 +758,7 @@ static inline NSUInteger _ScanHexNumber(const void* bytes, NSUInteger size) {
- (void)processRequest:(GCDWebServerRequest*)request completion:(GCDWebServerCompletionBlock)completion { - (void)processRequest:(GCDWebServerRequest*)request completion:(GCDWebServerCompletionBlock)completion {
GWS_LOG_DEBUG(@"Connection on socket %i processing request \"%@ %@\" with %lu bytes body", _socket, _virtualHEAD ? @"HEAD" : _request.method, _request.path, (unsigned long)_bytesRead); GWS_LOG_DEBUG(@"Connection on socket %i processing request \"%@ %@\" with %lu bytes body", _socket, _virtualHEAD ? @"HEAD" : _request.method, _request.path, (unsigned long)_bytesRead);
@try { _handler.asyncProcessBlock(request, [completion copy]);
_handler.asyncProcessBlock(request, [completion copy]);
}
@catch (NSException* exception) {
GWS_LOG_EXCEPTION(exception);
}
} }
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.25 // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.25

View File

@@ -246,7 +246,7 @@ NSString* GCDWebServerStringFromSockAddr(const struct sockaddr* addr, BOOL inclu
NSString* GCDWebServerGetPrimaryIPAddress(BOOL useIPv6) { NSString* GCDWebServerGetPrimaryIPAddress(BOOL useIPv6) {
NSString* address = nil; NSString* address = nil;
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE
#if !TARGET_IPHONE_SIMULATOR #if !TARGET_IPHONE_SIMULATOR && !TARGET_OS_TV
const char* primaryInterface = "en0"; // WiFi interface on iOS const char* primaryInterface = "en0"; // WiFi interface on iOS
#endif #endif
#else #else

View File

@@ -77,7 +77,6 @@
#define GWS_LOG_INFO(...) XLOG_INFO(__VA_ARGS__) #define GWS_LOG_INFO(...) XLOG_INFO(__VA_ARGS__)
#define GWS_LOG_WARNING(...) XLOG_WARNING(__VA_ARGS__) #define GWS_LOG_WARNING(...) XLOG_WARNING(__VA_ARGS__)
#define GWS_LOG_ERROR(...) XLOG_ERROR(__VA_ARGS__) #define GWS_LOG_ERROR(...) XLOG_ERROR(__VA_ARGS__)
#define GWS_LOG_EXCEPTION(__EXCEPTION__) XLOG_EXCEPTION(__EXCEPTION__)
#define GWS_DCHECK(__CONDITION__) XLOG_DEBUG_CHECK(__CONDITION__) #define GWS_DCHECK(__CONDITION__) XLOG_DEBUG_CHECK(__CONDITION__)
#define GWS_DNOT_REACHED() XLOG_DEBUG_UNREACHABLE() #define GWS_DNOT_REACHED() XLOG_DEBUG_UNREACHABLE()
@@ -102,7 +101,6 @@ extern DDLogLevel GCDWebServerLogLevel;
#define GWS_LOG_INFO(...) DDLogInfo(__VA_ARGS__) #define GWS_LOG_INFO(...) DDLogInfo(__VA_ARGS__)
#define GWS_LOG_WARNING(...) DDLogWarn(__VA_ARGS__) #define GWS_LOG_WARNING(...) DDLogWarn(__VA_ARGS__)
#define GWS_LOG_ERROR(...) DDLogError(__VA_ARGS__) #define GWS_LOG_ERROR(...) DDLogError(__VA_ARGS__)
#define GWS_LOG_EXCEPTION(__EXCEPTION__) DDLogError(@"%@", __EXCEPTION__)
/** /**
* If all of the above fail, then use GCDWebServer built-in * If all of the above fail, then use GCDWebServer built-in
@@ -118,8 +116,7 @@ typedef NS_ENUM(int, GCDWebServerLoggingLevel) {
kGCDWebServerLoggingLevel_Verbose, kGCDWebServerLoggingLevel_Verbose,
kGCDWebServerLoggingLevel_Info, kGCDWebServerLoggingLevel_Info,
kGCDWebServerLoggingLevel_Warning, kGCDWebServerLoggingLevel_Warning,
kGCDWebServerLoggingLevel_Error, kGCDWebServerLoggingLevel_Error
kGCDWebServerLoggingLevel_Exception
}; };
extern GCDWebServerLoggingLevel GCDWebServerLogLevel; extern GCDWebServerLoggingLevel GCDWebServerLogLevel;
@@ -134,7 +131,6 @@ extern void GCDWebServerLogMessage(GCDWebServerLoggingLevel level, NSString* for
#define GWS_LOG_INFO(...) do { if (GCDWebServerLogLevel <= kGCDWebServerLoggingLevel_Info) GCDWebServerLogMessage(kGCDWebServerLoggingLevel_Info, __VA_ARGS__); } while (0) #define GWS_LOG_INFO(...) do { if (GCDWebServerLogLevel <= kGCDWebServerLoggingLevel_Info) GCDWebServerLogMessage(kGCDWebServerLoggingLevel_Info, __VA_ARGS__); } while (0)
#define GWS_LOG_WARNING(...) do { if (GCDWebServerLogLevel <= kGCDWebServerLoggingLevel_Warning) GCDWebServerLogMessage(kGCDWebServerLoggingLevel_Warning, __VA_ARGS__); } while (0) #define GWS_LOG_WARNING(...) do { if (GCDWebServerLogLevel <= kGCDWebServerLoggingLevel_Warning) GCDWebServerLogMessage(kGCDWebServerLoggingLevel_Warning, __VA_ARGS__); } while (0)
#define GWS_LOG_ERROR(...) do { if (GCDWebServerLogLevel <= kGCDWebServerLoggingLevel_Error) GCDWebServerLogMessage(kGCDWebServerLoggingLevel_Error, __VA_ARGS__); } while (0) #define GWS_LOG_ERROR(...) do { if (GCDWebServerLogLevel <= kGCDWebServerLoggingLevel_Error) GCDWebServerLogMessage(kGCDWebServerLoggingLevel_Error, __VA_ARGS__); } while (0)
#define GWS_LOG_EXCEPTION(__EXCEPTION__) do { if (GCDWebServerLogLevel <= kGCDWebServerLoggingLevel_Exception) GCDWebServerLogMessage(kGCDWebServerLoggingLevel_Exception, @"%@", __EXCEPTION__); } while (0)
#endif #endif
@@ -168,7 +164,6 @@ extern void GCDWebServerLogMessage(GCDWebServerLoggingLevel level, NSString* for
*/ */
#define kGCDWebServerDefaultMimeType @"application/octet-stream" #define kGCDWebServerDefaultMimeType @"application/octet-stream"
#define kGCDWebServerGCDQueue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
#define kGCDWebServerErrorDomain @"GCDWebServerErrorDomain" #define kGCDWebServerErrorDomain @"GCDWebServerErrorDomain"
static inline BOOL GCDWebServerIsValidByteRange(NSRange range) { static inline BOOL GCDWebServerIsValidByteRange(NSRange range) {
@@ -200,6 +195,7 @@ extern NSString* GCDWebServerStringFromSockAddr(const struct sockaddr* addr, BOO
@property(nonatomic, readonly) NSDictionary* authenticationBasicAccounts; @property(nonatomic, readonly) NSDictionary* authenticationBasicAccounts;
@property(nonatomic, readonly) NSDictionary* authenticationDigestAccounts; @property(nonatomic, readonly) NSDictionary* authenticationDigestAccounts;
@property(nonatomic, readonly) BOOL shouldAutomaticallyMapHEADToGET; @property(nonatomic, readonly) BOOL shouldAutomaticallyMapHEADToGET;
@property(nonatomic, readonly) dispatch_queue_priority_t dispatchQueuePriority;
- (void)willStartConnection:(GCDWebServerConnection*)connection; - (void)willStartConnection:(GCDWebServerConnection*)connection;
- (void)didEndConnection:(GCDWebServerConnection*)connection; - (void)didEndConnection:(GCDWebServerConnection*)connection;
@end @end

View File

@@ -94,7 +94,7 @@ NSString* const GCDWebServerRequestAttribute_RegexCaptures = @"GCDWebServerReque
return NO; return NO;
} }
if (![super open:error]) { if (![super open:error]) {
deflateEnd(&_stream); inflateEnd(&_stream);
return NO; return NO;
} }
return YES; return YES;

View File

@@ -241,6 +241,7 @@
} }
- (void)performReadDataWithCompletion:(GCDWebServerBodyReaderCompletionBlock)block { - (void)performReadDataWithCompletion:(GCDWebServerBodyReaderCompletionBlock)block {
GWS_DCHECK(_opened);
if ([_reader respondsToSelector:@selector(asyncReadDataWithCompletion:)]) { if ([_reader respondsToSelector:@selector(asyncReadDataWithCompletion:)]) {
[_reader asyncReadDataWithCompletion:[block copy]]; [_reader asyncReadDataWithCompletion:[block copy]];
} else { } else {

View File

@@ -71,9 +71,9 @@ Then run `$ carthage update` and add the generated frameworks to your Xcode proj
Help & Support Help & Support
============== ==============
For help with using GCDWebServer, it's best to ask your question on Stack Overflow with the [`gcdwebserver`](http://stackoverflow.com/questions/tagged/gcdwebserver) tag. Be sure to read this entire README first though! For help with using GCDWebServer, it's best to ask your question on Stack Overflow with the [`gcdwebserver`](http://stackoverflow.com/questions/tagged/gcdwebserver) tag.
For bug reports or enhancement requests, please use [GitHub issues](https://github.com/swisspol/GCDWebServer/issues) instead. Be sure to read this entire README first though!
Hello World Hello World
=========== ===========
@@ -153,7 +153,7 @@ int main(int argc, const char* argv[]) {
***webServer.swift*** ***webServer.swift***
```swift ```swift
import Foundation import Foundation
import GCDWebServers import GCDWebServer
func initWebServer() { func initWebServer() {
@@ -172,8 +172,8 @@ func initWebServer() {
***WebServer-Bridging-Header.h*** ***WebServer-Bridging-Header.h***
```objectivec ```objectivec
#import <GCDWebServers/GCDWebServer.h> #import <GCDWebServer/GCDWebServer.h>
#import <GCDWebServers/GCDWebServerDataResponse.h> #import <GCDWebServer/GCDWebServerDataResponse.h>
``` ```
Web Based Uploads in iOS Apps Web Based Uploads in iOS Apps
@@ -276,7 +276,7 @@ GCDWebServer's architecture consists of only 4 core classes:
Implementing Handlers Implementing Handlers
===================== =====================
GCDWebServer relies on "handlers" to process incoming web requests and generating responses. Handlers are implemented with GCD blocks which makes it very easy to provide your owns. However, they are executed on arbitrary threads within GCD so __special attention must be paid to thread-safety and re-entrancy__. GCDWebServer relies on "handlers" to process incoming web requests and generating responses. Handlers are implemented with GCD blocks which makes it very easy to provide your own. However, they are executed on arbitrary threads within GCD so __special attention must be paid to thread-safety and re-entrancy__.
Handlers require 2 GCD blocks: Handlers require 2 GCD blocks:
* The ```GCDWebServerMatchBlock``` is called on every handler added to the ```GCDWebServer``` instance whenever a web request has started (i.e. HTTP headers have been received). It is passed the basic info for the web request (HTTP method, URL, headers...) and must decide if it wants to handle it or not. If yes, it must return a new ```GCDWebServerRequest``` instance (see above) created with this info. Otherwise, it simply returns nil. * The ```GCDWebServerMatchBlock``` is called on every handler added to the ```GCDWebServer``` instance whenever a web request has started (i.e. HTTP headers have been received). It is passed the basic info for the web request (HTTP method, URL, headers...) and must decide if it wants to handle it or not. If yes, it must return a new ```GCDWebServerRequest``` instance (see above) created with this info. Otherwise, it simply returns nil.
@@ -287,7 +287,7 @@ Note that most methods on ```GCDWebServer``` to add handlers only require the ``
Asynchronous HTTP Responses Asynchronous HTTP Responses
=========================== ===========================
New in GCDWebServer 3.0 is the ability to process HTTP requests aysnchronously i.e. add handlers to the server which generate their ```GCDWebServerResponse``` asynchronously. This is achieved by adding handlers that use a ```GCDWebServerAsyncProcessBlock``` instead of a ```GCDWebServerProcessBlock```. Here's an example: New in GCDWebServer 3.0 is the ability to process HTTP requests asynchronously i.e. add handlers to the server which generate their ```GCDWebServerResponse``` asynchronously. This is achieved by adding handlers that use a ```GCDWebServerAsyncProcessBlock``` instead of a ```GCDWebServerProcessBlock```. Here's an example:
**(Synchronous version)** The handler blocks while generating the HTTP response: **(Synchronous version)** The handler blocks while generating the HTTP response:
```objectivec ```objectivec