开发者

problem in setting parameters for NSMutableURLRequest ( POST request)

开发者 https://www.devze.com 2023-03-09 21:04 出处:网络
am setting the parameters(key-value pairs - user name, password, email id) for NSMutableURLRequest(POST) using the class method

am setting the parameters(key-value pairs - user name, password, email id) for NSMutableURLRequest(POST) using the class method

 + (void)setProperty:(id)value forKey:(NSString *)key inRequest:(NSMutableURLRequest *)request

and requesting the server using sendSynchronous.

But at the server end, 开发者_StackOverflow中文版the parameters are null.

plz suggest me some other new solution???


Use ASIFormDataRequest. Its -setPostValue:forKey: method makes POSTing data as application/x-www-urlformencoded or multipart/form-data dead simple.

If you want to use NSURLRequest instead, check out the OAuthConsumer project for an example of using application/x-www-form-urlencoded. Start by reading -setParameters: in NSMutableURLRequest+Parameters.m and go from there. For sending data asmultipart/form-datausingNSURLRequest`, see Facebook's FBRequest.

+[NSURLProtocol setProperty:forKey:inRequest:] is intended to be used to extend the URL loading system to support additional protocols:

Protocol implementors who need to extend the capabilities of NSURLRequest and NSMutableURLRequest [by providing categories on these classes] can store and retrieve protocol-specific request data by using NSURLProtocol’s class methods propertyForKey:inRequest: and setProperty:forKey:inRequest:. (here)

0

精彩评论

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