누구든지이 문제에 대한 해결책을 찾을 수 있습니까? 다운로드 한 내용은 iws> 2500 바이트이지만 변환되는 동안 nsstring은 비어있는 것을 반환합니다.utf-8 유형은 nsurlconnection을 다운로드하는 동안 129 바이트를 초과하지 않습니다.
NSMutableString *postString = [NSMutableString string];
// NSMutableString *postString = [[NSMutableString alloc] init];
[postString appendFormat:@"username=%@",[strUsrName dataUsingEncoding:NSUTF8StringEncoding]];
[postString appendFormat:@"&password=%@",[strPasswrd dataUsingEncoding:NSUTF8StringEncoding]];
[postString appendFormat:@"&client_assertion_type=%@",[@"JWT"dataUsingEncoding:NSUTF8StringEncoding]];
[postString appendFormat:@"&client_assertion=%@",[strAppTknContent dataUsingEncoding:NSUTF8StringEncoding]];
[postString appendFormat:@"&spEntityID=%@",[@"http://localhost:8080/opensso"dataUsingEncoding:NSUTF8StringEncoding]] ;
NSHTTPURLResponse *response = nil;
NSError *error = nil;
NSMutableURLRequest *theRequest = [[NSMutableURLRequest alloc] initWithURL:nsurl];
NSData* dataRequest = [postString dataUsingEncoding: NSISOLatin1StringEncoding ];
// NSData* dataRequest = [NSData dataWithBytes:strRequest];
[theRequest setHTTPMethod: @"POST"];
[theRequest setHTTPBody: dataRequest];
[theRequest setURL:nsurl];
//// set headers
NSString *contentType = [NSString stringWithFormat:@"text/plain"];
[theRequest setValue:contentType forHTTPHeaderField:@"Content-Type"];
NSString *acceptType = [NSString stringWithFormat:@"application/json"];
[theRequest setValue:acceptType forHTTPHeaderField:@"accept"];
[theRequest setTimeoutInterval:3.0];
[theRequest setCachePolicy:NSURLRequestReturnCacheDataElseLoad];
NSData *responseData =[NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error];
NSString *strUserResponse =[[NSString alloc]initWithData:responseData encoding:NSISOLatin1StringEncoding];
int status =[response statusCode ] ;
staus : 204 만 strUserResponse이
'dataRequest'에는 실제로 무엇이 들어 있습니까? 'postString'에 문자열을 추가 할 때 문자열을 UTF-8로 변환하고이를 Latin-1로 변환하면 데이터가 잘리는 것은 놀랄 일이 아닙니다. – sbooth
204는 "내용 없음"입니다. 어떻게 responseData를 기대할 수 있습니까? –