0

I'm trying to to send some post data to a Apache server from iPad application using the ASIHttp library.

actually I need to send huge data to the server and that means I need to compress the request body so I write some code to send the data and compress the request BUT there are no parameters received on the server !!!

the iOS code is :

        NSURL * URL = [NSURL URLWithString:myURL];  
        ASIFormDataRequest *ASIRequest = [ASIFormDataRequest requestWithURL:URL];
        ASIRequest.shouldCompressRequestBody=YES;
        ASIRequest setPostValue:data forKey:@"data"];
        [ASIRequest startSynchronous];
        NSError *error = [ASIRequest error];
        if (!error) {
            NSString *response = [ASIRequest responseString];
            NSLog(@"response %@" , response);
        }

PS: if I removed the ASIRequest.shouldCompressRequestBody=YES; everything works fine and I can see the data but when use it I see nothing on the server

  1. the request can be seen on the server but with no parameter
  2. noway to send such data over GET method.
  3. the server configuration are fine.

any solution ? any comment or idea can help ?

daigoor
  • 685
  • 8
  • 21

1 Answers1

0

By default, most web servers do not support compression on POSTs. The accepted answer here does a really good job explainining it: Why can't browser send gzip request?

According to official documentation, this feature has only been tested with Apache servers.

EDIT:

Here is a code snipt that compresses the actual post data:

if ([self shouldCompressRequestBody]) {
    NSError *err = nil;
    NSData *compressedBody = [ASIDataCompressor compressData:[self postBody] error:&err];
    if (err) {
        [self failWithError:err];
        return;
    }
    [self setCompressedPostBody:compressedBody];
    [self setPostLength:[[self compressedPostBody] length]];
} 

Source: http://forums.three20.info/discussion/77/tturlrequest-vs-asihttprequest/p1

Community
  • 1
  • 1
Jason
  • 4,232
  • 3
  • 23
  • 31
  • I'm sure my server can accept zipped requests my problem is on the client side. – daigoor May 09 '12 at 09:14
  • Can you humor me and try to send a compressed request via another client like curl? Just want to be 100% sure the sever is working correctly. – Jason May 09 '12 at 09:21
  • I did and I said that "the server configuration are fine." I'm using also Android client to do so and everything is fine ! – daigoor May 09 '12 at 09:28
  • Are you doing something like this to compress your form data? NSData *data = [ASIDataCompressor compressData:[self postBody] error:&err]; – Jason May 09 '12 at 09:37
  • no I'm not ! using this method will make not affect the data size and this is need a manual handling of data uncompromising on the server and this is can\t be done. – daigoor May 09 '12 at 09:44
  • my problem is that I do everything as I mentioned in the real post but the server does not see anything ! also there are nothing called setCompressedData – daigoor May 09 '12 at 11:18