gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSURLConnection and SSL


From: Fred Kiefer
Subject: Re: NSURLConnection and SSL
Date: Wed, 10 Apr 2013 09:38:37 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5

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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]