dlaczego RestKit zmienia mój typ zawartości odpowiedzi?

W skrócie: próbuję pobrać dane z serwera za pomocącontent-type nagłówka żądania HTTP ustawionego jako@"text/html.. ale z jakiegoś powodu RestKit zmienia to naapplication/JSON

Wyjaśnienie: Gdybym miał wykonać tę prośbę za pomocą justAFNetworking.. rzeczy działają jak urok ... tak wygląda mój kod AFNetworking:

AFHTTPClient *client = [AFHTTPClient alloc] initWithBaseURL:
                                               [NSURL URLWithString:kApiBaseUrl]];
singleton.parameterEncoding = AFJSONParameterEncoding;
[singleton setDefaultHeader:@"Accept" value:@"text/html"];
[client getPath:getPath parameters:nil success:successCallback failure:failureCallback];

Jeśli tego użyjędokładnie ten sam klient i dołącz go do

MyClient *client = [MyClient getSingleton];  //MyClient is instantiated as above        
self.objectManager = [[RKObjectManager alloc] initWithHTTPClient:client];
self.objectManager.managedObjectStore = self.managedObjectStore;
// this should have already been done by my client, but putting
// it here just to be sure
[self.objectManager setAcceptHeaderWithMIMEType:@"text/html"];

[[RKObjectManager sharedManager] getObjectsAtPath:kGradesPath 
                                       parameters:nil 
                                          success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
 // handle success
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
 // handle failure
}];

błąd jaki otrzymuję to:

 restkit.network:RKObjectRequestOperation.m:576 Object request failed: 
 Underlying HTTP request operation failed with error: Error
 Domain=org.restkit.RestKit.ErrorDomain Code=-1016 "Expected content type {(
    "application/x-www-form-urlencoded",
    "application/json"
)}, got text/html" UserInfo=0x8f7acd0

zagłębiając się w temat .. włożyłem punkt przerwaniamanagedObjectRequestOperationWithRequest, potem sprawdziłemacceptContentTypes zHTTPRequestOperation stworzone i to jest zero! Zakładam więc, że RestKit po prostu umieszcza własne domyślne akceptowalne typy zawartości. Po prostu nie wiem, gdzie i jak temu zapobiec. pomysły?

p.s. Nie mam kontroli nad serwerem, więc nie mogę go zmienićcontent-type nagłówek doapplication/JSON

Aktualizacja:

Okazuje się, że wRKObjectRequestOperation.m dostajemime-type z[RKMIMETypeSerialization registeredMIMETypes];(linia 354) .. i tak dalejRKMIMETypeSerialization.hjest metoda:

/**
 Registers the given serialization class to handle content for the given MIME Type identifier.

 MIME Types may be given as either a string or as a regular expression that matches the MIME Types for which the given serialization should handle. Serializations are searched in the reverse order of their registration. If a registration is made for an already registered MIME Type, the new registration will take precedence.

 @param serializationClass The class conforming to the RKSerialization protocol to be registered as handling the given MIME Type.
 @param MIMETypeStringOrRegularExpression A string or regular expression specifying the MIME Type(s) that given serialization implementation is to be registered as handling.
 */
+ (void)registerClass:(Class<RKSerialization>)serializationClass forMIMEType:(id)MIMETypeStringOrRegularExpression;

jak użyć tego do zarejestrowaniatext/html Typ zawartości?

questionAnswers(2)

yourAnswerToTheQuestion