Index: src/OFHTTPRequest.m ================================================================== --- src/OFHTTPRequest.m +++ src/OFHTTPRequest.m @@ -153,18 +153,18 @@ if (requestType == OF_HTTP_REQUEST_TYPE_HEAD) t = "HEAD"; if (requestType == OF_HTTP_REQUEST_TYPE_POST) t = "POST"; - if ((path = [URL path]) == nil) - path = @""; + if ([(path = [URL path]) isEqual: @""]) + path = @"/"; if ([URL query] != nil) - [sock writeFormat: @"%s /%@?%@ HTTP/1.0\r\n", + [sock writeFormat: @"%s %@?%@ HTTP/1.0\r\n", t, path, [URL query]]; else - [sock writeFormat: @"%s /%@ HTTP/1.0\r\n", t, path]; + [sock writeFormat: @"%s %@ HTTP/1.0\r\n", t, path]; if ([URL port] == 80) [sock writeFormat: @"Host: %@\r\n", [URL host]]; else [sock writeFormat: @"Host: %@:%d\r\n", [URL host], Index: src/OFURL.m ================================================================== --- src/OFURL.m +++ src/OFURL.m @@ -197,12 +197,13 @@ parameters = [[OFString alloc] initWithCString: tmp + 1]; } - path = [[OFString alloc] initWithCString: str_c]; - } + path = [[OFString alloc] initWithFormat: @"/%s", str_c]; + } else + path = @""; } @catch (id e) { [self release]; @throw e; } @finally { free(str_c2); @@ -252,11 +253,11 @@ parameters = [[OFString alloc] initWithCString: tmp + 1]; } if (*str_c == '/') - path = [[OFString alloc] initWithCString: str_c + 1]; + path = [[OFString alloc] initWithCString: str_c]; else { OFAutoreleasePool *pool; OFString *s; pool = [[OFAutoreleasePool alloc] init]; @@ -437,11 +438,18 @@ return [[path copy] autorelease]; } - (void)setPath: (OFString*)path_ { - OFString *old = path; + OFString *old; + + if (([scheme isEqual: @"http"] || [scheme isEqual: @"https"]) && + ![path_ hasPrefix: @"/"]) + @throw [OFInvalidArgumentException newWithClass: isa + selector: _cmd]; + + old = path; path = [path_ copy]; [old release]; } - (OFString*)parameters @@ -503,12 +511,11 @@ needPort = NO; if (needPort) [desc appendFormat: @":%d", port]; - if (path != nil) - [desc appendFormat: @"/%@", path]; + [desc appendString: path]; if (parameters != nil) [desc appendFormat: @";%@", parameters]; if (query != nil) Index: tests/OFURLTests.m ================================================================== --- tests/OFURLTests.m +++ tests/OFURLTests.m @@ -63,11 +63,11 @@ TEST(@"-[password]", [[u1 password] isEqual: @"p"] && [u4 password] == nil) TEST(@"-[host]", [[u1 host] isEqual: @"h"] && [u4 port] == 0) TEST(@"-[port]", [u1 port] == 1234) TEST(@"-[path]", - [[u1 path] isEqual: @"f"] && [[u4 path] isEqual: @"/etc/passwd"]) + [[u1 path] isEqual: @"/f"] && [[u4 path] isEqual: @"/etc/passwd"]) TEST(@"-[parameters]", [[u1 parameters] isEqual: @"p"] && [u4 parameters] == nil) TEST(@"-[query]", [[u1 query] isEqual: @"q"] && [u4 query] == nil) TEST(@"-[fragment]", [[u1 fragment] isEqual: @"f"] && [u4 fragment] == nil)