Private
Public Access
1
0

Attachments support!

This commit is contained in:
James Magahern
2018-11-21 01:38:43 -07:00
parent 4f5cd058c5
commit 3186f1948a
8 changed files with 168 additions and 11 deletions

View File

@@ -0,0 +1,18 @@
//
// MBIMDataResponse.h
// kordophoned
//
// Created by James Magahern on 11/20/18.
// Copyright © 2018 James Magahern. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CocoaHTTPServer/HTTPDataResponse.h>
NS_ASSUME_NONNULL_BEGIN
@interface MBIMDataResponse : HTTPDataResponse
- (instancetype)initWithData:(NSData *)data contentType:(NSString *)contentType;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,32 @@
//
// MBIMDataResponse.m
// kordophoned
//
// Created by James Magahern on 11/20/18.
// Copyright © 2018 James Magahern. All rights reserved.
//
#import "MBIMDataResponse.h"
@implementation MBIMDataResponse {
NSString *_contentType;
}
- (instancetype)initWithData:(NSData *)data contentType:(NSString *)contentType
{
self = [super initWithData:data];
if (self) {
_contentType = contentType;
}
return self;
}
- (NSDictionary *)httpHeaders
{
return @{
@"Content-Type" : _contentType
};
}
@end

View File

@@ -7,9 +7,9 @@
//
#import <Foundation/Foundation.h>
#import <CocoaHTTPServer/HTTPDataResponse.h>
#import "MBIMDataResponse.h"
@interface MBIMJSONDataResponse : HTTPDataResponse
@interface MBIMJSONDataResponse : MBIMDataResponse
+ (instancetype)responseWithJSONObject:(id)object;

View File

@@ -17,16 +17,8 @@
return nil;
}
MBIMJSONDataResponse *response = [[self alloc] initWithData:data];
MBIMJSONDataResponse *response = [[self alloc] initWithData:data contentType:@"application/json; charset=utf-8"];
return response;
}
- (NSDictionary *)httpHeaders
{
return @{
@"Content-Type" : @"application/json; charset=utf-8"
};
}
@end