romaonthego
romaonthego

Reputation: 810

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 (occurs 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?

Upvotes: 2

Views: 1097

Answers (1)

LDN
LDN

Reputation: 86

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

Upvotes: 7

Related Questions