开发者

iPhone ASIFormDataRequest with multipart/form-data

开发者 https://www.devze.com 2023-01-08 03:11 出处:网络
as I have read in the ASI Documentation, its writen: \"Data is posted in \'application/x-www-form-urlencoded\' format, or \'multipart/form-data\' format when uploading binary data or files.\"

as I have read in the ASI Documentation, its writen: "Data is posted in 'application/x-www-form-urlencoded' format, or 'multipart/form-data' format when uploading binary data or files."

That's exactly my Problem. I am sending just a String to a server, but the server just accepts 'multipart/form-data' and as I just send a String, the ASI Framework creates a POST request with 'application/x-www-form-urlencoded' format automatically, cause I am not sending any binary data or file. Result: the server does not acce开发者_StackOverflow中文版pt my POST request.

How could I solve this problem?

Thanks in advance for helping.


You could set the format manually:

[request setPostFormat:ASIMultipartFormDataPostFormat];


I've just solved this problem in a very ugly way: I've changed the ASIFormDataRequest implementation on line 200:

if ([self postFormat] == ASIURLEncodedPostFormat) {
    [self buildMultipartFormDataPostBody];  //NEW LINE  
    //[self buildURLEncodedPostBody];  ORIGINAL LINE
} else {
    [self buildMultipartFormDataPostBody];
}

I would be glad to hear any other suggestion!

0

精彩评论

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