EzDevInfo.com

asi-http-request

Easy to use CFNetwork wrapper for HTTP requests, Objective-C, Mac OS X and iPhone ASIHTTPRequest Documentation - All-Seeing Interactive an easy to use wrapper around cfnetwork http api, mac os x & iphone

Asihttprequest 61 errors

I'm using the ASIhttprequest in many projects but recently with each new project when I'm trying to add the ASIhttprequest classes I get the following error before using classes just when I'm trying to import them:

Build finjan of project finjan with configuration Debug

Ld build/Debug-iphonesimulator/finjan.app/finjan normal i386
cd /Users/Apple/Desktop/application/finjan
setenv MACOSX_DEPLOYMENT_TARGET 10.5
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk -L/Users/Apple/Desktop/application/finjan/build/Debug-iphonesimulator -F/Users/Apple/Desktop/application/finjan/build/Debug-iphonesimulator -filelist /Users/Apple/Desktop/application/finjan/build/finjan.build/Debug-iphonesimulator/finjan.build/Objects-normal/i386/finjan.LinkFileList -mmacosx-version-min=10.5 -framework Foundation -framework UIKit -framework CoreGraphics -framework AudioToolbox -framework AVFoundation -o /Users/Apple/Desktop/application/finjan/build/Debug-iphonesimulator/finjan.app/finjan

