Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions QCJSON/QCJSONPlugIn.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

NSString *_JSONLocation;
NSDictionary *_HTTPHeaders;
NSString *_bodyString;

NSDictionary *_parsedJSON;
double _downloadProgress;
Expand All @@ -27,6 +28,7 @@

@property (assign) NSString *inputJSONLocation;
@property (assign) NSDictionary *inputHTTPHeaders;
@property (assign) NSString *inputBodyString;
@property (assign) BOOL inputUpdateSignal;

@property (assign) NSDictionary *outputParsedJSON;
Expand Down
18 changes: 17 additions & 1 deletion QCJSON/QCJSONPlugIn.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ + (NSBundle *)bundle;

@property (copy) NSString *JSONLocation;
@property (copy) NSDictionary *HTTPHeaders;
@property (copy) NSString *bodyString;

@property (strong) NSDictionary *parsedJSON;
@property (assign) double downloadProgress;
Expand All @@ -45,6 +46,7 @@ @implementation QCJSONPlugIn

@dynamic inputJSONLocation;
@dynamic inputHTTPHeaders;
@dynamic inputBodyString;
@dynamic inputUpdateSignal;

@dynamic outputParsedJSON;
Expand All @@ -59,6 +61,7 @@ @implementation QCJSONPlugIn

@synthesize JSONLocation = _JSONLocation;
@synthesize HTTPHeaders = _HTTPHeaders;
@synthesize bodyString = _bodyString;

@synthesize parsedJSON = _parsedJSON;
@synthesize downloadProgress = _downloadProgress;
Expand Down Expand Up @@ -90,7 +93,12 @@ + (NSDictionary *)attributesForPropertyPortWithKey:(NSString *)key
{
return @{ QCPortAttributeNameKey: @"HTTP Headers" };
}


if([key isEqualToString:@"inputBodyString"])
{
return @{ QCPortAttributeNameKey: @"Body String" };
}

if([key isEqualToString:QCJSONPlugInInputUpdateSignal])
{
return @{ QCPortAttributeNameKey: @"Update Signal" };
Expand Down Expand Up @@ -162,6 +170,7 @@ - (void)dealloc
self.error = nil;

self.HTTPHeaders = nil;
self.bodyString = nil;
self.JSONLocation = nil;

[super dealloc];
Expand Down Expand Up @@ -249,6 +258,12 @@ - (void)startConnection
[request setValue:value forHTTPHeaderField:key];
}

if ([self.bodyString length])
{
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[self.bodyString dataUsingEncoding:NSUTF8StringEncoding]];
}

self.connection = [NSURLConnection connectionWithRequest:request delegate:self];

self.downloadProgress = 0.0;
Expand Down Expand Up @@ -375,6 +390,7 @@ - (BOOL)execute:(id<QCPlugInContext>)context atTime:(NSTimeInterval)time withArg
{
self.JSONLocation = self.inputJSONLocation;
self.HTTPHeaders = self.HTTPHeaders;
self.bodyString = self.inputBodyString;

[self performSelector:@selector(startConnection) onThread:self.connectionThread withObject:nil waitUntilDone:NO];
}
Expand Down