mirror of
https://github.com/swisspol/GCDWebServer.git
synced 2026-02-11 00:00:07 +08:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43555c6662 | ||
|
|
7c08c54156 | ||
|
|
5834770e08 | ||
|
|
52406a12c2 | ||
|
|
e83814b0fa | ||
|
|
fba593a602 | ||
|
|
eec17d5c7b | ||
|
|
32bc72113a | ||
|
|
200d21c3fa | ||
|
|
3042b853bc | ||
|
|
50eb0437c1 | ||
|
|
00cc560b8e | ||
|
|
fa41f26b30 | ||
|
|
845969ec0d | ||
|
|
629df7895d | ||
|
|
55104e5b1e | ||
|
|
fcc95fdc11 | ||
|
|
10a94e36fd | ||
|
|
010ef9b8bc | ||
|
|
5ca7c27a07 | ||
|
|
c6632633f8 | ||
|
|
5b6eebbb9e | ||
|
|
a4c61bd071 |
@@ -2,12 +2,12 @@
|
||||
# http://guides.cocoapods.org/making/getting-setup-with-trunk.html
|
||||
# $ sudo gem update cocoapods
|
||||
# (optional) $ pod trunk register {email} {name} --description={computer}
|
||||
# $ pod trunk push
|
||||
# $ pod trunk --verbose push
|
||||
# DELETE THIS SECTION BEFORE PROCEEDING!
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'GCDWebServer'
|
||||
s.version = '3.3.1'
|
||||
s.version = '3.3.3'
|
||||
s.author = { 'Pierre-Olivier Latour' => 'info@pol-online.net' }
|
||||
s.license = { :type => 'BSD', :file => 'LICENSE' }
|
||||
s.homepage = 'https://github.com/swisspol/GCDWebServer'
|
||||
@@ -39,8 +39,6 @@ Pod::Spec.new do |s|
|
||||
end
|
||||
|
||||
s.subspec 'WebDAV' do |cs|
|
||||
cs.default_subspec = 'Core'
|
||||
|
||||
cs.subspec "Core" do |ccs|
|
||||
ccs.dependency 'GCDWebServer/Core'
|
||||
ccs.source_files = 'GCDWebDAVServer/*.{h,m}'
|
||||
@@ -58,8 +56,6 @@ Pod::Spec.new do |s|
|
||||
end
|
||||
|
||||
s.subspec 'WebUploader' do |cs|
|
||||
cs.default_subspec = 'Core'
|
||||
|
||||
cs.subspec "Core" do |ccs|
|
||||
ccs.dependency 'GCDWebServer/Core'
|
||||
ccs.source_files = 'GCDWebUploader/*.{h,m}'
|
||||
|
||||
@@ -854,7 +854,7 @@
|
||||
08FB7793FE84155DC02AAC07 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0720;
|
||||
LastUpgradeCheck = 0730;
|
||||
TargetAttributes = {
|
||||
CEE28CD01AE004D800F4023C = {
|
||||
CreatedOnToolsVersion = 6.3;
|
||||
@@ -1208,7 +1208,7 @@
|
||||
1DEB928A08733DD80010E9CD /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BUNDLE_VERSION_STRING = 3.3.1;
|
||||
BUNDLE_VERSION_STRING = 3.3.3;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
@@ -1238,6 +1238,7 @@
|
||||
"-Wno-reserved-id-macro",
|
||||
"-Wno-cast-qual",
|
||||
"-Wno-nullable-to-nonnull-conversion",
|
||||
"-Wno-partial-availability",
|
||||
);
|
||||
};
|
||||
name = Debug;
|
||||
@@ -1245,7 +1246,7 @@
|
||||
1DEB928B08733DD80010E9CD /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BUNDLE_VERSION_STRING = 3.3.1;
|
||||
BUNDLE_VERSION_STRING = 3.3.3;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = __GCDWEBSERVER_ENABLE_TESTING__;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0720"
|
||||
LastUpgradeVersion = "0730"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -50,7 +50,6 @@
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
enableAddressSanitizer = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
@@ -63,11 +62,6 @@
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
<AdditionalOption
|
||||
key = "NSZombieEnabled"
|
||||
value = "YES"
|
||||
isEnabled = "YES">
|
||||
</AdditionalOption>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0720"
|
||||
LastUpgradeVersion = "0730"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -49,7 +49,6 @@
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
enableAddressSanitizer = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
@@ -62,11 +61,6 @@
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
<AdditionalOption
|
||||
key = "NSZombieEnabled"
|
||||
value = "YES"
|
||||
isEnabled = "YES">
|
||||
</AdditionalOption>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0720"
|
||||
LastUpgradeVersion = "0730"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -49,7 +49,6 @@
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
enableAddressSanitizer = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
@@ -62,11 +61,6 @@
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
<AdditionalOption
|
||||
key = "NSZombieEnabled"
|
||||
value = "YES"
|
||||
isEnabled = "YES">
|
||||
</AdditionalOption>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
|
||||
@@ -52,7 +52,7 @@ typedef GCDWebServerRequest* (^GCDWebServerMatchBlock)(NSString* requestMethod,
|
||||
* recommended to return a GCDWebServerErrorResponse on error so more useful
|
||||
* information can be returned to the client.
|
||||
*/
|
||||
typedef GCDWebServerResponse* (^GCDWebServerProcessBlock)(GCDWebServerRequest* request);
|
||||
typedef GCDWebServerResponse* (^GCDWebServerProcessBlock)(__kindof GCDWebServerRequest* request);
|
||||
|
||||
/**
|
||||
* The GCDWebServerAsynchronousProcessBlock works like the GCDWebServerProcessBlock
|
||||
@@ -65,7 +65,7 @@ typedef GCDWebServerResponse* (^GCDWebServerProcessBlock)(GCDWebServerRequest* r
|
||||
* useful information can be returned to the client.
|
||||
*/
|
||||
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).
|
||||
@@ -176,6 +176,15 @@ extern NSString* const GCDWebServerOption_AutomaticallyMapHEADToGET;
|
||||
*/
|
||||
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
|
||||
|
||||
/**
|
||||
@@ -537,12 +546,10 @@ extern NSString* const GCDWebServerAuthenticationMethod_DigestAccess;
|
||||
* GWS_LOG_INFO(...)
|
||||
* GWS_LOG_WARNING(...)
|
||||
* GWS_LOG_ERROR(...)
|
||||
* GWS_LOG_EXCEPTION(__EXCEPTION__)
|
||||
*
|
||||
* IMPORTANT: Except for GWS_LOG_EXCEPTION() which gets passed an NSException,
|
||||
* these macros must behave like NSLog(). Furthermore the GWS_LOG_DEBUG() macro
|
||||
* should not do anything unless the preprocessor constant "DEBUG" evaluates to
|
||||
* non-zero.
|
||||
* IMPORTANT: These macros must behave like NSLog(). Furthermore the GWS_LOG_DEBUG()
|
||||
* macro should not do anything unless the preprocessor constant "DEBUG" evaluates
|
||||
* to non-zero.
|
||||
*
|
||||
* The logging methods below send log messages to the same logging facility
|
||||
* used by GCDWebServer. They can be used for consistency wherever you interact
|
||||
@@ -562,7 +569,6 @@ extern NSString* const GCDWebServerAuthenticationMethod_DigestAccess;
|
||||
* INFO = 2
|
||||
* WARNING = 3
|
||||
* ERROR = 4
|
||||
* EXCEPTION = 5
|
||||
*/
|
||||
+ (void)setLogLevel:(int)level;
|
||||
|
||||
@@ -586,11 +592,6 @@ extern NSString* const GCDWebServerAuthenticationMethod_DigestAccess;
|
||||
*/
|
||||
- (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
|
||||
|
||||
#ifdef __GCDWEBSERVER_ENABLE_TESTING__
|
||||
|
||||
@@ -63,6 +63,7 @@ NSString* const GCDWebServerOption_AuthenticationAccounts = @"AuthenticationAcco
|
||||
NSString* const GCDWebServerOption_ConnectionClass = @"ConnectionClass";
|
||||
NSString* const GCDWebServerOption_AutomaticallyMapHEADToGET = @"AutomaticallyMapHEADToGET";
|
||||
NSString* const GCDWebServerOption_ConnectedStateCoalescingInterval = @"ConnectedStateCoalescingInterval";
|
||||
NSString* const GCDWebServerOption_DispatchQueuePriority = @"DispatchQueuePriority";
|
||||
#if TARGET_OS_IPHONE
|
||||
NSString* const GCDWebServerOption_AutomaticallySuspendInBackground = @"AutomaticallySuspendInBackground";
|
||||
#endif
|
||||
@@ -91,7 +92,7 @@ static BOOL _run;
|
||||
#ifdef __GCDWEBSERVER_LOGGING_FACILITY_BUILTIN__
|
||||
|
||||
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;
|
||||
if (enableLogging < 0) {
|
||||
enableLogging = (isatty(STDERR_FILENO) ? 1 : 0);
|
||||
@@ -170,6 +171,7 @@ static void _ExecuteMainThreadRunLoopSources() {
|
||||
Class _connectionClass;
|
||||
BOOL _mapHEADToGET;
|
||||
CFTimeInterval _disconnectDelay;
|
||||
dispatch_queue_priority_t _dispatchQueuePriority;
|
||||
NSUInteger _port;
|
||||
dispatch_source_t _source4;
|
||||
dispatch_source_t _source6;
|
||||
@@ -195,7 +197,7 @@ static void _ExecuteMainThreadRunLoopSources() {
|
||||
|
||||
@synthesize delegate=_delegate, handlers=_handlers, port=_port, serverName=_serverName, authenticationRealm=_authenticationRealm,
|
||||
authenticationBasicAccounts=_authenticationBasicAccounts, authenticationDigestAccounts=_authenticationDigestAccounts,
|
||||
shouldAutomaticallyMapHEADToGET=_mapHEADToGET;
|
||||
shouldAutomaticallyMapHEADToGET=_mapHEADToGET, dispatchQueuePriority=_dispatchQueuePriority;
|
||||
|
||||
+ (void)initialize {
|
||||
GCDWebServerInitializeFunctions();
|
||||
@@ -493,7 +495,7 @@ static inline NSString* _EncodeBase64(NSString* string) {
|
||||
|
||||
- (dispatch_source_t)_createDispatchSourceWithListeningSocket:(int)listeningSocket isIPv6:(BOOL)isIPv6 {
|
||||
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, ^{
|
||||
|
||||
@autoreleasepool {
|
||||
@@ -599,6 +601,7 @@ static inline NSString* _EncodeBase64(NSString* string) {
|
||||
_connectionClass = _GetOption(_options, GCDWebServerOption_ConnectionClass, [GCDWebServerConnection class]);
|
||||
_mapHEADToGET = [_GetOption(_options, GCDWebServerOption_AutomaticallyMapHEADToGET, @YES) boolValue];
|
||||
_disconnectDelay = [_GetOption(_options, GCDWebServerOption_ConnectedStateCoalescingInterval, @1.0) doubleValue];
|
||||
_dispatchQueuePriority = [_GetOption(_options, GCDWebServerOption_DispatchQueuePriority, @(DISPATCH_QUEUE_PRIORITY_DEFAULT)) longValue];
|
||||
|
||||
_source4 = [self _createDispatchSourceWithListeningSocket:listeningSocket4 isIPv6:NO];
|
||||
_source6 = [self _createDispatchSourceWithListeningSocket:listeningSocket6 isIPv6:YES];
|
||||
@@ -1128,10 +1131,6 @@ static inline NSString* _EncodeBase64(NSString* string) {
|
||||
va_end(arguments);
|
||||
}
|
||||
|
||||
- (void)logException:(NSException*)exception {
|
||||
GWS_LOG_EXCEPTION(exception);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#ifdef __GCDWEBSERVER_ENABLE_TESTING__
|
||||
|
||||
@@ -88,7 +88,7 @@ static int32_t _connectionCounter = 0;
|
||||
@implementation GCDWebServerConnection (Read)
|
||||
|
||||
- (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 {
|
||||
if (error == 0) {
|
||||
@@ -247,10 +247,10 @@ static inline NSUInteger _ScanHexNumber(const void* bytes, NSUInteger size) {
|
||||
@implementation GCDWebServerConnection (Write)
|
||||
|
||||
- (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
|
||||
});
|
||||
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 {
|
||||
if (error == 0) {
|
||||
@@ -758,12 +758,7 @@ static inline NSUInteger _ScanHexNumber(const void* bytes, NSUInteger size) {
|
||||
|
||||
- (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);
|
||||
@try {
|
||||
_handler.asyncProcessBlock(request, [completion copy]);
|
||||
}
|
||||
@catch (NSException* exception) {
|
||||
GWS_LOG_EXCEPTION(exception);
|
||||
}
|
||||
_handler.asyncProcessBlock(request, [completion copy]);
|
||||
}
|
||||
|
||||
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.25
|
||||
|
||||
@@ -246,7 +246,7 @@ NSString* GCDWebServerStringFromSockAddr(const struct sockaddr* addr, BOOL inclu
|
||||
NSString* GCDWebServerGetPrimaryIPAddress(BOOL useIPv6) {
|
||||
NSString* address = nil;
|
||||
#if TARGET_OS_IPHONE
|
||||
#if !TARGET_IPHONE_SIMULATOR
|
||||
#if !TARGET_IPHONE_SIMULATOR && !TARGET_OS_TV
|
||||
const char* primaryInterface = "en0"; // WiFi interface on iOS
|
||||
#endif
|
||||
#else
|
||||
|
||||
@@ -77,7 +77,6 @@
|
||||
#define GWS_LOG_INFO(...) XLOG_INFO(__VA_ARGS__)
|
||||
#define GWS_LOG_WARNING(...) XLOG_WARNING(__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_DNOT_REACHED() XLOG_DEBUG_UNREACHABLE()
|
||||
@@ -102,7 +101,6 @@ extern DDLogLevel GCDWebServerLogLevel;
|
||||
#define GWS_LOG_INFO(...) DDLogInfo(__VA_ARGS__)
|
||||
#define GWS_LOG_WARNING(...) DDLogWarn(__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
|
||||
@@ -118,8 +116,7 @@ typedef NS_ENUM(int, GCDWebServerLoggingLevel) {
|
||||
kGCDWebServerLoggingLevel_Verbose,
|
||||
kGCDWebServerLoggingLevel_Info,
|
||||
kGCDWebServerLoggingLevel_Warning,
|
||||
kGCDWebServerLoggingLevel_Error,
|
||||
kGCDWebServerLoggingLevel_Exception
|
||||
kGCDWebServerLoggingLevel_Error
|
||||
};
|
||||
|
||||
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_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_EXCEPTION(__EXCEPTION__) do { if (GCDWebServerLogLevel <= kGCDWebServerLoggingLevel_Exception) GCDWebServerLogMessage(kGCDWebServerLoggingLevel_Exception, @"%@", __EXCEPTION__); } while (0)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -168,7 +164,6 @@ extern void GCDWebServerLogMessage(GCDWebServerLoggingLevel level, NSString* for
|
||||
*/
|
||||
|
||||
#define kGCDWebServerDefaultMimeType @"application/octet-stream"
|
||||
#define kGCDWebServerGCDQueue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
|
||||
#define kGCDWebServerErrorDomain @"GCDWebServerErrorDomain"
|
||||
|
||||
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* authenticationDigestAccounts;
|
||||
@property(nonatomic, readonly) BOOL shouldAutomaticallyMapHEADToGET;
|
||||
@property(nonatomic, readonly) dispatch_queue_priority_t dispatchQueuePriority;
|
||||
- (void)willStartConnection:(GCDWebServerConnection*)connection;
|
||||
- (void)didEndConnection:(GCDWebServerConnection*)connection;
|
||||
@end
|
||||
|
||||
@@ -94,7 +94,7 @@ NSString* const GCDWebServerRequestAttribute_RegexCaptures = @"GCDWebServerReque
|
||||
return NO;
|
||||
}
|
||||
if (![super open:error]) {
|
||||
deflateEnd(&_stream);
|
||||
inflateEnd(&_stream);
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
|
||||
@@ -241,6 +241,7 @@
|
||||
}
|
||||
|
||||
- (void)performReadDataWithCompletion:(GCDWebServerBodyReaderCompletionBlock)block {
|
||||
GWS_DCHECK(_opened);
|
||||
if ([_reader respondsToSelector:@selector(asyncReadDataWithCompletion:)]) {
|
||||
[_reader asyncReadDataWithCompletion:[block copy]];
|
||||
} else {
|
||||
|
||||
14
README.md
14
README.md
@@ -71,9 +71,9 @@ Then run `$ carthage update` and add the generated frameworks to your Xcode proj
|
||||
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
|
||||
===========
|
||||
@@ -153,7 +153,7 @@ int main(int argc, const char* argv[]) {
|
||||
***webServer.swift***
|
||||
```swift
|
||||
import Foundation
|
||||
import GCDWebServers
|
||||
import GCDWebServer
|
||||
|
||||
func initWebServer() {
|
||||
|
||||
@@ -172,8 +172,8 @@ func initWebServer() {
|
||||
|
||||
***WebServer-Bridging-Header.h***
|
||||
```objectivec
|
||||
#import <GCDWebServers/GCDWebServer.h>
|
||||
#import <GCDWebServers/GCDWebServerDataResponse.h>
|
||||
#import <GCDWebServer/GCDWebServer.h>
|
||||
#import <GCDWebServer/GCDWebServerDataResponse.h>
|
||||
```
|
||||
|
||||
Web Based Uploads in iOS Apps
|
||||
@@ -276,7 +276,7 @@ GCDWebServer's architecture consists of only 4 core classes:
|
||||
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:
|
||||
* 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
|
||||
===========================
|
||||
|
||||
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:
|
||||
```objectivec
|
||||
|
||||
Reference in New Issue
Block a user