Hi Rob and Jorg,

It seems like I'm having related problems. 
Basically, I have a website built with angularJS which is meant to be 
mobile-friendly. The app basically makes one POST request to a JAVA server 
and I've been seeing a long lag upon a POST request on iOS Safari when 
testing on an iPad and on an iPhone. 
I am using the Angular $http call to make the POST request, which means 
just before the POST request, the app makes an OPTIONS preflight request. 
The JAVA server in accepts OPTIONS request and the app works without a 
problem in other browsers on pc (windows and Mac) as well as other Android 
devices. However, on the iPad and iPhone, the OPTIONS request takes 
anywhere from 8 seconds to 20 seconds. 

I found this thread because I was trying to find a solution to this problem 
and it seems like you have found a solution to your problem. If so, can you 
explain how you've solved the problem you are dealing with? I do understand 
that our problems may not be exactly the same but I'd like to understand 
how you've solved yours. 

Thanks,
Sam

On Wednesday, February 4, 2015 at 1:42:39 AM UTC-8, Jörg Zimmer wrote:
>
> Hey Rob,
>
> I think you will bang your head now, as I just did...
> I also have it working just in this second... BUT: I just did some apache 
> config:
>
> Header always set Access-Control-Allow-Headers 
> "Origin,X-Requested-With,Content-Type,Accept,Authorization,Accept-Language,Content-Language,Last-Event-ID,X-HTTP-Method-Override"
> Header always set Access-Control-Allow-Methods 
> "GET,POST,PUT,DELETE,OPTIONS"
> Header always set Access-Control-Allow-Credentials "true"
> Header always set Cache-Control "max-age=0"
>
> I added the Headers for credentials and cache-control plus the 
> allow-headers entry for X-HTTP-Method-Override.
> Don't know what exactly does the trick, but even the older Version of my 
> angular-app now works on my iPhone with iOS8...
>
> Will do some more testing, but I think this was it....
>
>
>
>
>
> Am Mittwoch, 4. Februar 2015 01:56:44 UTC+1 schrieb Rob Koberg:
>>
>> I have this working now, but I had to use jQuery.ajax and not angular's 
>> own. Here is what works:
>>
>>
>> SessionCreator.$inject = ['$http', '$q', '$rootScope', '$timeout', 'ENV', 
>> 'User'];
>> function SessionCreator($http, $q, $rootScope, $timeout, ENV, User) {
>>
>>   var deferred = $q.defer();
>>
>>   jQuery.ajax(ENV.apiEndPoint + '/user-init', {
>>
>>     accepts: 'application/json',
>>     dataType: 'json',
>>     headers: {
>>       Accept: 'application/json',
>>       Authorization: User.getAuth()
>>     },
>>
>>
>>     success: function(data) {
>>
>>       $rootScope.maintenance = false;
>>       User.init(data.user);
>>       $rootScope.totalReads = data.totalReads;
>>
>>       if (data.maintenance) {
>>         $rootScope.maintenance = true;
>>         $rootScope.maintenanceMsg = data.content;
>>       }
>>
>>       deferred.resolve();
>>     },
>>     error: function(jqXHR, status, errorThrown) {
>>       console.log('SessionCreator error jqXHR', jqXHR);
>>       console.log('SessionCreator error status', status);
>>       console.log('SessionCreator error errorThrown', errorThrown);
>>
>>         User.init(data.user);
>>         $rootScope.totalReads = data.totalReads;
>>         if (data.maintenance) {
>>           $rootScope.maintenance = true;
>>           $rootScope.maintenanceMsg = data.content;
>>         }
>>       jQuery('.loader-wrap').fadeOut();
>>       $timeout(function() {});
>>
>>     }
>>   });
>>
>>   return deferred.promise;
>> }
>>
>>
>> This does not work:
>>
>>
>> SessionCreator.$inject = ['$http', '$q', '$rootScope', '$timeout', 'ENV', 
>> 'User'];
>> function SessionCreator($http, $q, $rootScope, $timeout, ENV, User) {
>>
>>   var deferred = $q.defer();
>>
>> // used text here to try and avoid preflight request. Didn't work.
>>   $http
>>     .get(ENV.apiEndPoint + '/user-init',
>>       {
>>         responseType: 'text',
>>         headers: {
>>           Accept: 'text/plain'
>>         }
>>       }
>>     )
>>     .success(function(data) {
>>       $rootScope.maintenance = false;
>>       User.init(data.user);
>>       $rootScope.totalReads = data.totalReads;
>>   
>>       if (data.maintenance) {
>>         $rootScope.maintenance = true;
>>         $rootScope.maintenanceMsg = data.content;
>>       }
>>   
>>       deferred.resolve();
>>     })
>>     .error(function(data, status, headers, config) {
>>       console.log('SessionCreator error data', data);
>>       console.log('SessionCreator error status', status);
>>       console.log('SessionCreator error headers', headers);
>>       console.log('SessionCreator error config', config);
>>   
>>         User.init(data.user);
>>         $rootScope.totalReads = data.totalReads;
>>         if (data.maintenance) {
>>           $rootScope.maintenance = true;
>>           $rootScope.maintenanceMsg = data.content;
>>         }
>>       jQuery('.loader-wrap').fadeOut();
>>       $timeout(function() {});
>>   
>>     });
>>
>>   return deferred.promise;
>> }
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to