Moved +shouldAutomaticallyMapHEADToGET to GCDWebServer class

This commit is contained in:
Pierre-Olivier Latour
2014-04-09 13:53:46 -07:00
parent d383845fcc
commit fcea9cad44
4 changed files with 6 additions and 6 deletions

View File

@@ -63,6 +63,7 @@ NSString* GCDWebServerGetPrimaryIPv4Address(); // Returns IPv4 address of prima
@interface GCDWebServer (Subclassing)
+ (Class)connectionClass;
+ (NSString*)serverName; // Default is class name
+ (BOOL)shouldAutomaticallyMapHEADToGET; // Default is YES which means HEAD requests are mapped to GET requests with the response body being discarded
@end
@interface GCDWebServer (Extensions)

View File

@@ -510,6 +510,10 @@ static void _NetServiceClientCallBack(CFNetServiceRef service, CFStreamError* er
return NSStringFromClass(self);
}
+ (BOOL)shouldAutomaticallyMapHEADToGET {
return YES;
}
@end
@implementation GCDWebServer (Extensions)

View File

@@ -40,7 +40,6 @@
@end
@interface GCDWebServerConnection (Subclassing)
+ (BOOL)shouldAutomaticallyMapHEADToGET; // Default is YES which means HEAD requests are mapped to GET requests with the response body being discarded
- (void)open;
- (void)didUpdateBytesRead; // Called from arbitrary thread after @totalBytesRead is updated - Default implementation does nothing
- (void)didUpdateBytesWritten; // Called from arbitrary thread after @totalBytesWritten is updated - Default implementation does nothing

View File

@@ -535,7 +535,7 @@ static inline NSUInteger _ScanHexNumber(const void* bytes, NSUInteger size) {
if (extraData) {
NSString* requestMethod = ARC_BRIDGE_RELEASE(CFHTTPMessageCopyRequestMethod(_requestMessage)); // Method verbs are case-sensitive and uppercase
DCHECK(requestMethod);
if ([[self class] shouldAutomaticallyMapHEADToGET] && [requestMethod isEqualToString:@"HEAD"]) {
if ([[_server class] shouldAutomaticallyMapHEADToGET] && [requestMethod isEqualToString:@"HEAD"]) {
requestMethod = @"GET";
_virtualHEAD = YES;
}
@@ -662,10 +662,6 @@ static NSString* _StringFromAddressData(NSData* data) {
@implementation GCDWebServerConnection (Subclassing)
+ (BOOL)shouldAutomaticallyMapHEADToGET {
return YES;
}
- (void)open {
LOG_DEBUG(@"Did open connection on socket %i", _socket);
[self _readRequestHeaders];