Undefined symbols:
  "_CFHTTPAuthenticationIsValid", referenced from:
      -[ASIHTTPRequest attemptToApplyProxyCredentialsAndResume] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyCredentialsAndResume] in ASIHTTPRequest.o
  "_CFHTTPMessageApplyCredentialDictionary", referenced from:
      -[ASIHTTPRequest applyAuthorizationHeader] in ASIHTTPRequest.o
      -[ASIHTTPRequest applyAuthorizationHeader] in ASIHTTPRequest.o
      -[ASIHTTPRequest applyProxyCredentials:] in ASIHTTPRequest.o
      -[ASIHTTPRequest applyCredentials:] in ASIHTTPRequest.o
  "_CFHTTPMessageIsHeaderComplete", referenced from:
      -[ASIHTTPRequest readResponseHeaders] in ASIHTTPRequest.o
  "_kCFStreamPropertyHTTPSProxyPort", referenced from:
      _kCFStreamPropertyHTTPSProxyPort$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPSProxyPort$non_lazy_ptr)
  "_inflate", referenced from:
      +[ASIHTTPRequest uncompressZippedData:] in ASIHTTPRequest.o
      +[ASIHTTPRequest uncompressZippedDataFromSource:toDestination:] in ASIHTTPRequest.o
  "_kCFStreamSSLCertificates", referenced from:
      _kCFStreamSSLCertificates$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamSSLCertificates$non_lazy_ptr)
  "_CFNetworkCopyProxiesForAutoConfigurationScript", referenced from:
      +[ASIHTTPRequest proxiesForURL:fromPAC:] in ASIHTTPRequest.o
  "_kCFProxyTypeKey", referenced from:
      _kCFProxyTypeKey$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFProxyTypeKey$non_lazy_ptr)
  "_CFReadStreamCreateForStreamedHTTPRequest", referenced from:
      -[ASIHTTPRequest startRequest] in ASIHTTPRequest.o
      -[ASIHTTPRequest startRequest] in ASIHTTPRequest.o
  "_kCFProxyPortNumberKey", referenced from:
      _kCFProxyPortNumberKey$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFProxyPortNumberKey$non_lazy_ptr)
  "_kUTTagClassMIMEType", referenced from:
      _kUTTagClassMIMEType$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kUTTagClassMIMEType$non_lazy_ptr)
  "_inflateEnd", referenced from:
      +[ASIHTTPRequest uncompressZippedData:] in ASIHTTPRequest.o
      +[ASIHTTPRequest uncompressZippedDataFromSource:toDestination:] in ASIHTTPRequest.o
      +[ASIHTTPRequest uncompressZippedDataFromSource:toDestination:] in ASIHTTPRequest.o
      +[ASIHTTPRequest uncompressZippedDataFromSource:toDestination:] in ASIHTTPRequest.o
      +[ASIHTTPRequest uncompressZippedDataFromSource:toDestination:] in ASIHTTPRequest.o
  "_inflateInit2_", referenced from:
      +[ASIHTTPRequest uncompressZippedData:] in ASIHTTPRequest.o
      +[ASIHTTPRequest uncompressZippedDataFromSource:toDestination:] in ASIHTTPRequest.o
  "_kCFProxyAutoConfigurationURLKey", referenced from:
      _kCFProxyAutoConfigurationURLKey$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFProxyAutoConfigurationURLKey$non_lazy_ptr)
  "_CFHTTPAuthenticationRequiresUserNameAndPassword", referenced from:
      -[ASIHTTPRequest attemptToApplyProxyCredentialsAndResume] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyCredentialsAndResume] in ASIHTTPRequest.o
  "_kCFHTTPAuthenticationUsername", referenced from:
      _kCFHTTPAuthenticationUsername$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPAuthenticationUsername$non_lazy_ptr)
  "_kCFStreamPropertyHTTPProxy", referenced from:
      _kCFStreamPropertyHTTPProxy$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPProxyPort$non_lazy_ptr, _kCFStreamPropertyHTTPProxyHost$non_lazy_ptr , _kCFStreamPropertyHTTPProxy$non_lazy_ptr )
  "_kCFStreamPropertyHTTPResponseHeader", referenced from:
      _kCFStreamPropertyHTTPResponseHeader$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPResponseHeader$non_lazy_ptr)
  "_CFHTTPMessageGetResponseStatusCode", referenced from:
      -[ASIHTTPRequest readResponseHeaders] in ASIHTTPRequest.o
  "_kCFProxyTypeHTTP", referenced from:
      _kCFProxyTypeHTTP$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFProxyTypeHTTP$non_lazy_ptr)
  "_kCFHTTPAuthenticationSchemeBasic", referenced from:
      _kCFHTTPAuthenticationSchemeBasic$non_lazy_ptr in ASIAuthenticationDialog.o
      _kCFHTTPAuthenticationSchemeBasic$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPAuthenticationSchemeBasic$non_lazy_ptr)
  "_SCNetworkReachabilityScheduleWithRunLoop", referenced from:
      -[Reachability startNotifier] in Reachability.o
  "_SCNetworkReachabilityGetFlags", referenced from:
      -[Reachability currentReachabilityStatus] in Reachability.o
      -[Reachability isReachable] in Reachability.o
      -[Reachability isConnectionRequired] in Reachability.o
      -[Reachability isConnectionOnDemand] in Reachability.o
      -[Reachability isInterventionRequired] in Reachability.o
      -[Reachability isReachableViaWWAN] in Reachability.o
      -[Reachability isReachableViaWiFi] in Reachability.o
      -[Reachability reachabilityFlags] in Reachability.o
  "_deflateInit2_", referenced from:
      +[ASIHTTPRequest compressData:] in ASIHTTPRequest.o
      +[ASIHTTPRequest compressDataFromSource:toDestination:] in ASIHTTPRequest.o
  "_CFNetworkCopyProxiesForURL", referenced from:
      -[ASIHTTPRequest startRequest] in ASIHTTPRequest.o
      +[ASIHTTPRequest proxiesForURL:fromPAC:] in ASIHTTPRequest.o
  "_CFHTTPMessageSetHeaderFieldValue", referenced from:
      -[ASIHTTPRequest main] in ASIHTTPRequest.o
      -[ASIHTTPRequest checkRequestStatus] in ASIHTTPRequest.o
  "_kCFProxyTypeSOCKS", referenced from:
      _kCFProxyTypeSOCKS$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFProxyTypeSOCKS$non_lazy_ptr)
  "_kCFStreamPropertyHTTPAttemptPersistentConnection", referenced from:
      _kCFStreamPropertyHTTPAttemptPersistentConnection$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPAttemptPersistentConnection$non_lazy_ptr)
  "_CFHTTPMessageCopyVersion", referenced from:
      -[ASIHTTPRequest readResponseHeaders] in ASIHTTPRequest.o
  "_CFHTTPAuthenticationCopyRealm", referenced from:
      -[ASIHTTPRequest attemptToApplyProxyCredentialsAndResume] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyCredentialsAndResume] in ASIHTTPRequest.o
  "_CFHTTPMessageCopyAllHeaderFields", referenced from:
      -[ASIHTTPRequest readResponseHeaders] in ASIHTTPRequest.o
  "_CFHTTPMessageCreateRequest", referenced from:
      -[ASIHTTPRequest main] in ASIHTTPRequest.o
  "_kCFProxyHostNameKey", referenced from:
      _kCFProxyHostNameKey$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFProxyHostNameKey$non_lazy_ptr)
  "_kCFStreamPropertyHTTPProxyHost", referenced from:
      _kCFStreamPropertyHTTPProxyHost$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPProxyHost$non_lazy_ptr)
  "_CFHTTPMessageCopyResponseStatusLine", referenced from:
      -[ASIHTTPRequest readResponseHeaders] in ASIHTTPRequest.o
  "_kCFStreamPropertyHTTPRequestBytesWrittenCount", referenced from:
      _kCFStreamPropertyHTTPRequestBytesWrittenCount$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPRequestBytesWrittenCount$non_lazy_ptr)
  "_deflate", referenced from:
      +[ASIHTTPRequest compressData:] in ASIHTTPRequest.o
      +[ASIHTTPRequest compressDataFromSource:toDestination:] in ASIHTTPRequest.o
  "_SCNetworkReachabilityCreateWithAddress", referenced from:
      +[Reachability reachabilityWithAddress:] in Reachability.o
  "_kCFErrorDomainCFNetwork", referenced from:
      _kCFErrorDomainCFNetwork$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFErrorDomainCFNetwork$non_lazy_ptr)
  "_kCFStreamSSLValidatesCertificateChain", referenced from:
      _kCFStreamSSLValidatesCertificateChain$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamSSLValidatesCertificateChain$non_lazy_ptr)
  "_CFHTTPAuthenticationCreateFromResponse", referenced from:
      -[ASIHTTPRequest attemptToApplyProxyCredentialsAndResume] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyCredentialsAndResume] in ASIHTTPRequest.o
  "_deflateEnd", referenced from:
      +[ASIHTTPRequest compressData:] in ASIHTTPRequest.o
      +[ASIHTTPRequest compressDataFromSource:toDestination:] in ASIHTTPRequest.o
      +[ASIHTTPRequest compressDataFromSource:toDestination:] in ASIHTTPRequest.o
      +[ASIHTTPRequest compressDataFromSource:toDestination:] in ASIHTTPRequest.o
  "_UTTypeCopyPreferredTagWithClass", referenced from:
      +[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
  "_kCFStreamPropertyHTTPSProxyHost", referenced from:
      _kCFStreamPropertyHTTPSProxyHost$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPSProxyHost$non_lazy_ptr)
  "_kCFHTTPAuthenticationSchemeNTLM", referenced from:
      _kCFHTTPAuthenticationSchemeNTLM$non_lazy_ptr in ASIAuthenticationDialog.o
      _kCFHTTPAuthenticationSchemeNTLM$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPAuthenticationSchemeNTLM$non_lazy_ptr)
  "_CFHTTPAuthenticationCopyMethod", referenced from:
      -[ASIHTTPRequest attemptToApplyProxyCredentialsAndResume] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyCredentialsAndResume] in ASIHTTPRequest.o
  "_kCFHTTPAuthenticationAccountDomain", referenced from:
      _kCFHTTPAuthenticationAccountDomain$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPAuthenticationAccountDomain$non_lazy_ptr)
  "_UTTypeCreatePreferredIdentifierForTag", referenced from:
      +[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
  "_CFNetworkCopySystemProxySettings", referenced from:
      -[ASIHTTPRequest startRequest] in ASIHTTPRequest.o
  "_SCNetworkReachabilityUnscheduleFromRunLoop", referenced from:
      -[Reachability stopNotifier] in Reachability.o
  "_kCFStreamPropertyHTTPProxyPort", referenced from:
      _kCFStreamPropertyHTTPProxyPort$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPProxyPort$non_lazy_ptr)
  "_CFHTTPAuthenticationRequiresAccountDomain", referenced from:
      -[ASIHTTPRequest findProxyCredentials] in ASIHTTPRequest.o
      -[ASIHTTPRequest findCredentials] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyProxyCredentialsAndResume] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyCredentialsAndResume] in ASIHTTPRequest.o
  "_SCNetworkReachabilityCreateWithName", referenced from:
      +[Reachability reachabilityWithHostName:] in Reachability.o
  "_SCNetworkReachabilitySetCallback", referenced from:
      -[Reachability startNotifier] in Reachability.o
  "_kCFHTTPAuthenticationPassword", referenced from:
      _kCFHTTPAuthenticationPassword$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPAuthenticationPassword$non_lazy_ptr)
  "_kCFHTTPVersion1_0", referenced from:
      _kCFHTTPVersion1_0$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPVersion1_0$non_lazy_ptr)
  "_kCFHTTPVersion1_1", referenced from:
      _kCFHTTPVersion1_1$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPVersion1_1$non_lazy_ptr)
  "_kCFStreamPropertySSLSettings", referenced from:
      _kCFStreamPropertySSLSettings$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertySSLSettings$non_lazy_ptr)
  "_kCFStreamErrorDomainHTTP", referenced from:
      _kCFStreamErrorDomainHTTP$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamErrorDomainHTTP$non_lazy_ptr)
  "_CFReadStreamCreateForHTTPRequest", referenced from:
      -[ASIHTTPRequest startRequest] in ASIHTTPRequest.o
  "_kUTTagClassFilenameExtension", referenced from:
      _kUTTagClassFilenameExtension$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kUTTagClassFilenameExtension$non_lazy_ptr)
