mirror of
https://github.com/swisspol/GCDWebServer.git
synced 2026-02-11 00:00:07 +08:00
Fixes
This commit is contained in:
@@ -29,7 +29,8 @@
|
||||
|
||||
#ifdef __LOGGING_HEADER__
|
||||
|
||||
#import __LOGGING_HEADER__
|
||||
// Define __GCDWEBSERVER_LOGGING_HEADER__ as a preprocessor constant to redirect GCDWebServer logging to your own system
|
||||
#import __GCDWEBSERVER_LOGGING_HEADER__
|
||||
|
||||
#else
|
||||
|
||||
|
||||
@@ -72,10 +72,10 @@
|
||||
@interface GCDWebServerDataResponse (Extensions)
|
||||
+ (GCDWebServerDataResponse*) responseWithText:(NSString*)text;
|
||||
+ (GCDWebServerDataResponse*) responseWithHTML:(NSString*)html;
|
||||
+ (GCDWebServerDataResponse*) responseWithHTMLTemplate:(NSString*)path variables:(NSDictionary*)variables; // Simple template system that replaces all occurences of "%variable%" with corresponding value (encodes using UTF-8)
|
||||
+ (GCDWebServerDataResponse*) responseWithHTMLTemplate:(NSString*)path variables:(NSDictionary*)variables;
|
||||
- (id) initWithText:(NSString*)text; // Encodes using UTF-8
|
||||
- (id) initWithHTML:(NSString*)html; // Encodes using UTF-8
|
||||
- (id) initWithHTMLTemplate:(NSString*)path variables:(NSDictionary*)variables;
|
||||
- (id) initWithHTMLTemplate:(NSString*)path variables:(NSDictionary*)variables; // Simple template system that replaces all occurences of "%variable%" with corresponding value (encodes using UTF-8)
|
||||
@end
|
||||
|
||||
@interface GCDWebServerFileResponse : GCDWebServerResponse {
|
||||
|
||||
@@ -245,11 +245,12 @@
|
||||
|
||||
if ((self = [super initWithContentType:type contentLength:info.st_size])) {
|
||||
_path = [path copy];
|
||||
if (attachment) {
|
||||
NSData* data = [[path lastPathComponent] dataUsingEncoding:NSISOLatin1StringEncoding allowLossyConversion:YES]; // ISO 8859-1
|
||||
NSString* fileName = data ? [[[NSString alloc] initWithData:data encoding:NSISOLatin1StringEncoding] autorelease] : nil;
|
||||
if (attachment) { // TODO: Use http://tools.ietf.org/html/rfc5987 to encode file names with special characters instead of using lossy conversion to ISO 8859-1
|
||||
NSData* data = [[path lastPathComponent] dataUsingEncoding:NSISOLatin1StringEncoding allowLossyConversion:YES];
|
||||
NSString* fileName = data ? [[NSString alloc] initWithData:data encoding:NSISOLatin1StringEncoding] : nil;
|
||||
if (fileName) {
|
||||
[self setValue:[NSString stringWithFormat:@"attachment; filename=\"%@\"", fileName] forAdditionalHeader:@"Content-Disposition"]; // TODO: Use http://tools.ietf.org/html/rfc5987
|
||||
[self setValue:[NSString stringWithFormat:@"attachment; filename=\"%@\"", fileName] forAdditionalHeader:@"Content-Disposition"];
|
||||
[fileName release];
|
||||
} else {
|
||||
DNOT_REACHED();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user