Por que o RestKit está alterando meu tipo de conteúdo de resposta?

Em suma: eu tento buscar dados do servidor com ocontent-type do cabeçalho de solicitação http definido como@"text/html.. mas por algum motivo RestKit muda isso paraapplication/JSON

Explicação: Se eu fizesse esse pedido usando apenasAFNetworking.. as coisas funcionam como um encanto ... é assim que meu código AFNetworking se parece:

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];

Se eu usar issoexatamente o mesmo cliente e anexá-lo a

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
}];

o erro que recebo é:

 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

cavando o assunto .. eu coloquei um ponto de ruptura emmanagedObjectRequestOperationWithRequest, então eu verifiquei oacceptableContentTypes doHTTPRequestOperation criado, e é nulo! Então, estou assumindo que o RestKit está apenas colocando seus próprios tipos de conteúdo aceitáveis ​​padrão. Eu simplesmente não sei onde e como evitá-lo. ideias?

p.s. Eu não tenho controle sobre o servidor, então eu não posso mudar issocontent-type cabeçalho paraapplication/JSON

Atualizar:

Acontece que emRKObjectRequestOperation.m fica omime-type de[RKMIMETypeSerialization registeredMIMETypes];(linha 354) .. e assim por dianteRKMIMETypeSerialization.hexiste o método:

/**
 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;

como eu uso isso para registrar umtext/html tipo de conteúdo?

questionAnswers(2)

yourAnswerToTheQuestion