ATHttpConnectionManagerRequest
public class ATHttpConnectionManagerRequest: NSObject
The ATHttpConnectionManagerRequest allows to create a request for ATHttpConnectionManager.
-
The variable allows to enable / disable the logs for the request.
Usage Example
let aRequest = ATHttpConnectionManagerRequest() aRequest.isLogEnabled = true
Note
It is recommended to disable the logs for production release.Declaration
Swift
public var isLogEnabled :Bool = false
-
The variable allows to set a URL for the request.
Usage Example
let aRequest = ATHttpConnectionManagerRequest() aRequest.url = URL(string: "https://example.com/")
See also
var httpMethod :String?
func addHttpHeader(name :String, value :String)
func removeHttpHeader(name :String)
func addHttpParameter(name :String, value :Data)
func removeHttpParameter(name :String)
func addHttpAttachment(_ :ATHttpConnectionManagerAttachment)
func addHttpAttachment(requestParameterName :String, attachmentData :Data)
Declaration
Swift
public var url :URL?
-
The variable allows to set an HTTP method (GET, POST, PUT etc.) for the request.
Usage Example
let aRequest = ATHttpConnectionManagerRequest() aRequest.httpMethod = "POST"
See also
var url :URL?
func addHttpHeader(name :String, value :String)
func removeHttpHeader(name :String)
func addHttpParameter(name :String, value :Data)
func removeHttpParameter(name :String)
func addHttpAttachment(_ :ATHttpConnectionManagerAttachment)
func addHttpAttachment(requestParameterName :String, attachmentData :Data)
Declaration
Swift
public var httpMethod :String?
-
The variable allows to get http headers added to the request.
Usage Example
let aRequest = ATHttpConnectionManagerRequest() aRequest.httpHeaders
See also
func addHttpHeader(name :String, value :String)
func removeHttpHeader(name :String)
Declaration
Swift
public var httpHeaders :[String:String]?
-
The variable allows to set/get http body of the request.
Usage Example
let aRequest = ATHttpConnectionManagerRequest() aRequest.httpBody = "{\"request\":\"submit\"}".data(using: String.Encoding.utf8)
Note
If ‘var httpBody’ is provided, then ‘var httpParameters’ will be ignored while sending http request body.
See also
var httpParameters :[String:Data]?
func addHttpParameter(name :String, value :Data)
func removeHttpParameter(name :String)
Declaration
Swift
public var httpBody :Data?
-
The variable allows to get http parameters added to the request.
Usage Example
let aRequest = ATHttpConnectionManagerRequest() aRequest.httpParameters
Note
If ‘var httpBody’ is provided, then ‘var httpParameters’ will be ignored while sending http request body.
See also
func addHttpParameter(name :String, value :Data)
func removeHttpParameter(name :String)
Declaration
Swift
public var httpParameters :[String:Data]?
-
The variable allows to get http attachments added to the request.
Usage Example
let aRequest = ATHttpConnectionManagerRequest() aRequest.httpAttachments
See also
func addHttpAttachment(_ :ATHttpConnectionManagerAttachment)
func addHttpAttachment(requestParameterName :String, attachmentData :Data)
Declaration
Swift
public var httpAttachments :Array<ATHttpConnectionManagerAttachment>?
-
The variable allows to set end of the part for the multipart request. Mostly it is – or \r\n.
Usage Example
let aRequest = ATHttpConnectionManagerRequest() aRequest.endOfPartString = "\r\n"
Declaration
Swift
public var endOfPartString :String?
-
Initializer.
Declaration
Swift
public override init()
-
Custom initializer.
Usage Example
let aRequest = ATHttpConnectionManagerRequest(url: URL(string: "http://google.com")!, httpMethod: "POST")
See also
init(urlString pUrlString :String, httpMethod pHttpMethod :String)
Declaration
Swift
public init(url pUrl :URL, httpMethod pHttpMethod :String = "GET")
Parameters
pUrl
URL. URL to which request is to be made.
pHttpMethod
String. HTTP method e.g. GET, POST, PUT etc.
-
Custom initializer.
Usage Example
let aRequest = ATHttpConnectionManagerRequest(urlString: "http://google.com", httpMethod: "POST")
See also
init(url pUrl :URL, httpMethod pHttpMethod :String)
Declaration
Swift
public init(urlString pUrlString :String, httpMethod pHttpMethod :String = "GET")
Parameters
pUrlString
String. URL as string to which request is to be made.
pHttpMethod
String. HTTP method e.g. GET, POST, PUT etc.
-
The method allows to add HTTP header to the request.
Usage Example
let aRequest = ATHttpConnectionManagerRequest() aRequest.addHttpHeader(name: "Content-Type", value: "application/json")
See also
func removeHttpHeader(name :String)
Declaration
Swift
public func addHttpHeader(name pName :String, value pValue :String)
Parameters
pName
Name of the http header.
pValue
Value of the http header.
-
The method allows to remove HTTP header from the request.
Usage Example
let aRequest = ATHttpConnectionManagerRequest() aRequest.removeHttpHeader(name: "Content-Type")
See also
func addHttpHeader(name :String, value :String)
Declaration
Swift
public func removeHttpHeader(name pName :String)
Parameters
pName
Name of the http header.
-
The method allows to add HTTP parameter to the request.
Usage Example
let aRequest = ATHttpConnectionManagerRequest() aRequest.addHttpParameter(name: "first_name", value: "Tony".data(using: String.Encoding.utf8)!) aRequest.addHttpParameter(name: "last_name", value: "Stark".data(using: String.Encoding.utf8)!)
Note
If ‘var httpBody’ is provided, then ‘var httpParameters’ will be ignored while sending http request body.
See also
func removeHttpParameter(name :String)
Declaration
Swift
public func addHttpParameter(name pName :String, value pValue :Data)
Parameters
pName
Name of the http parameter.
pValue
Value of the http parameter.
-
The method allows to remove HTTP parameter from the request.
Usage Example
let aRequest = ATHttpConnectionManagerRequest() aRequest.removeHttpParameter(name: "first_name")
See also
func addHttpParameter(name :String, value :String)
Declaration
Swift
public func removeHttpParameter(name pName :String)
Parameters
pName
Name of the http parameter.
-
The method allows to add HTTP attachment to the request.
Usage Example
let aRequest = ATHttpConnectionManagerRequest() let anAvatarImage = UIImage() // Assign image as you want let anAttachment = ATHttpConnectionManagerAttachment(requestParameterName: "user_avatar", fileTitle: "Avatar", fileExtension: "jpg", fileData: UIImageJPEGRepresentation(anAvatarImage, 0.8)!, shouldEncodeInBase64: false) aRequest.addHttpAttachment(anAttachment)
Note
If ‘var httpBody’ is provided, then ‘var httpAttachments’ will be ignored while sending http request body.
See also
func addHttpAttachment(requestParameterName pRequestParameterName :String, attachmentData pAttachmentData :Data)
func removeHttpAttachment(requestParameterName pRequestParameterName :String)
Declaration
Swift
public func addHttpAttachment(_ pAttachment :ATHttpConnectionManagerAttachment)
Parameters
pAttachment
Object of ATHttpConnectionManagerAttachment class with attachment details.
-
The method allows to add HTTP attachment to the request.
Usage Example
let aRequest = ATHttpConnectionManagerRequest() let anAvatarImage = UIImage() // Assign image as you want aRequest.addHttpAttachment(requestParameterName: "user_avatar", attachmentData: UIImageJPEGRepresentation(anAvatarImage, 0.8)!)
Note
If ‘var httpBody’ is provided, then ‘var httpAttachments’ will be ignored while sending http request body.
See also
func addHttpAttachment(_ pAttachment :ATHttpConnectionManagerAttachment)
func removeHttpAttachment(requestParameterName pRequestParameterName :String)
Declaration
Swift
public func addHttpAttachment(requestParameterName pRequestParameterName :String, attachmentData pAttachmentData :Data)
Parameters
pRequestParameterName
Http request parameter name.
pAttachmentData
Http attachment data.
-
The method allows to remove HTTP attachment from the request.
Usage Example
let aRequest = ATHttpConnectionManagerRequest() // Create request will added attachments aRequest.removeHttpAttachment(requestParameterName: "user_avatar")
See also
func addHttpParameter(name :String, value :String)
Declaration
Swift
public func removeHttpAttachment(requestParameterName pRequestParameterName :String)
Parameters
pRequestParameterName
Name of the http parameter for the attachment.