|
|
|
|
@ -876,7 +876,8 @@ static inline NSString* _EncodeBase64(NSString* string) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)addDefaultHandlerForMethod:(NSString*)method requestClass:(Class)aClass asyncProcessBlock:(GCDWebServerAsyncProcessBlock)block {
|
|
|
|
|
[self addHandlerWithMatchBlock:^GCDWebServerRequest*(NSString* requestMethod, NSURL* requestURL, NSDictionary<NSString*, NSString*>* requestHeaders, NSString* urlPath, NSDictionary<NSString*, NSString*>* urlQuery) {
|
|
|
|
|
[self
|
|
|
|
|
addHandlerWithMatchBlock:^GCDWebServerRequest*(NSString* requestMethod, NSURL* requestURL, NSDictionary<NSString*, NSString*>* requestHeaders, NSString* urlPath, NSDictionary<NSString*, NSString*>* urlQuery) {
|
|
|
|
|
if (![requestMethod isEqualToString:method]) {
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
@ -896,7 +897,8 @@ static inline NSString* _EncodeBase64(NSString* string) {
|
|
|
|
|
|
|
|
|
|
- (void)addHandlerForMethod:(NSString*)method path:(NSString*)path requestClass:(Class)aClass asyncProcessBlock:(GCDWebServerAsyncProcessBlock)block {
|
|
|
|
|
if ([path hasPrefix:@"/"] && [aClass isSubclassOfClass:[GCDWebServerRequest class]]) {
|
|
|
|
|
[self addHandlerWithMatchBlock:^GCDWebServerRequest*(NSString* requestMethod, NSURL* requestURL, NSDictionary<NSString*, NSString*>* requestHeaders, NSString* urlPath, NSDictionary<NSString*, NSString*>* urlQuery) {
|
|
|
|
|
[self
|
|
|
|
|
addHandlerWithMatchBlock:^GCDWebServerRequest*(NSString* requestMethod, NSURL* requestURL, NSDictionary<NSString*, NSString*>* requestHeaders, NSString* urlPath, NSDictionary<NSString*, NSString*>* urlQuery) {
|
|
|
|
|
if (![requestMethod isEqualToString:method]) {
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
@ -923,7 +925,8 @@ static inline NSString* _EncodeBase64(NSString* string) {
|
|
|
|
|
- (void)addHandlerForMethod:(NSString*)method pathRegex:(NSString*)regex requestClass:(Class)aClass asyncProcessBlock:(GCDWebServerAsyncProcessBlock)block {
|
|
|
|
|
NSRegularExpression* expression = [NSRegularExpression regularExpressionWithPattern:regex options:NSRegularExpressionCaseInsensitive error:NULL];
|
|
|
|
|
if (expression && [aClass isSubclassOfClass:[GCDWebServerRequest class]]) {
|
|
|
|
|
[self addHandlerWithMatchBlock:^GCDWebServerRequest*(NSString* requestMethod, NSURL* requestURL, NSDictionary<NSString*, NSString*>* requestHeaders, NSString* urlPath, NSDictionary<NSString*, NSString*>* urlQuery) {
|
|
|
|
|
[self
|
|
|
|
|
addHandlerWithMatchBlock:^GCDWebServerRequest*(NSString* requestMethod, NSURL* requestURL, NSDictionary<NSString*, NSString*>* requestHeaders, NSString* urlPath, NSDictionary<NSString*, NSString*>* urlQuery) {
|
|
|
|
|
if (![requestMethod isEqualToString:method]) {
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
@ -1021,7 +1024,8 @@ static inline NSString* _EncodeBase64(NSString* string) {
|
|
|
|
|
- (void)addGETHandlerForBasePath:(NSString*)basePath directoryPath:(NSString*)directoryPath indexFilename:(NSString*)indexFilename cacheAge:(NSUInteger)cacheAge allowRangeRequests:(BOOL)allowRangeRequests {
|
|
|
|
|
if ([basePath hasPrefix:@"/"] && [basePath hasSuffix:@"/"]) {
|
|
|
|
|
GCDWebServer* __unsafe_unretained server = self;
|
|
|
|
|
[self addHandlerWithMatchBlock:^GCDWebServerRequest*(NSString* requestMethod, NSURL* requestURL, NSDictionary<NSString*, NSString*>* requestHeaders, NSString* urlPath, NSDictionary<NSString*, NSString*>* urlQuery) {
|
|
|
|
|
[self
|
|
|
|
|
addHandlerWithMatchBlock:^GCDWebServerRequest*(NSString* requestMethod, NSURL* requestURL, NSDictionary<NSString*, NSString*>* requestHeaders, NSString* urlPath, NSDictionary<NSString*, NSString*>* urlQuery) {
|
|
|
|
|
if (![requestMethod isEqualToString:@"GET"]) {
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|