I need a NSMutableURLRequest header which looks like:
---begin
POST /index.php HTTP/1.1
Content-Length: 91
Host: 192.168.1.3:8803
Content-Type: application/x-www-form-urlencoded
command=01&version=V0.1&type=3
----end
some one please tell me how I can make a header field looks like the last line. Separated from the others with an empty line is better.
That last line isn't a header, it's the body of the request. Just set the body data with that value as a string, like this:
NSString *params = @"command=01&version=V0.1&type=3";
NSData *data = [params dataUsingEncoding:NSUTF8StringEncoding];
//set headers
[self addValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[self addValue:[NSString stringWithFormat:@"%i", [data length]] forHTTPHeaderField:@"Content-Length"];
//set body
[self setHTTPBody:data];