ld: symbol(s) not found
collect2: ld returned 1 exit status

What is causing this?


Source: (StackOverflow)

ASIHTTPRequest vs AFNetworking framework

I am about to develop an application for iPad and it has enormous amount of background thread network calls.

I would like to know which one will be better? ASIHTTPRequest still works but not maintained. However few sources says AFNetworking framework creates lots of complications.


Source: (StackOverflow)

Advertisements

What major ASIHTTPRequest features is AFNetworking missing?

With work having recently stopped on ASIHTTPRequest, it seems like attention is shifting to AFNetworking.

However, I've not yet found a good comparison of the features of the two libraries, so I don't know what I might lose if/when I switch over.

Major differences I've spotted so far are:

  1. AFNetworking has a much smaller code size (which is good)
  2. AFNetworking is being rapidly improved (so it may not yet be mature, may not have a stable API yet?)
  3. Both seem to have caching, though I've seen hints that because AFNetworking uses NSURLConnection it won't cache objects over 50K
  4. ASIHTTPRequest has very good support for manual & automatic (PAC) http proxies; I can't find any information on what level of support AFNetworking has for proxies
  5. AFNetworking requires iOS 4+, whereas ASIHTTPRequest works right back to iOS 2 (not really an issue for me, but it is an issue for some people)
  6. AFNetworking doesn't (yet) have a built in persistent cache, but there's a persistent cache which has a pending pull request: https://github.com/gowalla/AFNetworking/pull/25

