Fixup to perform a full load

This commit is contained in:
Richard Frith-Macdonald 2021-02-15 21:20:22 +00:00
parent 4b5e342c89
commit e6c387f8fd

View file

@ -67,7 +67,7 @@ resourceDataDidBecomeAvailable: (NSData *)newBytes
{ {
[_receivedData release]; [_receivedData release];
} }
_receivedData = newBytes; _receivedData = [newBytes retain];
} }
- (void) URLHandle: (NSURLHandle *)sender - (void) URLHandle: (NSURLHandle *)sender
@ -108,7 +108,7 @@ resourceDidFailLoadingWithReason: (NSString *)reason
[handle beginLoadInBackground]; [handle beginLoadInBackground];
[handle cancelLoadInBackground]; [handle cancelLoadInBackground];
PASS([self status] == URLHandleClientDidCancelLoading, PASS([self status] == URLHandleClientDidCancelLoading,
"URLHandleResourceDidCancelLoading called"); "URLHandleClientDidCancelLoading called");
[handle release]; [handle release];
handle = [[cls alloc] initWithURL: url cached: NO]; handle = [[cls alloc] initWithURL: url cached: NO];
@ -118,16 +118,22 @@ resourceDidFailLoadingWithReason: (NSString *)reason
*/ */
[handle writeProperty: @"POST" forKey: GSHTTPPropertyMethodKey]; [handle writeProperty: @"POST" forKey: GSHTTPPropertyMethodKey];
[handle writeData: [@"Hello" dataUsingEncoding: NSASCIIStringEncoding]]; [handle writeData: [@"Hello" dataUsingEncoding: NSASCIIStringEncoding]];
[handle setReturnAll: YES];
[handle loadInBackground]; [handle loadInBackground];
PASS([self status] == URLHandleClientDidBeginLoading, PASS([self status] == URLHandleClientDidBeginLoading,
"URLHandleResourceDidBeginLoading called"); "URLHandleClientDidBeginLoading called");
[[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode NSDate *limit = [NSDate dateWithTimeIntervalSinceNow: 5.0];
beforeDate: [NSDate dateWithTimeIntervalSinceNow: 1.0]]; while ([limit timeIntervalSinceNow] > 0.0
PASS([self status] == URLHandleClientDidBeginLoading, && [self status] != URLHandleClientDidFinishLoading)
"URLHandleResourceDidFinishLoading called"); {
[[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode
beforeDate: limit];
}
PASS([self status] == URLHandleClientDidFinishLoading,
"URLHandleClientDidFinishLoading called");
NSLog(@"Data %@", [handle availableResourceData]);
[handle release]; [handle release];
return 0; return 0;
} }