Re: NSURLConnection Problem Inside QuickLook Generator
Re: NSURLConnection Problem Inside QuickLook Generator
- Subject: Re: NSURLConnection Problem Inside QuickLook Generator
- From: Mike Abdullah <email@hidden>
- Date: Tue, 8 Dec 2009 12:09:04 +0000
I'm pretty certain Apple disallows use of non-file URLs in Quick Look generators for the simple reason that a generator should run as quickly as possible. Generators should also be fairly standalone - why do you need to POST to generate a preview/thumbnail?
On 8 Dec 2009, at 10:13, Dalmazio Brisinda wrote:
> I'm writing a QuickLook plugin that, as part of the preview process, makes an http call to a (localhost) server to obtain data that is then used to generate the preview image.
>
> The code below works fine outside the QuickLook architecture, as a standard Cocoa application. But as soon as I move the (exact) same code over to the QuickLook plugin, a call to the server only returns (null) response, and (null) data. The docs indicate that this means the connection is failing. But why o why is it failing?
>
> If I print the contents of the NSError object to the console, I get the following message:
>
> 09-12-08 3:02:05 AM quicklookd[37158] error: Error Domain=NSPOSIXErrorDomain Code=1 UserInfo=0x10049d880 "The operation couldn’t be completed. Operation not permitted"
>
> It appears that sendSynchronousRequest:... is not permitted. So why is this operation not permitted? And is there a workaround? Any help would be most appreciated.
>
> NSURL * url = [NSURL URLWithString:urlString];
> NSMutableURLRequest * request = [NSMutableURLRequest requestWithURL:url];
>
> [request setHTTPMethod:@"POST"];
> [request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]];
> [request setTimeoutInterval:5];
>
> NSError * error;
> NSURLResponse * response;
> NSData * data = [NSURLConnection sendSynchronousRequest:request
> returningResponse:&response error:&error];
>
> Best,
> Dalmazio
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden