mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
add NSURLConnection chunked test and tidy up a bit
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34901 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
719178bc2e
commit
e6d6db7df8
2 changed files with 39 additions and 5 deletions
|
@ -138,8 +138,8 @@
|
|||
else
|
||||
{
|
||||
unsigned char buffer[BUFSIZ];
|
||||
int readSize;
|
||||
readSize = [inStream read: buffer maxLength: BUFSIZ];
|
||||
|
||||
(void)[inStream read: buffer maxLength: BUFSIZ];
|
||||
// make outStream available for writing
|
||||
[outStream scheduleInRunLoop: runLoop
|
||||
forMode: NSDefaultRunLoopMode];
|
||||
|
|
|
@ -17,14 +17,12 @@ int main()
|
|||
NSMutableString *m;
|
||||
NSTask *t;
|
||||
NSString *helpers;
|
||||
NSString *capture;
|
||||
NSString *respond;
|
||||
NSString *keepalive;
|
||||
|
||||
helpers = [[NSFileManager defaultManager] currentDirectoryPath];
|
||||
helpers = [helpers stringByAppendingPathComponent: @"Helpers"];
|
||||
helpers = [helpers stringByAppendingPathComponent: @"obj"];
|
||||
capture = [helpers stringByAppendingPathComponent: @"capture"];
|
||||
keepalive = [helpers stringByAppendingPathComponent: @"keepalive"];
|
||||
respond = [helpers stringByAppendingPathComponent: @"respond"];
|
||||
|
||||
|
@ -50,12 +48,48 @@ int main()
|
|||
data = [u resourceDataUsingCache: NO];
|
||||
// Get status code
|
||||
str = [u propertyForKey: NSHTTPPropertyStatusCodeKey];
|
||||
PASS([data isEqual: cont], "chunked test OK");
|
||||
PASS([data isEqual: cont], "NSURL chunked test OK");
|
||||
// Wait for server termination
|
||||
[t terminate];
|
||||
[t waitUntilExit];
|
||||
}
|
||||
|
||||
t = [NSTask launchedTaskWithLaunchPath: keepalive
|
||||
arguments: [NSArray arrayWithObjects:
|
||||
@"-FileName", @"Chunked.dat",
|
||||
@"-FileHdrs", @"YES", // Headers are in file
|
||||
@"-Port", @"54321",
|
||||
@"-Count", @"1",
|
||||
nil]];
|
||||
if (t != nil)
|
||||
{
|
||||
NSURLRequest *request;
|
||||
NSHTTPURLResponse *response;
|
||||
NSError *error;
|
||||
const char *lit = "This is the data in the first chunk\r\n"
|
||||
"and this is the second one\r\n"
|
||||
"consequence";
|
||||
|
||||
cont = [NSData dataWithBytes: lit length: strlen(lit)];
|
||||
|
||||
// Pause to allow server subtask to set up.
|
||||
[NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.5]];
|
||||
u = [NSURL URLWithString: @"http://localhost:54321/chunked"];
|
||||
|
||||
request = [NSURLRequest requestWithURL: u];
|
||||
response = nil;
|
||||
data = [NSURLConnection sendSynchronousRequest: request
|
||||
returningResponse: &response
|
||||
error: &error];
|
||||
// Get status code
|
||||
PASS(response != nil && [response statusCode] > 0,
|
||||
"NSURLConnection synchronous load returns a response");
|
||||
|
||||
PASS([data isEqual: cont], "NSURLConnection chunked test OK");
|
||||
// Wait for server termination
|
||||
[t terminate];
|
||||
[t waitUntilExit];
|
||||
}
|
||||
|
||||
url = [NSURL URLWithString: @"http://localhost:54321/"];
|
||||
|
||||
|
|
Loading…
Reference in a new issue