Skip to content

Commit 21cc6bf

Browse files
committed
Added types to collections
1 parent faf28fe commit 21cc6bf

20 files changed

Lines changed: 50 additions & 50 deletions

GCDWebDAVServer/GCDWebDAVServer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ NS_ASSUME_NONNULL_BEGIN
9595
*
9696
* The default value is nil i.e. all file extensions are allowed.
9797
*/
98-
@property(nonatomic, copy) NSArray* allowedFileExtensions;
98+
@property(nonatomic, copy) NSArray<NSString*>* allowedFileExtensions;
9999

100100
/**
101101
* Sets if files and directories whose name start with a period are allowed to

GCDWebServer/Core/GCDWebServer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ NS_ASSUME_NONNULL_BEGIN
4242
* GCDWebServerRequest instance created with the same basic info.
4343
* Otherwise, it simply returns nil.
4444
*/
45-
typedef GCDWebServerRequest* _Nullable (^GCDWebServerMatchBlock)(NSString* requestMethod, NSURL* requestURL, NSDictionary* requestHeaders, NSString* urlPath, NSDictionary* urlQuery);
45+
typedef GCDWebServerRequest* _Nullable (^GCDWebServerMatchBlock)(NSString* requestMethod, NSURL* requestURL, NSDictionary<NSString*, NSString*>* requestHeaders, NSString* urlPath, NSDictionary<NSString*, NSString*>* urlQuery);
4646

4747
/**
4848
* The GCDWebServerProcessBlock is called after the HTTP request has been fully
@@ -365,7 +365,7 @@ extern NSString* const GCDWebServerAuthenticationMethod_DigestAccess;
365365
*
366366
* Returns NO if the server failed to start and sets "error" argument if not NULL.
367367
*/
368-
- (BOOL)startWithOptions:(nullable NSDictionary*)options error:(NSError** _Nullable)error;
368+
- (BOOL)startWithOptions:(nullable NSDictionary<NSString*, id>*)options error:(NSError** _Nullable)error;
369369

370370
/**
371371
* Stops the server and prevents it to accepts new HTTP requests.
@@ -444,7 +444,7 @@ extern NSString* const GCDWebServerAuthenticationMethod_DigestAccess;
444444
*
445445
* @warning This method must be used from the main thread only.
446446
*/
447-
- (BOOL)runWithOptions:(nullable NSDictionary*)options error:(NSError** _Nullable)error;
447+
- (BOOL)runWithOptions:(nullable NSDictionary<NSString*, id>*)options error:(NSError** _Nullable)error;
448448

449449
#endif
450450

@@ -613,7 +613,7 @@ extern NSString* const GCDWebServerAuthenticationMethod_DigestAccess;
613613
*
614614
* Returns the number of failed tests or -1 if server failed to start.
615615
*/
616-
- (NSInteger)runTestsWithOptions:(nullable NSDictionary*)options inDirectory:(NSString*)path;
616+
- (NSInteger)runTestsWithOptions:(nullable NSDictionary<NSString*, id>*)options inDirectory:(NSString*)path;
617617

618618
@end
619619

GCDWebServer/Core/GCDWebServer.m

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,14 @@ - (instancetype)initWithMatchBlock:(GCDWebServerMatchBlock _Nonnull)matchBlock a
141141
@implementation GCDWebServer {
142142
dispatch_queue_t _syncQueue;
143143
dispatch_group_t _sourceGroup;
144-
NSMutableArray* _handlers;
144+
NSMutableArray<GCDWebServerHandler*>* _handlers;
145145
NSInteger _activeConnections; // Accessed through _syncQueue only
146146
BOOL _connected; // Accessed on main thread only
147147
CFRunLoopTimerRef _disconnectTimer; // Accessed on main thread only
148148

149-
NSDictionary* _options;
150-
NSMutableDictionary* _authenticationBasicAccounts;
151-
NSMutableDictionary* _authenticationDigestAccounts;
149+
NSDictionary<NSString*, id>* _options;
150+
NSMutableDictionary<NSString*, NSString*>* _authenticationBasicAccounts;
151+
NSMutableDictionary<NSString*, NSString*>* _authenticationDigestAccounts;
152152
Class _connectionClass;
153153
CFTimeInterval _disconnectDelay;
154154
dispatch_source_t _source4;
@@ -408,7 +408,7 @@ static void _SocketCallBack(CFSocketRef s, CFSocketCallBackType type, CFDataRef
408408
}
409409
}
410410

