i want to send an If-Modified-Since
http header with a GET request, issued by [RKObjectManager getObjectsAtPath:...]
.
the migration guide tells that i can set only "global" default request headers for an RKObjectManager
instance:
RKObjectManager* objectManager = [RKObjectManager managerWithBaseURLString:url];
[objectManager.HTTPClient setDefaultHeader:@"If-Modified-Since" value:@"Sat, 29 Dec 2012 19:43:31 GMT"];
since i want to keep a centralized RKObjetManager
instance (via [RKObjectManager sharedManaged]
), this is not really a good option.
is creating a specific RKObjectManager
before each request and set my http headers as "default" the only solution or is there a better way?
There are a few options here:
NSURLRequest
object using requestWithObject:method:path:parameters:
, configure the NSURLRequest
appropriately, and then invoke objectRequestOperationWithRequest:success:failure:
or managedObjectRequestOperationWithRequest:managedObjectContext:success:failure:
. This will let you configure the requests on a one-off basis.RKHTTPRequestOperation
via setHTTPOperationClass:
on RKObjectManager
. This will let you hook subclass in that can configure every NSURLRequest as the object manager makes requests, letting you centralize the configuration.RKObjectRequestOperation
with the manager that will be used for requests of your choosing, enabling you to centralize customization at the object request operation level.Options 1 or 2 are probably most appropriate for the HTTP level concern you outline, but I mention as an alternative for doing the same sort of customization at the object mapping level.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With