Index: base/NSURL/Helpers/respond.m =================================================================== --- base/NSURL/Helpers/respond.m (revision 24166) +++ base/NSURL/Helpers/respond.m (working copy) @@ -11,6 +11,7 @@ BOOL writable; unsigned writeLen; unsigned count; + double pause; } - (int) runTest; @end @@ -44,6 +45,8 @@ count = [[defs stringForKey: @"Count"] intValue]; if (count == 0) count = 1; + pause = [[defs stringForKey: @"Pause"] doubleValue]; + file = [defs stringForKey: @"FileName"]; if (file == nil) file = @"Respond.dat"; content = [[NSData alloc] initWithContentsOfFile: file]; @@ -170,12 +173,20 @@ length = writeLen; } - /* Just pause for a very short time to try to stop the operating - * system from combining individual writes ... because we want - * the remote end to have to deal with separate reads. - */ - [NSThread sleepUntilDate: - [NSDate dateWithTimeIntervalSinceNow: 0.0001]]; + /* We now pause for the time (in sec) specified. Even if + * the time is zero we still have a small pause, to try to + * coerce the OS into separating the write events. + */ + if (pause == 0) + { + [NSThread sleepUntilDate: + [NSDate dateWithTimeIntervalSinceNow: 0.0001]]; + } + else + { + [NSThread sleepUntilDate: + [NSDate dateWithTimeIntervalSinceNow: pause]]; + } length = [op write: [content bytes] + written maxLength: length]; if (length <= 0) Index: base/NSURL/test00.m =================================================================== --- base/NSURL/test00.m (revision 24166) +++ base/NSURL/test00.m (working copy) @@ -6,7 +6,7 @@ int main() { CREATE_AUTORELEASE_POOL(arp); - unsigned i; + unsigned i, j; NSURL *url; NSData *data; NSMutableData *resp; @@ -78,38 +78,41 @@ [resp writeToFile: @"SimpleResponse.dat" atomically: YES]; str = [NSString stringWithFormat: @"%u", [resp length]]; - t = [NSTask launchedTaskWithLaunchPath: respond - arguments: [NSArray arrayWithObjects: - @"-FileName", @"SimpleResponse.dat", - @"-Count", @"4", - nil]]; - url = [NSURL URLWithString: @"http://localhost:4321/"]; - if (t != nil) + + for (j=0; j<13; j+=4) { - // Pause to allow server subtask to set up. - [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.5]]; - for (i = 0; i < 4; i++) + NSString *delay = [NSString stringWithFormat: @"%u", j]; + t = [NSTask launchedTaskWithLaunchPath: respond + arguments: [NSArray arrayWithObjects: + @"-FileName", @"SimpleResponse.dat", + @"-Count", @"4", @"-Pause", delay, + nil]]; + if (t != nil) { - NSAutoreleasePool *pool = [NSAutoreleasePool new]; - char buf[128]; + // Pause to allow server subtask to set up. + [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.5]]; + for (i = 0; i < 4; i++) + { + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + char buf[128]; - // Talk to server. - data = [url resourceDataUsingCache: NO]; - // Get status code - str = [url propertyForKey: NSHTTPPropertyStatusCodeKey]; - sprintf(buf, "respond with keepalive %d OK", i); - pass([data isEqual: cont], buf); - [pool release]; - /* Allow remote end time to close socket. - */ - [NSThread sleepUntilDate: - [NSDate dateWithTimeIntervalSinceNow: 0.01]]; - } - /* Kill helper task and wait for it to finish */ - [t terminate]; - [t waitUntilExit]; + // Talk to server. + data = [url resourceDataUsingCache: NO]; + // Get status code + str = [url propertyForKey: NSHTTPPropertyStatusCodeKey]; + sprintf(buf, "respond with keepalive %d OK", i); + pass([data isEqual: cont], buf); + [pool release]; + /* Allow remote end time to close socket. + */ + [NSThread sleepUntilDate: + [NSDate dateWithTimeIntervalSinceNow: 0.01]]; + } + /* Kill helper task and wait for it to finish */ + [t terminate]; + [t waitUntilExit]; + } } - DESTROY(arp); return 0; } Index: base/NSURL/basic.m =================================================================== --- base/NSURL/basic.m (revision 24166) +++ base/NSURL/basic.m (working copy) @@ -23,6 +23,9 @@ url = [NSURL fileURLWithPath: str]; pass([[url path] isEqual: str], "Can put a pound sign in a file URL"); + str = [url scheme]; + pass([str isEqual: @"file"], "Scheme of file URL is file"); + url = [NSURL URLWithString: @"http://www.w3.org/"]; data = [url resourceDataUsingCache: NO]; pass(data != nil, @@ -36,7 +39,16 @@ str = [url propertyForKey: NSHTTPPropertyStatusCodeKey]; pass([str isEqual: @"404"], "Status of load is 404 for www.w3.org/silly-file-name"); - + + str = [url scheme]; + pass([str isEqual: @"http"], + "Scheme of http://www.w3.org/silly-file-name is http"); + str = [url host]; + pass([str isEqual: @"www.w3.org"], + "Host of http://www.w3.org/silly-file-name is www.w3.org"); + str = [url path]; + pass([str isEqual: @"/silly-file-name"], + "Path of http://www.w3.org/silly-file-name is /silly-file-name"); DESTROY(arp); return 0; }