Has anyone seen any good comparisons of the two libraries or any documented experiences of switching from one to the other?


Source: (StackOverflow)

Fix warning "Capturing [an object] strongly in this block is likely to lead to a retain cycle" in ARC-enabled code

In ARC enabled code, how to fix a warning about a potential retain cycle, when using a block-based API?

The warning:
Capturing 'request' strongly in this block is likely to lead to a retain cycle

produced by this snippet of code:

ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:...

[request setCompletionBlock:^{
    NSDictionary *jsonDictionary = [[CJSONDeserializer deserializer] deserialize:request.rawResponseData error:nil];
    // ...
    }];

Warning is linked to the use of the object request inside the block.


Source: (StackOverflow)

Generic approach to NSManagedObjectContext in multi-threaded application

I've read a number of posts here about NSManagedObjectContext and multi-threaded applications. I've also gone over the CoreDataBooks example to understand how separate threads require their own NSManagedObjectContext, and how a save operation gets merged with the main NSManagedObjectContext. I found the example to be good, but also too application specific. I'm trying to generalize this, and wonder if my approach is sound.

My approach is to have a generic function for fetching the NSManagedObjectContext for the current thread. The function returns the NSManagedObjectContext for the main thread, but will create a new one (or fetch it from a cache) if called from within a different thread. That goes as follows:

