discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Basic HTTP Authentication with Objective-C


From: Andreas Höschler
Subject: Basic HTTP Authentication with Objective-C
Date: Tue, 13 Aug 2013 15:52:06 +0200

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 = "" 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?

Thanks a lot in advance!

Andreas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]