[OGo-Developer] NSURL different in libFoundation and GNUstep base?

Helge Hess developer@opengroupware.org
Sun, 13 Apr 2008 11:43:19 +0200


On 13.04.2008, at 09:16, Sebastian Reitenbach wrote:
> i try to create a NSURL and then to retrieve some data from it. This  
> is
> working with my test program on gnustep-base, but not with  
> libFoundation.

lF itself has no HTTP support. You can use WOHTTPConnection,  
WORequest, WOResponse.

>  URLString = [URLString
> stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

Convention is to use lowercase names for variables, eg:
   urlString

For escaping you can find NSString methods in NGExtensions (those work  
on all Foundations).

> Apr 13 07:00:50 getcoords [13768]: -[NSURL URLHandleUsingCache:]:  
> missing
> handler for URL '<_NSAbsoluteHTTPURL
^^^error

> libFoundation adds a :80 to the end of the URL, I wonder why, and  
> whether
> this is the problem?

Because your escaping code is b0rked. You escape almost the whole URL:

  URLString = [URLString stringByEscapingURL];
  URLString = [@"http://" stringByAppendingString:URLString];

How is that supposed to work? (you put everything in the hostname ...)

You always need to escape the components of an URL individually. This  
is also true for the path, btw (escaping the whole path will escape  
the '/', hence, it will result in a single resource name!).

Helge
-- 
Helge Hess
http://www.helgehess.eu/