誰でもこの問題の解決策を見つけるのを手伝ってください。ダウンロードされたコンテンツはiws> 2500バイトですが、変換中にnsstringは空を返します。utf-8 type does not accept> 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を期待できますか? –