411-
static inline id _GetOption(NSDictionary* options, NSString* key, id defaultValue) {
411+
static inline id _GetOption(NSDictionary<NSString*, id>* options, NSString* key, id defaultValue) {
412412
id value = [options objectForKey:key];
413413
return value ? value : defaultValue;
414414
}
@@ -721,7 +721,7 @@ - (void)_willEnterForeground:(NSNotification*)notification {
721721

722722
#endif
723723

724-
- (BOOL)startWithOptions:(NSDictionary*)options error:(NSError**)error {
724+
- (BOOL)startWithOptions:(NSDictionary<NSString*, id>*)options error:(NSError**)error {
725725
if (_options == nil) {
726726
_options = options ? [options copy] : @{};
727727
#if TARGET_OS_IPHONE
@@ -832,7 +832,7 @@ - (BOOL)runWithPort:(NSUInteger)port bonjourName:(NSString*)name {
832832
return [self runWithOptions:options error:NULL];
833833
}
834834

835-
- (BOOL)runWithOptions:(NSDictionary*)options error:(NSError**)error {
835+
- (BOOL)runWithOptions:(NSDictionary<NSString*, id>*)options error:(NSError**)error {
836836
GWS_DCHECK([NSThread isMainThread]);
837837
BOOL success = NO;
838838
_run = YES;
@@ -868,7 +868,7 @@ - (void)addDefaultHandlerForMethod:(NSString*)method requestClass:(Class)aClass
868868
}
869869

870870
- (void)addDefaultHandlerForMethod:(NSString*)method requestClass:(Class)aClass asyncProcessBlock:(GCDWebServerAsyncProcessBlock)block {
871-
[self addHandlerWithMatchBlock:^GCDWebServerRequest*(NSString* requestMethod, NSURL* requestURL, NSDictionary* requestHeaders, NSString* urlPath, NSDictionary* urlQuery) {
871+
[self addHandlerWithMatchBlock:^GCDWebServerRequest*(NSString* requestMethod, NSURL* requestURL, NSDictionary<NSString*, NSString*>* requestHeaders, NSString* urlPath, NSDictionary<NSString*, NSString*>* urlQuery) {
872872
if (![requestMethod isEqualToString:method]) {
873873
return nil;
874874
}
@@ -888,7 +888,7 @@ - (void)addHandlerForMethod:(NSString*)method path:(NSString*)path requestClass:
888888

889889
- (void)addHandlerForMethod:(NSString*)method path:(NSString*)path requestClass:(Class)aClass asyncProcessBlock:(GCDWebServerAsyncProcessBlock)block {
890890
if ([path hasPrefix:@"/"] && [aClass isSubclassOfClass:[GCDWebServerRequest class]]) {
891-
[self addHandlerWithMatchBlock:^GCDWebServerRequest*(NSString* requestMethod, NSURL* requestURL, NSDictionary* requestHeaders, NSString* urlPath, NSDictionary* urlQuery) {
891+
[self addHandlerWithMatchBlock:^GCDWebServerRequest*(NSString* requestMethod, NSURL* requestURL, NSDictionary<NSString*, NSString*>* requestHeaders, NSString* urlPath, NSDictionary<NSString*, NSString*>* urlQuery) {
892892
if (![requestMethod isEqualToString:method]) {
893893
return nil;
894894
}
@@ -915,7 +915,7 @@ - (void)addHandlerForMethod:(NSString*)method pathRegex:(NSString*)regex request
915915
- (void)addHandlerForMethod:(NSString*)method pathRegex:(NSString*)regex requestClass:(Class)aClass asyncProcessBlock:(GCDWebServerAsyncProcessBlock)block {
916916
NSRegularExpression* expression = [NSRegularExpression regularExpressionWithPattern:regex options:NSRegularExpressionCaseInsensitive error:NULL];
917917
if (expression && [aClass isSubclassOfClass:[GCDWebServerRequest class]]) {
918-
[self addHandlerWithMatchBlock:^GCDWebServerRequest*(NSString* requestMethod, NSURL* requestURL, NSDictionary* requestHeaders, NSString* urlPath, NSDictionary* urlQuery) {
918+
[self addHandlerWithMatchBlock:^GCDWebServerRequest*(NSString* requestMethod, NSURL* requestURL, NSDictionary<NSString*, NSString*>* requestHeaders, NSString* urlPath, NSDictionary<NSString*, NSString*>* urlQuery) {
919919
if (![requestMethod isEqualToString:method]) {
920920
return nil;
921921
}
@@ -1013,7 +1013,7 @@ - (GCDWebServerResponse*)_responseWithContentsOfDirectory:(NSString*)path {
10131013
- (void)addGETHandlerForBasePath:(NSString*)basePath directoryPath:(NSString*)directoryPath indexFilename:(NSString*)indexFilename cacheAge:(NSUInteger)cacheAge allowRangeRequests:(BOOL)allowRangeRequests {
10141014
if ([basePath hasPrefix:@"/"] && [basePath hasSuffix:@"/"]) {
10151015
GCDWebServer* __unsafe_unretained server = self;
1016-
[self addHandlerWithMatchBlock:^GCDWebServerRequest*(NSString* requestMethod, NSURL* requestURL, NSDictionary* requestHeaders, NSString* urlPath, NSDictionary* urlQuery) {
1016+
[self addHandlerWithMatchBlock:^GCDWebServerRequest*(NSString* requestMethod, NSURL* requestURL, NSDictionary<NSString*, NSString*>* requestHeaders, NSString* urlPath, NSDictionary<NSString*, NSString*>* urlQuery) {
10171017
if (![requestMethod isEqualToString:@"GET"]) {
10181018
return nil;
10191019
}
@@ -1168,7 +1168,7 @@ static void _LogResult(NSString* format, ...) {
11681168
fprintf(stdout, "%s\n", [message UTF8String]);
11691169
}
11701170

1171-
- (NSInteger)runTestsWithOptions:(NSDictionary*)options inDirectory:(NSString*)path {
1171+
- (NSInteger)runTestsWithOptions:(NSDictionary<NSString*, id>*)options inDirectory:(NSString*)path {
11721172
GWS_DCHECK([NSThread isMainThread]);
11731173
NSArray* ignoredHeaders = @[ @"Date", @"Etag" ]; // Dates are always different by definition and ETags depend on file system node IDs
11741174
NSInteger result = -1;

GCDWebServer/Core/GCDWebServerConnection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ NS_ASSUME_NONNULL_BEGIN
130130
*
131131
* The default implementation returns the original URL.
132132
*/
133-
- (NSURL*)rewriteRequestURL:(NSURL*)url withMethod:(NSString*)method headers:(NSDictionary*)headers;
133+
- (NSURL*)rewriteRequestURL:(NSURL*)url withMethod:(NSString*)method headers:(NSDictionary<NSString*, NSString*>*)headers;
134134

135135
/**
136136
* Assuming a valid HTTP request was received, this method is called before

GCDWebServer/Core/GCDWebServerConnection.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ - (void)didWriteBytes:(const void*)bytes length:(NSUInteger)length {
698698
#endif
699699
}
700700

701-
- (NSURL*)rewriteRequestURL:(NSURL*)url withMethod:(NSString*)method headers:(NSDictionary*)headers {
701+
- (NSURL*)rewriteRequestURL:(NSURL*)url withMethod:(NSString*)method headers:(NSDictionary<NSString*, NSString*>*)headers {
702702
return url;
703703
}
704704

GCDWebServer/Core/GCDWebServerFunctions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ extern "C" {
4141
* types. Keys of the dictionary must be lowercased file extensions without
4242
* the period, and the values must be the corresponding MIME types.
4343
*/
44-
NSString* GCDWebServerGetMimeTypeForExtension(NSString* extension, NSDictionary* _Nullable overrides);
44+
NSString* GCDWebServerGetMimeTypeForExtension(NSString* extension, NSDictionary<NSString*, NSString*>* _Nullable overrides);
4545

4646
/**
4747
* Add percent-escapes to a string so it can be used in a URL.
@@ -60,7 +60,7 @@ NSString* _Nullable GCDWebServerUnescapeURLString(NSString* string);
6060
* "application/x-www-form-urlencoded" form.
6161
* http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1
6262
*/
63-
NSDictionary* GCDWebServerParseURLEncodedForm(NSString* form);
63+
NSDictionary<NSString*, NSString*>* GCDWebServerParseURLEncodedForm(NSString* form);
6464

6565
/**
6666
* On OS X, returns the IPv4 or IPv6 address as a string of the primary

GCDWebServer/Core/GCDWebServerFunctions.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ BOOL GCDWebServerIsTextContentType(NSString* type) {
166166
return [NSString stringWithFormat:@"<%lu bytes>", (unsigned long)data.length];
167167
}
168168

169-
NSString* GCDWebServerGetMimeTypeForExtension(NSString* extension, NSDictionary* overrides) {
169+
NSString* GCDWebServerGetMimeTypeForExtension(NSString* extension, NSDictionary<NSString*, NSString*>* overrides) {
170170
NSDictionary* builtInOverrides = @{@"css" : @"text/css"};
171171
NSString* mimeType = nil;
172172
extension = [extension lowercaseString];
@@ -200,7 +200,7 @@ BOOL GCDWebServerIsTextContentType(NSString* type) {
200200
#pragma clang diagnostic pop
201201
}
202202

203-
NSDictionary* GCDWebServerParseURLEncodedForm(NSString* form) {
203+
NSDictionary<NSString*, NSString*>* GCDWebServerParseURLEncodedForm(NSString* form) {
204204
NSMutableDictionary* parameters = [NSMutableDictionary dictionary];
205205
NSScanner* scanner = [[NSScanner alloc] initWithString:form];
206206
[scanner setCharactersToBeSkipped:nil];

GCDWebServer/Core/GCDWebServerPrivate.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,11 @@ extern NSString* GCDWebServerStringFromSockAddr(const struct sockaddr* addr, BOO
185185
@end
186186

187187
@interface GCDWebServer ()
188-
@property(nonatomic, readonly) NSMutableArray* handlers;
188+
@property(nonatomic, readonly) NSMutableArray<GCDWebServerHandler*>* handlers;
189189
@property(nonatomic, readonly, nullable) NSString* serverName;
190190
@property(nonatomic, readonly, nullable) NSString* authenticationRealm;
191-
@property(nonatomic, readonly, nullable) NSMutableDictionary* authenticationBasicAccounts;
192-
@property(nonatomic, readonly, nullable) NSMutableDictionary* authenticationDigestAccounts;
191+
@property(nonatomic, readonly, nullable) NSMutableDictionary<NSString*, NSString*>* authenticationBasicAccounts;
192+
@property(nonatomic, readonly, nullable) NSMutableDictionary<NSString*, NSString*>* authenticationDigestAccounts;
193193
@property(nonatomic, readonly) BOOL shouldAutomaticallyMapHEADToGET;
194194
@property(nonatomic, readonly) dispatch_queue_priority_t dispatchQueuePriority;
195195
- (void)willStartConnection:(GCDWebServerConnection*)connection;
@@ -213,7 +213,7 @@ extern NSString* GCDWebServerStringFromSockAddr(const struct sockaddr* addr, BOO
213213
@end
214214

215215
@interface GCDWebServerResponse ()
216-
@property(nonatomic, readonly) NSDictionary* additionalHeaders;
216+
@property(nonatomic, readonly) NSDictionary<NSString*, NSString*>* additionalHeaders;
217217
@property(nonatomic, readonly) BOOL usesChunkedTransferEncoding;
218218
- (void)prepareForReading;
219219
- (BOOL)performOpen:(NSError**)error;

GCDWebServer/Core/GCDWebServerRequest.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ extern NSString* const GCDWebServerRequestAttribute_RegexCaptures;
102102
/**
103103
* Returns the HTTP headers for the request.
104104
*/
105-
@property(nonatomic, readonly) NSDictionary* headers;
105+
@property(nonatomic, readonly) NSDictionary<NSString*, NSString*>* headers;
106106

107107
/**
108108
* Returns the path component of the URL for the request.
@@ -114,7 +114,7 @@ extern NSString* const GCDWebServerRequestAttribute_RegexCaptures;
114114
*
115115
* @warning This property will be nil if there is no query in the URL.
116116
*/
117-
@property(nonatomic, readonly, nullable) NSDictionary* query;
117+
@property(nonatomic, readonly, nullable) NSDictionary<NSString*, NSString*>* query;
118118

119119
/**
120120
* Returns the content type for the body of the request parsed from the
@@ -186,7 +186,7 @@ extern NSString* const GCDWebServerRequestAttribute_RegexCaptures;
186186
/**
187187
* This method is the designated initializer for the class.
188188
*/
189-
- (instancetype)initWithMethod:(NSString*)method url:(NSURL*)url headers:(NSDictionary*)headers path:(NSString*)path query:(nullable NSDictionary*)query;
189+
- (instancetype)initWithMethod:(NSString*)method url:(NSURL*)url headers:(NSDictionary<NSString*, NSString*>*)headers path:(NSString*)path query:(nullable NSDictionary<NSString*, NSString*>*)query;
190190

191191
/**
192192
* Convenience method that checks if the contentType property is defined.

GCDWebServer/Core/GCDWebServerRequest.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,12 @@ - (BOOL)close:(NSError**)error {
136136

137137
@implementation GCDWebServerRequest {
138138
BOOL _opened;
139-
NSMutableArray* _decoders;
139+
NSMutableArray<GCDWebServerBodyDecoder*>* _decoders;
140140
id<GCDWebServerBodyWriter> __unsafe_unretained _writer;
141-
NSMutableDictionary* _attributes;
141+
NSMutableDictionary<NSString*, id>* _attributes;
142142
}
143143

144-
- (instancetype)initWithMethod:(NSString*)method url:(NSURL*)url headers:(NSDictionary*)headers path:(NSString*)path query:(NSDictionary*)query {
144+
- (instancetype)initWithMethod:(NSString*)method url:(NSURL*)url headers:(NSDictionary<NSString*, NSString*>*)headers path:(NSString*)path query:(NSDictionary<NSString*, NSString*>*)query {
145145
if ((self = [super init])) {
146146
_method = [method copy];
147147
_URL = url;

0 commit comments

Comments
 (0)