Add JSON payload to webmail "headers" action

pull/91/head
Francis Lachapelle 2014-11-25 09:57:08 -05:00
parent 7e11806bf9
commit 1c9da902d3
1 changed files with 10 additions and 4 deletions

View File

@ -759,19 +759,25 @@
- (id <WOActionResults>) getHeadersAction
{
NSArray *uids, *headers;
NSDictionary *data;
WORequest *request;
WOResponse *response;
request = [context request];
if ([request formValueForKey: @"uids"] == nil)
data = [[request contentAsString] objectFromJSONString];
if (![[data objectForKey: @"uids"] isKindOfClass: [NSArray class]]
|| [[data objectForKey: @"uids"] count] == 0)
{
return [NSException exceptionWithHTTPStatus: 404
reason: @"No UID specified"];
data = [NSDictionary dictionaryWithObjectsAndKeys:
@"No UID specified", @"error", nil];
return [self responseWithStatus: 404 /* Not Found */
andString: [data jsonRepresentation]];
}
uids = [[request formValueForKey: @"uids"] componentsSeparatedByString: @","]; // Should we support ranges? ie "x-y"
uids = [data objectForKey: @"uids"];
headers = [self getHeadersForUIDs: uids
inFolder: [self clientObject]];
response = [context response];
[response setHeader: @"application/json; charset=utf-8"
forKey: @"content-type"];