diff --git a/QCJSON/QCJSONPlugIn.h b/QCJSON/QCJSONPlugIn.h index 7eeabec..b73d54f 100644 --- a/QCJSON/QCJSONPlugIn.h +++ b/QCJSON/QCJSONPlugIn.h @@ -18,6 +18,7 @@ NSString *_JSONLocation; NSDictionary *_HTTPHeaders; + NSString *_bodyString; NSDictionary *_parsedJSON; double _downloadProgress; @@ -27,6 +28,7 @@ @property (assign) NSString *inputJSONLocation; @property (assign) NSDictionary *inputHTTPHeaders; +@property (assign) NSString *inputBodyString; @property (assign) BOOL inputUpdateSignal; @property (assign) NSDictionary *outputParsedJSON; diff --git a/QCJSON/QCJSONPlugIn.m b/QCJSON/QCJSONPlugIn.m index fad12a1..cecd724 100644 --- a/QCJSON/QCJSONPlugIn.m +++ b/QCJSON/QCJSONPlugIn.m @@ -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; @@ -45,6 +46,7 @@ @implementation QCJSONPlugIn @dynamic inputJSONLocation; @dynamic inputHTTPHeaders; +@dynamic inputBodyString; @dynamic inputUpdateSignal; @dynamic outputParsedJSON; @@ -59,6 +61,7 @@ @implementation QCJSONPlugIn @synthesize JSONLocation = _JSONLocation; @synthesize HTTPHeaders = _HTTPHeaders; +@synthesize bodyString = _bodyString; @synthesize parsedJSON = _parsedJSON; @synthesize downloadProgress = _downloadProgress; @@ -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" }; @@ -162,6 +170,7 @@ - (void)dealloc self.error = nil; self.HTTPHeaders = nil; + self.bodyString = nil; self.JSONLocation = nil; [super dealloc]; @@ -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; @@ -375,6 +390,7 @@ - (BOOL)execute:(id)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]; }