Am 13.08.2013 um 15:52 schrieb Andreas Höschler <[email protected]>:
> Hi all, > > I need an Objective-C (GNUstep) wrapper for accessing the OpenStreetMap API, > basically an Objective-C replacement for > > curl -v -H 'Authorization: Basic bXl1c2VybmFtZTpteXBhc3N3b3Jk' > 'http://api.openstreetmap.org/path' > > I do successfully access the API for read only calls that do not require > authentication like so > > #define IPADDRESS @"api.openstreetmap.org" > > SRFileHandle *handle = [[SRFileHandle alloc] > initAsClientAtAddress:IPADDRESS port:80]; > NSString *request = @"GET /api/capabilities\n"; > [handle writeData:[request dataUsingEncoding:NSUTF8StringEncoding]]; > NSData *data = [handle readDataToEndOfFile]; > NSString *xmlString = [[NSString alloc] initWithData:data > encoding:NSUTF8StringEncoding]; > [handle closeFile]; > [handle release]; > > NSLog(@"xmlString: %@", xmlString); > > Any idea how this could be extended to include Basic HTTP Authentication for > PUT calls like > > PUT /api/0.6/changeset/create > > Googling got me lots of NSURL, addRequestHeader,... stuff, but I don't have > all these fancy new classes in my (rather old) GNUstep tree. Anyone? I'd go with NSURLConnection and a NSMutableURLRequest that you set the authentication header using -setValue:forHTTPHeaderField:. If it's not in your GNUstep tree, that would indicate that it is pretty ancient, svn tells me that it been there since 2006, so it should really work. I think you should also be able to use the NSURLAuthenticationChallenge/NSURLCredential stuff, but I've not used it on GNUstep recently. Cheers, Niels
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ Discuss-gnustep mailing list [email protected] https://lists.gnu.org/mailman/listinfo/discuss-gnustep