+(NSManagedObjectContext *)managedObjectContext {
    MyAppDelegate *delegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
    NSManagedObjectContext *moc = delegate.managedObjectContext;

    NSThread *thread = [NSThread currentThread];

    if ([thread isMainThread]) {
        return moc;
    }

    // a key to cache the context for the given thread
    NSString *threadKey = [NSString stringWithFormat:@"%p", thread];

    // delegate.managedObjectContexts is a mutable dictionary in the app delegate
    NSMutableDictionary *managedObjectContexts = delegate.managedObjectContexts;

    if ( [managedObjectContexts objectForKey:threadKey] == nil ) {
        // create a context for this thread
        NSManagedObjectContext *threadContext = [[[NSManagedObjectContext alloc] init] autorelease];
        [threadContext setPersistentStoreCoordinator:[moc persistentStoreCoordinator]];
        // cache the context for this thread
        [managedObjectContexts setObject:threadContext forKey:threadKey];
    }

    return [managedObjectContexts objectForKey:threadKey];
}

Save operations are simple if called from the main thread. Save operations called from other threads require merging within the main thread. For that I have a generic commit function:

+(void)commit {
    // get the moc for this thread
    NSManagedObjectContext *moc = [self managedObjectContext];

    NSThread *thread = [NSThread currentThread];

    if ([thread isMainThread] == NO) {
        // only observe notifications other than the main thread
        [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(contextDidSave:)
                                                 name:NSManagedObjectContextDidSaveNotification
                                               object:moc];
    }

    NSError *error;
    if (![moc save:&error]) {
        // fail
    }

    if ([thread isMainThread] == NO) {
        [[NSNotificationCenter defaultCenter] removeObserver:self 
                                                    name:NSManagedObjectContextDidSaveNotification 
                                                  object:moc];
    }
}

In the contextDidSave: function we perform the merge, if called by the notification in commit.

+(void)contextDidSave:(NSNotification*)saveNotification {
    MyAppDelegate *delegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
    NSManagedObjectContext *moc = delegate.managedObjectContext;

    [moc performSelectorOnMainThread:@selector(mergeChangesFromContextDidSaveNotification:)
                      withObject:saveNotification
                   waitUntilDone:YES];
}

Finally, we clean-up the cache of NSManagedObjectContext with this:

+(void)initialize {
    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(threadExit) 
                                                 name:NSThreadWillExitNotification 
                                               object:nil]; 
}

+(void)threadExit {
    MyAppDelegate *delegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
    NSString *threadKey = [NSString stringWithFormat:@"%p", [NSThread currentThread]];  
    NSMutableDictionary *managedObjectContexts = delegate.managedObjectContexts;    

    [managedObjectContexts removeObjectForKey:threadKey];
}

This compiles and seems to work, but I know threading problems can be tricky due to race conditions. Does anybody see a problem with this approach?

Also, I'm using this from within the context of an asynchronous request (using ASIHTTPRequest), which fetches some data from a server and updates and inserts the store on the iPhone. It seems NSThreadWillExitNotification doesn't fire after the request completes, and the same thread is then used for subsequent requests. This means the same NSManagedObjectContext is used for separate requests on the same thread. Is this a problem?


Source: (StackOverflow)

ASIHTTPRequest set timeout

How can I set the session timeout using ASIHTTPRequest ?

Thanks


Source: (StackOverflow)

Objective-C: Instance Variable in Category

I am just asking whether it was possible to add an instance variable via a category. My special problem is, that I need to add an NSIndexPath property to an ASIHTTPRequest object but I don't wanna subclass the ASIHTTPRequest as a matter of principle.

Do I have any kind of alternative?

Thanks for your answers, Christian


Source: (StackOverflow)

AFNetworking : How to know if response is using cache or not ? 304 or 200

I can't find any answer to my question, may be I miss something...

When I ask for a url, I need to know if the response comes from the cache or from the net.

Is the status code 304 or 200 ? (but AFNetworking always responde 200)

With ASIHTTPRequest I used to check "didUseCachedResponse" from ASIHTTPRequest, this was perfect.


Source: (StackOverflow)

How? UITableViewCell with UIImageView asynchronously loaded via ASINetworkQueue

I'm trying to load some images in table cells asynchronously using ASINetworkQueue. I just can't figure it out and can't seem to find a good SIMPLE example.

The best I can find is this, but its just totally overkill and a little too complicated for me: http://kosmaczewski.net/2009/03/08/asynchronous-loading-of-images-in-a-uitableview/

Does anyone else have any tips/solutions/code for doing this with the ASIHTTPRequest library?


Source: (StackOverflow)

Best substitute, successor or alternative for ASIHTTP for a download queue

I've recently read the news on http://allseeing-i.com that ASIHTTP is being discontinued. I have much respect for the makers of the library. However, I am now looking for a substitute that also supports queued download (multithreaded) on iOS, that also supports a progress bar with appropriate information.

