Switches from GCDWebServer to CocoaHTTPServer so we can have HTTPS eventually
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import "MBIMMessagesListOperation.h"
|
||||
#import "MBIMHTTPUtilities.h"
|
||||
|
||||
#import <IMCore/IMCore.h>
|
||||
|
||||
@@ -21,9 +22,9 @@
|
||||
|
||||
- (void)main
|
||||
{
|
||||
GCDWebServerResponse *response = nil;
|
||||
NSObject<HTTPResponse> *response = nil;
|
||||
do {
|
||||
NSURLComponents *urlComponents = [NSURLComponents componentsWithURL:[self.request URL] resolvingAgainstBaseURL:NO];
|
||||
NSURLComponents *urlComponents = [NSURLComponents componentsWithURL:self.requestURL resolvingAgainstBaseURL:NO];
|
||||
|
||||
NSString *guid = nil;
|
||||
for (NSURLQueryItem *queryItem in [urlComponents queryItems]) {
|
||||
@@ -35,14 +36,14 @@
|
||||
|
||||
if (!guid) {
|
||||
NSLog(@"No query item provided");
|
||||
response = [GCDWebServerDataResponse responseWithStatusCode:500];
|
||||
response = [[HTTPErrorResponse alloc] initWithErrorCode:500];
|
||||
break;
|
||||
}
|
||||
|
||||
IMChat *chat = [sChatRegistry existingChatWithGUID:guid];
|
||||
if (!chat) {
|
||||
NSLog(@"Chat with guid: %@ not found", guid);
|
||||
response = [GCDWebServerDataResponse responseWithStatusCode:500];
|
||||
response = [[HTTPErrorResponse alloc] initWithErrorCode:500];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -53,12 +54,12 @@
|
||||
for (IMMessageItem *imMessage in [[chat chatItems] messages]) {
|
||||
NSMutableDictionary *messageDict = [NSMutableDictionary dictionary];
|
||||
messageDict[@"text"] = [[imMessage body] string];
|
||||
messageDict[@"date"] = GCDWebServerFormatRFC822([imMessage time]);
|
||||
messageDict[@"date"] = MBIMWebServerFormatRFC822([imMessage time]);
|
||||
messageDict[@"sender"] = [imMessage sender];
|
||||
[messages addObject:messageDict];
|
||||
}
|
||||
|
||||
response = [GCDWebServerDataResponse responseWithJSONObject:messages];
|
||||
response = [MBIMJSONDataResponse responseWithJSONObject:messages];
|
||||
} while (0);
|
||||
|
||||
self.serverCompletionBlock(response);
|
||||
|
||||
Reference in New Issue
Block a user