아이폰 오브젝티브-C 서버에 쿠키 저장 하는방법 질문 입니다.
외부 서버에 http가이렇게 되어있다고 합니다.
여기서 빨간색으로 된곳에 쿠키로 userid랑 password를 저장해야 하는데요
서버에 GET이던 POST이던 쿠키를 저장해야 인증이 되서 다른걸 할수 있는데 인증이 안되네요
NSString *smsURL = @"http://주소;
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
NSString *post = @"userid=root&password=pass";
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]];
[request setURL:[NSURL URLWithString:smsURL]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Authorization"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
[NSURLConnection connectionWithRequest:request delegate:self ];
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
To query information of IP camera, use the syntax
GET http:///?= HTTP/1.0
Authorization: Basic
where,
is a URL of a CGI. For example, get basic information is “/common/info.cgi”.
Authorization is optional for some CGIs.
is the base64 encoding of userid:password.
is Carriage Return and Line Feed (\r\n).
To set values in the IP camera, you may use HTTP GET method, the syntax is
GET http:///
?=[&=...] HTTP/1.0
Authorization: Basic
or HTTP method POST, the syntax is
POST http:/// HTTP/1.0
Authorization: Basic
Content-Type: application/x-www-form-urlencoded
Content-Length:
=[&=]
where,
is the length of the entity body.
will be described in the following chapters. Valid characters only include alphabets([A-Za-z]), digits([0-9]) and
underline(_). There is no such restriction for . The content part of the post message should be encoded with “url- encoding”
function.
댓글 달기