diff --git a/CGDWebServer/GCDWebServerConnection.m b/CGDWebServer/GCDWebServerConnection.m index 43de7d1..c9d7a47 100644 --- a/CGDWebServer/GCDWebServerConnection.m +++ b/CGDWebServer/GCDWebServerConnection.m @@ -448,7 +448,7 @@ static inline NSUInteger _ScanHexNumber(const void* bytes, NSUInteger size) { if ([_response hasBody]) { [self _writeBodyWithCompletionBlock:^(BOOL successInner) { - [_response performClose]; + [_response performClose]; // TODO: There's nothing we can do on failure as headers have already been sent }]; } diff --git a/CGDWebServer/GCDWebServerRequest.h b/CGDWebServer/GCDWebServerRequest.h index 49684b8..7122223 100644 --- a/CGDWebServer/GCDWebServerRequest.h +++ b/CGDWebServer/GCDWebServerRequest.h @@ -39,10 +39,10 @@ @property(nonatomic, readonly) NSDictionary* headers; @property(nonatomic, readonly) NSString* path; @property(nonatomic, readonly) NSDictionary* query; // May be nil -@property(nonatomic, readonly) NSString* contentType; // Automatically parsed from headers (nil if request has no body) +@property(nonatomic, readonly) NSString* contentType; // Automatically parsed from headers (nil if request has no body or set to "application/octet-stream" if a body is present without a "Content-Type" header) @property(nonatomic, readonly) NSUInteger contentLength; // Automatically parsed from headers (NSNotFound if request has no "Content-Length" header) @property(nonatomic, readonly) NSRange byteRange; // Automatically parsed from headers ([NSNotFound, 0] if request has no "Range" header, [offset, length] for byte range from beginning or [NSNotFound, -bytes] from end) - (id)initWithMethod:(NSString*)method url:(NSURL*)url headers:(NSDictionary*)headers path:(NSString*)path query:(NSDictionary*)query; -- (BOOL)hasBody; // Convenience method +- (BOOL)hasBody; // Convenience method that checks if "contentType" is not nil - (BOOL)hasByteRange; // Convenience method that checks "byteRange" @end diff --git a/CGDWebServer/GCDWebServerResponse.h b/CGDWebServer/GCDWebServerResponse.h index 4892535..18470a0 100644 --- a/CGDWebServer/GCDWebServerResponse.h +++ b/CGDWebServer/GCDWebServerResponse.h @@ -34,15 +34,15 @@ @end @interface GCDWebServerResponse : NSObject -@property(nonatomic, copy) NSString* contentType; // Default is nil i.e. no body -@property(nonatomic) NSUInteger contentLength; // Default is NSNotFound i.e. undefined +@property(nonatomic, copy) NSString* contentType; // Default is nil i.e. no body (must be set if a body is present) +@property(nonatomic) NSUInteger contentLength; // Default is NSNotFound i.e. undefined (if a body is present but length is undefined, chunked transfer encoding will be enabled) @property(nonatomic) NSInteger statusCode; // Default is 200 @property(nonatomic) NSUInteger cacheControlMaxAge; // Default is 0 seconds i.e. "no-cache" @property(nonatomic, getter=isGZipContentEncodingEnabled) BOOL gzipContentEncodingEnabled; // Default is disabled + (GCDWebServerResponse*) response; - (id)init; -- (void)setValue:(NSString*)value forAdditionalHeader:(NSString*)header; -- (BOOL)hasBody; // Convenience method +- (void)setValue:(NSString*)value forAdditionalHeader:(NSString*)header; // Pass nil value to remove header +- (BOOL)hasBody; // Convenience method that checks if "contentType" is not nil @end @interface GCDWebServerResponse (Extensions)