Is there any (hopefully lightweight) library, that is in an active development livecycle? ARC support would also be much appreciated.

Many thanks for your thoughts.


Source: (StackOverflow)

Why are my ASIHTTPRequest files showing ARC errors?

I have implemented all of my ASIHTTPRequest files, but unfortunately the following errors occur:

enter image description here

enter image description here

Why is this happening?


Source: (StackOverflow)

Incorrect NSStringEncoding value 0x0000 detected (using ASIHTTPRequest)

I'm using ASIHTTPRequst in my application and im having some problems, but only on certain devices. In some cases i get the following error:

" Incorrect NSStringEncoding value 0x0000 detected. Assuming NSASCIIStringEncoding. Will stop this compatiblity mapping behavior in the near future "

I got limited options for testing this out, because it works on all my internal test devices, but the problem still occurs on one or more of my clients test phones. It may also be a case when the phone is connected to the cellular network, as it seems to be working on wifi.

Does anyone know what might cause the problem? I see there are similar type of questions but my code looks like its correct both from the other questions answers and the ASIHTTPRequest site.

Edit When the error occurs no response from server is recieved so the user is stuck at register/login.

urlEncodeValue:

- (NSString *)urlEncodeValue:(NSString *)str
{
    NSString *result = (NSString *) CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)str, NULL, CFSTR(":/?#[]@!$&’()*+,;="), kCFStringEncodingUTF8);
    return [result autorelease];
}

ASIHTTPRequest code snippet:

    NSString *encodedUrlAdress = [NSString stringWithFormat:@"%@user/register/%@/%@/%@/%d/%@/%@/%@/%@", 
                                   kUserServerAddress, 
                                   [self urlEncodeValue:_firstName], 
                                   [self urlEncodeValue:_lastName], 
                                   [self urlEncodeValue:_phoneNumber], 
                                   _sex, 
                                   [self urlEncodeValue:_birthDate], 
                                   [self urlEncodeValue:_address], 
                                   [self urlEncodeValue:_postalNumber]];    
    NSLog(@"encodedUrlAdress: %@", encodedUrlAdress);

    NSURL *url = [NSURL URLWithString:encodedUrlAdress];
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request startSynchronous];
    NSError *error = [request error];

    if (!error) {
// do stuff
}

Source: (StackOverflow)

iOS 5 : https ( ASIHTTPRequest) stop working

I got an app which use ASIHTTPRequest.

I recompiled my app with iOS 5 (sdk : 5.0 / xcode: 4.2 Build 4D199 ) and the https connections fail with error message (the same call with https disabled works fine):

Error Domain=ASIHTTPRequestErrorDomain Code=1 "A connection failure occurred" UserInfo=0xa8e66e0 {NSUnderlyingError=0xa8ac6c0 "The operation couldn’t be completed. (OSStatus error -9844.)", NSLocalizedDescription=A connection failure occurred}

With debug log enabled:

[STATUS] Starting asynchronous request <ASIFormDataRequest: 0xd96fc00>

[CONNECTION] Request <ASIFormDataRequest: 0xd96fc00> will not use a persistent connection

[STATUS] Request <ASIFormDataRequest: 0xd96fc00>: Failed

[CONNECTION] Request #(null) failed and will invalidate connection #(null)

I found this related post: https://devforums.apple.com/message/537440#537440 which could explain my problem.

based on the idea that iOS 5 prefer TLS 1.2, I try changing the setting kCFStreamSocketSecurityLevelTLSv1 in AIHTTPRequest.m                    

  NSDictionary *sslProperties = [[NSDictionary alloc] initWithObjectsAndKeys:
                                     [NSNumber numberWithBool:YES],
kCFStreamSSLAllowsExpiredCertificates,
                                     [NSNumber numberWithBool:YES], kCFStreamSSLAllowsAnyRoot,
                                     [NSNumber numberWithBool:NO],  kCFStreamSSLValidatesCertificateChain,
                                     kCFNull,kCFStreamSSLPeerName,
                                      kCFStreamSocketSecurityLevelTLSv1, kCFStreamSSLLevel,// my modif
                                     nil];

with no success. Maybe my modification is incorrect?

Details:

  • I got the ARC disabled
  • I use libz.1.2.5.dylib
  • I updated the ASIHTTPRequest a week ago.

