<TRCRequestSerializer > Protocol Reference

Defines protocol for objects which converts TRCRequest.requestBody object into NSData More...

Inheritance diagram for <TRCRequestSerializer >:

Instance Methods

(NSData *) - bodyDataFromObject:forRequest:error:
 Convert your requestObject into NSData here. More...
 
(NSInputStream *) - bodyStreamFromObject:forRequest:error:
 Convert your requestObject into NSInputStream here. More...
 
(NSString *) - contentType
 This is string which would be used as Content-Type HTTP header value. More...
 

Detailed Description

Defines protocol for objects which converts TRCRequest.requestBody object into NSData

You should implement one of these method:

  • dataFromRequestObject:error:
  • dataStreamFromRequestObject:error:

If both implemented, then only dataFromRequestObject:error will be used.

Method Documentation

◆ bodyDataFromObject:forRequest:error:()

- (NSData * TRCRequestSerializer) bodyDataFromObject: (id)  requestObject
forRequest: (NSMutableURLRequest *)  urlRequest
error: (NSError **)  error 
optional

Convert your requestObject into NSData here.

Parameters
requestObjectobject taken from TRCRequest.requestBody
errorwrite NSError into that pointer if error happens
Returns
NSData which used as request body

◆ bodyStreamFromObject:forRequest:error:()

- (NSInputStream * TRCRequestSerializer) bodyStreamFromObject: (id)  requestObject
forRequest: (NSMutableURLRequest *)  urlRequest
error: (NSError **)  error 
optional

Convert your requestObject into NSInputStream here.

This method useful in next cases:

  • when your requestObject is NSInputStream
  • when your requestObject points to file to upload, or too large to be loaded into memory
Parameters
requestObjectobject taken from TRCRequest.requestBody
errorwrite NSError into that pointer if error happens
Returns
NSInputStream which used to upload request body

◆ contentType()

- (NSString * TRCRequestSerializer) contentType
optional

This is string which would be used as Content-Type HTTP header value.

If not implemented or returns nil, then Content-Type would not be specified.