Hi Everyone:

I am writing a project for OS X, iOS and Linux, and a cross-platform lore 
library is called for. This following code works fine under both OS X and iOS, 
but are very problematic under Linux using GNUstep:

- (NSData *)dataWithData:(NSData *)data fromMethod:(NSString *)method 
error:(NSError *__autoreleasing *)error
{
    NSURL *methodURL = [NSURL URLWithString:method 
relativeToURL:self.serverRoot];
    
    NSMutableURLRequest *request = [NSMutableURLRequest 
requestWithURL:methodURL];
    
    if ([data length])
    {
        [request setHTTPMethod:@"POST"];
        [request setHTTPBody:data];
    }
    
    [request setValue:[self userAgent] forHTTPHeaderField:@"User-Agent"];
    
    NSError *err = nil;
    NSHTTPURLResponse *response = nil;
    
    NSData *responseData = [NSURLConnection sendSynchronousRequest:request
                                                 returningResponse:&response
                                                             error:&err];
    
    if (![responseData length])
    {
        WFAssignPointer(error, err);
        return nil;
    }
    
    if ([response statusCode] >= 400)
    {
        NSDictionary *userInfo = @{
                                   NSLocalizedDescriptionKey:
                                       
NSLocalizedStringFromTableInBundle(WFSTR(@"http%ld", [response statusCode]),
                                                                          
@"error",
                                                                          
WFThisBundle,
                                                                          @"")
                                   };
        err = [NSError errorWithDomain:WFErrorDoamin
                                  code:[response statusCode]
                              userInfo:userInfo];
        WFAssignPointer(error, err);
        return nil;
    }
    
    return responseData;
}

The methodURL is a HTTPS URL.

The call to [NSURLConnection sendSynchronousRequest:returningResponse:error] 
failed silently, making this code very confused.

Would anyone tell me what happened?
_______________________________________________
Gnustep-dev mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to