I do not know if the issue is a certificate story (like TLS version) or something else.

any help/idea is welcome !


Source: (StackOverflow)

How to accept self-signed certificate with asihttprequest

I am trying to get a self-signed certificate to work with my application.

I am using the ASIHTTPRequest library at the moment like so :

- (IBAction)sendHttpsRequest
{    
    //Set request address
    NSMutableString *databaseURL = [[NSMutableString alloc] initWithString:@"https://142.18.87.46:443"];

    //call ASIHTTP delegates (Used to connect to database)
    NSURL *url = [NSURL URLWithString:databaseURL];

    //This sets up all other request
    ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];

    [request setDelegate:self];
    [request setValidatesSecureCertificate:YES];
    [request startAsynchronous];
}

I have set setValidatesSecureCertificate to YES in the hope that something would happen but obviously nothing has because I'm not sure what I have to do.

This is the error I'm getting in my log

2011-12-06 14:27:33.514 connectionTest[916:207] Error Domain=ASIHTTPRequestErrorDomain Code=1 "A connection failure occurred: SSL problem (Possible causes may include a bad/expired/self-signed certificate, clock set to wrong date)" UserInfo=0x683a860 {NSUnderlyingError=0x68390d0 "The operation couldn’t be completed. (OSStatus error -9807.)", NSLocalizedDescription=A connection failure occurred: SSL problem (Possible causes may include a bad/expired/self-signed certificate, clock set to wrong date)}

Any help would be greatly appreciated.


Source: (StackOverflow)

Apple Mach-O Linker (id) Error - undefined symbols for architecture i386

I know this type of error has been raised many times before, but I have not found solution of my error. I am using xcode 4.0. I downloaded ASIHTTPRequest zip and copied classes folder along with two files of 'Reachability". After compilation, it is giving me strange errors which I can't figure out. Below I copied text of error for undefined symbols for architecture i386.

Ld /Users/svp/Library/Developer/Xcode/DerivedData/Manual_BeforePres2-fahkeiivemkgpubswgvzglvndszw/Build/Products/Debug-iphonesimulator/Manual.app/Manual normal i386
cd "/Users/svp/Desktop/Manual nav before pres 2"
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -L/Users/svp/Library/Developer/Xcode/DerivedData/Manual_BeforePres2-fahkeiivemkgpubswgvzglvndszw/Build/Products/Debug-iphonesimulator -F/Users/svp/Library/Developer/Xcode/DerivedData/Manual_BeforePres2-fahkeiivemkgpubswgvzglvndszw/Build/Products/Debug-iphonesimulator -filelist /Users/svp/Library/Developer/Xcode/DerivedData/Manual_BeforePres2-fahkeiivemkgpubswgvzglvndszw/Build/Intermediates/Manual_BeforePres2.build/Debug-iphonesimulator/Manual.build/Objects-normal/i386/Manual.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -lz -framework SystemConfiguration -framework CFNetwork -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/svp/Library/Developer/Xcode/DerivedData/Manual_BeforePres2-fahkeiivemkgpubswgvzglvndszw/Build/Products/Debug-iphonesimulator/Manual.app/Manual

 Undefined symbols for architecture i386:
"_UTTypeCreatePreferredIdentifierForTag", referenced from:
  +[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
"_UTTypeCopyPreferredTagWithClass", referenced from:
  +[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
"_kUTTagClassFilenameExtension", referenced from:
  +[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
"_kUTTagClassMIMEType", referenced from:
  +[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
ld: symbol(s) not found for architecture i386

collect2: ld returned 1 exit status

Also it is giving me a warning in ASIAuthenticationDialog.m file:

ASIAuthenticationDialog may not respond to _presentingViewController

Please anyone tell me what are these errors and warning for? What am I doing wrong? I have wasted many hours over it :(

EDIT:

Code for warning in ASIAuthenticationDialog.m file:

#import "ASIAuthenticationDialog.h"
#import "ASIHTTPRequest.h"

#pragma mark show / dismiss

+ (void)dismiss
{
if ([sharedDialog respondsToSelector:@selector(presentingViewController)])
    [[sharedDialog presentingViewController] dismissModalViewControllerAnimated:YES];
else 
    [[sharedDialog parentViewController] dismissModalViewControllerAnimated:YES];
}

Source: (StackOverflow)