NetworkModule

大约 2 分钟

NetworkModule

HTTP请求模块

requestGet方法

发送HTTP GET请求


参数

参数描述类型
url 必需请求urlString
param 必需请求参数JSONObject
responseCallback 必需请求回调闭包NMAllResponse

requestPost方法

发送HTTP POST请求


参数

参数描述类型
url 必需请求urlString
param 必需请求参数JSONObject
responseCallback 必需请求回调闭包NMAllResponse

httpRequest方法

发送HTTP通用请求方法


参数

参数描述类型
url 必需请求urlString
isPost 必需是否为POST请求Boolean
param 必需请求参数JSONObject
headers 非必需请求头参数JSONObject
cookie 非必需请求cookieString
timeout 非必需请求超时时间, 单位为秒Int
responseCallback 必需请求回调闭包NMAllResponse

requestGetBinary方法

发送二进制HTTP GET请求


参数

参数描述类型
url 必需请求urlString
param 必需请求参数JSONObject
responseCallback 必需请求回调闭包NMDataResponse

requestPostBinary方法

发送二进制HTTP POST请求


参数

参数描述类型
url 必需请求urlString
bytes 必需请求参数ByteArray
responseCallback 必需请求回调闭包NMDataResponse

httpRequestBinary方法

发送二进制HTTP通用请求方法


参数

参数描述类型
url 必需请求urlString
isPost 必需是否为POST请求Boolean
bytes 必需请求参数ByteArray
param 非必需请求参数JSONObject
headers 非必需请求头参数JSONObject
cookie 非必需请求cookieString
timeout 非必需请求超时时间, 单位为秒Int
responseCallback 必需请求回调闭包NMDataResponse

类型说明

NMAllResponse

NMAllResponse = (data: JSONObject, success : Boolean , errorMsg: String, response: NetworkResponse) -> Unit
参数描述类型
data返回数据JSONObject
success请求是否成功Boolean
errorMsg错误信息String
response响应包信息NetworkResponse

NMDataResponse

NMDataResponse = (data: ByteArray, success: Boolean, errorMsg: String, response: NetworkResponse) -> Unit
参数描述类型
data返回数据ByteArray
success请求是否成功Boolean
errorMsg错误信息String
response响应包信息NetworkResponse

NetworkResponse

参数描述类型
headerFields响应头参数JSONObject
statusCode 非必需响应状态码Int