ASIFormDataRequest empty POST request
I'm using ASIFormDataRequest to send multipart POST data to a server running nginx + php-fpm.
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:sessionKey forKey:@"session"];
[request setPostValue:secret forKey:@"secret"];
[request setPostValue:@"test" forKey:@"description"];
[request setFile:filePath forKey:@"image"];
[request setTimeOutSeconds:120];
[request setDelegate:self];
[request startAsynchronous];
However, once in a while (occu开发者_如何学Crs very randomly, hard to reproduce) an empty request reaches server, I'm using the same file for all tests. ASIHTTPRequest peforms requestFinished, like everything's ok.
No server-side errors generated, I checked logs.
Has anyone had this problem before?
I had this problem too earlier today. It has something to do with nginx behaviour on how to reuse a connection. A simple fix is to just add the following to your request procedure:
[request setShouldAttemptPersistentConnection:NO];
This option also has been set to NO by default in the newest build of ASIHTTPRequest. Read more about it at Github:
Stop using persisted connections on POST/PUT
精彩评论