After a quick look through the RFC, it looks like NSURLConnection won't quite be able to meet your needs out of the box. As I understand it, what you need to happen is to take the ipp:// request and turn it into a modified HTTP request as per the spec.
I suggest you read up on NSURLProtocol and implement your own custom protocol for ipp:// URLs. It sounds like you should be able to set it up to construct an http:// URL and pass that along, but if not, the CFHTTP functions aren't too hard to get acquainted with. Mike. On 15 Dec 2009, at 22:22, Development wrote: > I am trying to post data to NSString * url = [NSString > stringWithFormat:@"ipp://%@:%i/%@",host,[service port],item]; > Which as you can see is an ipp address. However the code below fails as I get > an error from the NSError that I am using an unsupported url. Obviously if I > send it as http:// all I get is the cups page. So the question then is how to > format this url or how to send the request. > > > NSMutableData * sendData= [[NSMutableData alloc]init]; > NSMutableData * body= [[NSMutableData alloc]init]; > NSString * boundry = @"@@##$$rew**&&^%^"; > > NSInputStream* stream = [[[NSInputStream alloc]initWithData:imageData] > retain]; > [body appendData:[[NSString > stringWithFormat:@"-...@\r\n",boundry]dataUsingEncoding:NSUTF8StringEncoding]]; > [body appendData:[@"Content-Type: image/png\r\n\r\n" > dataUsingEncoding:NSUTF8StringEncoding]]; > [body appendData:imageData]; > [body appendData:[[NSString > stringWithFormat:@"\r\n...@--\r\n",boundry]dataUsingEncoding:NSUTF8StringEncoding]]; > > //int totalSize =[body length]; > > [sendData appendData:body]; > NSMutableURLRequest* post = [NSMutableURLRequest requestWithURL: [NSURL > URLWithString:path]]; > > [post addValue: @"application/ipp; boundary=@@##$$rew**&&^%^" > forHTTPHeaderField: @"Content-Type"]; > [post setHTTPBodyStream:stream]; > [post setHTTPMethod: @"POST"]; > [post setHTTPBody:sendData]; > NSURLResponse* response; > NSError* error; > NSLog(@"Sending request now %@",[NSURL URLWithString:path]); > NSLog(@"Scheme: %@",[[NSURL URLWithString:path]scheme]); > NSLog(@"Port %@",[[NSURL URLWithString:path]port]); > NSData* result = [NSURLConnection sendSynchronousRequest:post > returningResponse:&response error:&error]; > NSString * incoming = [[[NSString alloc] initWithData:result > encoding:NSASCIIStringEncoding] autorelease]; > > _______________________________________________ > > Cocoa-dev mailing list ([email protected]) > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net > > This email sent to [email protected] _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
