开发者

Sending post request does not send post body to server

I have the following code used to post data to a remote server:

NSString *urlStr = [[NSString alloc] initWithFormat: @"http://www.myserver.com/%@",program ];
    NSString *postBody =[[NSString alloc] initWithFormat:@"uid=%@",parms]; 
    NSMutableURLRequest *request;
    NSData *postData = [postBody dataUsingEncoding:NSISOLatin1StringEncoding];
    NSError *error;
    NSURLResponse *response;
    NSData *dataReply;

    request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString:urlStr]];
    [request setHTTPMethod: @"POST"];
    [request setHTTPBody:postData]; 

    dataReply = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
    serverResponse = (NSString *)[[NSString alloc] initWithData:dataReply encoding:NSUTF8StringEncoding];
    [postBody release];
    [urlStr release];

program is the php program to run on the server. parms is the string to be posted in the format:

\ntoken=12345

Here开发者_运维百科's the problem: This works fine from the simulator. It works fine on my 3gs development phone. It works fine on a beta tester's 3gs phone that I emailed the app to. It does NOT work fine on another beta tester's iPhone 4 (emailed to him the exact same provision file and ipa file). The POST call is made from the iPhone 4 to the server but no post body is passed. I log each of the calls to the server on the server. The post body is there for the 3gs phones, not for the 4 phone. There are no errors generated in the Apache logs.

Is there some difference between the two phone models that I need to account for? I have tried both http and https access with the same behavior. I don't currently have access to an iPhone 4 so any insight would be a great help.


The answer is not model related. It has to do with the name of the phone which is passed as a parameter to the server. The name contains an apostrophe as in Mike's iPhone.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