On 09.04.2013 18:05, Maxthon Chan wrote:
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?

You understand that you will have to provide a full working example which allows somebody else to reproduce your problem? The best thing to do is write a very simple example that reproduces the issue.

And please, make sure that you are using a current version of base.



_______________________________________________
Gnustep-dev mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to