objective c - NSMutableURLRequest setValue:forHTTPHeaderField failing for really long values -
here's code snippet i'm working on:
nserror *error = nil; nsdata *data = [nsjsonserialization datawithjsonobject:body options:0 error:&error]; nsstring *string = [[nsstring alloc]initwithdata:data encoding:nsutf8stringencoding]; [request setvalue:[[nsstring alloc] initwithformat:@"%d", string.length] forhttpheaderfield:@"content-length"]; [request setvalue:string forhttpheaderfield:@"json"]; [request sethttpbody:data]; nslog(@"request.values: %@", [request allhttpheaderfields]);
the nslog returns first value:header (i.e. "content-length" = 74288), not show value:header containing string property. i've checked string exists, it's long. guess it's length of value field causing not set header. that, or json format weird (it's dictionary containing array of dictionaries).
any thoughts?0
Comments
Post a Comment